[honey] Pad single file databases better
[xapian.git] / xapian-core / backends / honey / honey_defs.h
bloba8386ae3284ea1a5175af7ea7af7e71e2afd914d
1 /** @file honey_defs.h
2 * @brief Definitions, types, etc for use inside honey.
3 */
4 /* Copyright (C) 2010,2014,2015,2017,2018 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_HONEY_DEFS_H
22 #define XAPIAN_INCLUDED_HONEY_DEFS_H
24 #include "internaltypes.h"
26 #define SST_SEARCH
28 /// Honey table extension.
29 #define HONEY_TABLE_EXTENSION "honey"
31 /** Minimum size to pad a honey table to.
33 * Having this minimum size means we can usually know from the size that a
34 * stub database file isn't a single file database.
36 #define HONEY_MIN_DB_SIZE 2048
38 /// Default B-tree block size.
39 #define HONEY_DEFAULT_BLOCKSIZE 8192
41 /// Minimum B-tree block size.
42 #define HONEY_MIN_BLOCKSIZE 2048
44 /// Maximum B-tree block size.
45 #define HONEY_MAX_BLOCKSIZE 65536
47 /// Maximum key length.
48 #define HONEY_MAX_KEY_LEN 255
50 // Maximum size of a document length chunk in bytes.
51 #define HONEY_DOCLEN_CHUNK_MAX 2016
53 /** The largest docid value supported by honey.
55 * The disk format supports 64-bit docids, but if Xapian::docid is narrower
56 * then it's the largest value supported by the type that matters here.
58 #define HONEY_MAX_DOCID Xapian::docid(0xffffffffffffffff)
60 namespace Honey {
62 enum table_type {
63 POSTLIST,
64 DOCDATA,
65 TERMLIST,
66 POSITION,
67 SPELLING,
68 SYNONYM,
69 MAX_
72 /// Postlist key second bytes when first byte is zero.
73 enum {
74 KEY_USER_METADATA = 0x00,
75 KEY_VALUE_STATS = 0x01,
76 KEY_VALUE_STATS_HI = 0x08,
77 KEY_VALUE_CHUNK = 0x09,
78 KEY_VALUE_CHUNK_HI = 0xe1, // (0xe1 for slots > 26)
79 /* 0xe2-0xe6 inclusive unused currently. */
80 /* 0xe7-0xee inclusive reserved for doc max wdf chunks. */
81 /* 0xef-0xf6 inclusive reserved for unique terms chunks. */
82 KEY_DOCLEN_CHUNK = 0xf7,
83 KEY_DOCLEN_CHUNK_HI = 0xfe,
84 KEY_POSTING_CHUNK = 0xff
87 #define KEY_DOCLEN_PREFIX "\0\xf7"
89 static_assert(((KEY_VALUE_CHUNK_HI - KEY_VALUE_CHUNK) & 0x07) == 0,
90 "No wasted values");
94 /// A block number in a honey Btree file.
95 typedef uint4 honey_block_t;
97 /// The revision number of a honey database.
98 typedef uint4 honey_revision_number_t;
100 /// How many entries there are in a table.
101 typedef unsigned long long honey_tablesize_t;
103 #endif // XAPIAN_INCLUDED_HONEY_DEFS_H