00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef OM_HGUARD_BTREE_BASE_H
00023 #define OM_HGUARD_BTREE_BASE_H
00024
00025 #include <xapian/visibility.h>
00026
00027 #include "quartz_types.h"
00028 #include "btree_util.h"
00029
00030 class XAPIAN_VISIBILITY_DEFAULT Btree_base {
00031 public:
00034 Btree_base();
00035
00041 Btree_base(const std::string &name_, char ch);
00042
00044 Btree_base(const Btree_base &other);
00045
00047 ~Btree_base();
00048
00059 bool read(const std::string &name, char ch, std::string &err_msg);
00060
00061 uint4 get_revision() const { return revision; }
00062 uint4 get_block_size() const { return block_size; }
00063 uint4 get_root() const { return root; }
00064 uint4 get_level() const { return level; }
00065 uint4 get_bit_map_size() const { return bit_map_size; }
00066 uint4 get_item_count() const { return item_count; }
00067 uint4 get_last_block() const { return last_block; }
00068 bool get_have_fakeroot() const { return have_fakeroot; }
00069 bool get_sequential() const { return sequential; }
00070
00071 void set_revision(uint4 revision_) {
00072 revision = revision_;
00073 }
00074 void set_block_size(uint4 block_size_) {
00075 block_size = block_size_;
00076 }
00077 void set_root(uint4 root_) {
00078 root = root_;
00079 }
00080 void set_level(uint4 level_) {
00081 level = level_;
00082 }
00083 void set_item_count(uint4 item_count_) {
00084 item_count = item_count_;
00085 }
00086 void set_have_fakeroot(bool have_fakeroot_) {
00087 have_fakeroot = have_fakeroot_;
00088 }
00089 void set_sequential(bool sequential_) {
00090 sequential = sequential_;
00091 }
00092
00094 void write_to_file(const std::string &filename);
00095
00096
00100 bool block_free_at_start(uint4 n) const;
00101
00102 void free_block(uint4 n);
00103
00104 uint4 next_free_block();
00105
00106 bool block_free_now(uint4 n);
00107
00108 void calculate_last_block();
00109
00110
00111 void clear_bit_map();
00112
00113 void commit();
00114
00115
00116 bool is_empty() const;
00117
00118 void swap(Btree_base &other);
00119
00120 private:
00122 void operator=(const Btree_base &other);
00123
00124 void extend_bit_map();
00125
00127 bool do_unpack_uint(const char **start, const char *end,
00128 uint4 *dest, std::string &err_msg,
00129 const std::string &basename,
00130 const char *varname);
00131
00132
00133 uint4 revision;
00134 uint4 block_size;
00135 uint4 root;
00136 uint4 level;
00137 uint4 bit_map_size;
00138 uint4 item_count;
00139 uint4 last_block;
00140 bool have_fakeroot;
00141 bool sequential;
00142
00143
00146 uint4 bit_map_low;
00147
00150 byte *bit_map0;
00151
00153 byte *bit_map;
00154 };
00155
00156 #endif