backends/flint/flint_btreebase.h

Go to the documentation of this file.
00001 /* flint_btreebase.h: Btree base file implementation
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002,2004,2007,2008 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00019  * USA
00020  */
00021 
00022 #ifndef OM_HGUARD_FLINT_BTREEBASE_H
00023 #define OM_HGUARD_FLINT_BTREEBASE_H
00024 
00025 #include <string>
00026 
00027 #include <xapian/visibility.h>
00028 
00029 #include "flint_types.h"
00030 #include "flint_btreeutil.h"
00031 
00032 class XAPIAN_VISIBILITY_DEFAULT FlintTable_base {
00033     public:
00035         FlintTable_base();
00036 
00038         FlintTable_base(const FlintTable_base &other);
00039 
00041         ~FlintTable_base();
00042 
00053         bool read(const std::string &name, char ch, std::string &err_msg);
00054 
00055         uint4 get_revision() const { return revision; }
00056         uint4 get_block_size() const { return block_size; }
00057         uint4 get_root() const { return root; }
00058         uint4 get_level() const { return level; }
00059         uint4 get_bit_map_size() const { return bit_map_size; }
00060         uint4 get_item_count() const { return item_count; }
00061         uint4 get_last_block() const { return last_block; }
00062         bool get_have_fakeroot() const { return have_fakeroot; }
00063         bool get_sequential() const { return sequential; }
00064 
00065         void set_revision(uint4 revision_) {
00066             revision = revision_;
00067         }
00068         void set_block_size(uint4 block_size_) {
00069             block_size = block_size_;
00070         }
00071         void set_root(uint4 root_) {
00072             root = root_;
00073         }
00074         void set_level(uint4 level_) {
00075             level = level_;
00076         }
00077         void set_item_count(uint4 item_count_) {
00078             item_count = item_count_;
00079         }
00080         void set_have_fakeroot(bool have_fakeroot_) {
00081             have_fakeroot = have_fakeroot_;
00082         }
00083         void set_sequential(bool sequential_) {
00084             sequential = sequential_;
00085         }
00086 
00088         void write_to_file(const std::string &filename);
00089 
00090         /* Methods dealing with the bitmap */
00094         bool block_free_at_start(uint4 n) const;
00095 
00096         void free_block(uint4 n);
00097 
00098         uint4 next_free_block();
00099 
00100         bool block_free_now(uint4 n);
00101 
00102         void calculate_last_block();
00103 
00104         /* Only used with fake root blocks */
00105         void clear_bit_map();
00106 
00107         void commit();
00108 
00109         /* Used by FlintTable::check() */
00110         bool is_empty() const;
00111 
00112         void swap(FlintTable_base &other);
00113 
00114     private:
00116         void operator=(const FlintTable_base &other);
00117 
00118         void extend_bit_map();
00119 
00121         bool do_unpack_uint(const char **start, const char *end,
00122                             uint4 *dest, std::string &err_msg,
00123                             const std::string &basename,
00124                             const char *varname);
00125 
00126         /* Decoded values from the base file follow */
00127         uint4 revision;
00128         uint4 block_size;
00129         uint4 root;
00130         uint4 level;
00131         uint4 bit_map_size;
00132         uint4 item_count;
00133         uint4 last_block;
00134         bool have_fakeroot;
00135         bool sequential;
00136 
00137         /* Data related to the bitmap */
00140         uint4 bit_map_low;
00141 
00144         byte *bit_map0;
00145 
00147         byte *bit_map;
00148 };
00149 
00150 #endif /* OM_HGUARD_FLINT_BTREEBASE_H */

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.