xapian-core
1.4.26
|
#include <glass_postlist.h>
Public Member Functions | |
GlassPostListTable (const string &path_, bool readonly_) | |
Create a new table object. More... | |
GlassPostListTable (int fd, off_t offset_, bool readonly_) | |
void | open (int flags_, const RootInfo &root_info, glass_revision_number_t rev) |
void | merge_changes (const string &term, const Inverter::PostingChanges &changes) |
Merge changes for a term. More... | |
void | merge_doclen_changes (const map< Xapian::docid, Xapian::termcount > &doclens) |
Merge document length changes. More... | |
Xapian::docid | get_chunk (const string &tname, Xapian::docid did, bool adding, Glass::PostlistChunkReader **from, Glass::PostlistChunkWriter **to) |
bool | term_exists (const string &term) const |
void | get_freqs (const std::string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr, Xapian::termcount *wdfub_ptr=NULL) const |
Returns frequencies for a term. More... | |
Xapian::termcount | get_doclength (Xapian::docid did, Xapian::Internal::intrusive_ptr< const GlassDatabase > db) const |
Returns the length of document did. More... | |
bool | document_exists (Xapian::docid did, Xapian::Internal::intrusive_ptr< const GlassDatabase > db) const |
Check if document did exists. More... | |
void | get_used_docid_range (Xapian::docid &first, Xapian::docid &last) const |
Public Member Functions inherited from GlassTable | |
GlassTable (const char *tablename_, const std::string &path_, bool readonly_, bool lazy=false) | |
Create a new Btree object. More... | |
GlassTable (const char *tablename_, int fd, off_t offset_, bool readonly_, bool lazy=false) | |
~GlassTable () | |
Close the Btree. More... | |
void | close (bool permanent=false) |
Close the Btree. More... | |
bool | readahead_key (const string &key) const |
bool | exists () const |
Determine whether the btree exists on disk. More... | |
void | open (int flags_, const RootInfo &root_info, glass_revision_number_t rev) |
Open the btree. More... | |
bool | is_open () const |
Return true if this table is open. More... | |
bool | is_writable () const |
Return true if this table is writable. More... | |
void | flush_db () |
Flush any outstanding changes to the DB file of the table. More... | |
void | commit (glass_revision_number_t revision, RootInfo *root_info) |
Commit any outstanding changes to the table. More... | |
bool | sync () |
void | cancel (const RootInfo &root_info, glass_revision_number_t rev) |
Cancel any outstanding changes. More... | |
bool | get_exact_entry (const std::string &key, std::string &tag) const |
Read an entry from the table, if and only if it is exactly that being asked for. More... | |
bool | key_exists (const std::string &key) const |
Check if a key exists in the Btree. More... | |
bool | read_tag (Glass::Cursor *C_, std::string *tag, bool keep_compressed) const |
Read the tag value for the key pointed to by cursor C_. More... | |
void | add (const std::string &key, const std::string &tag, bool already_compressed=false) |
Add a key/tag pair to the table, replacing any existing pair with the same key. More... | |
bool | del (const std::string &key) |
Delete an entry from the table. More... | |
int | get_flags () const |
void | create_and_open (int flags_, const RootInfo &root_info) |
Create a new empty btree structure on disk and open it at the initial revision. More... | |
void | set_full_compaction (bool parity) |
glass_revision_number_t | get_open_revision_number () const |
Get the revision number at which this table is currently open. More... | |
glass_tablesize_t | get_entry_count () const |
Return a count of the number of entries in the table. More... | |
bool | empty () const |
Return true if there are no entries in the table. More... | |
GlassCursor * | cursor_get () const |
Get a cursor for reading from the table. More... | |
bool | is_modified () const |
Determine whether the object contains uncommitted modifications. More... | |
void | set_max_item_size (size_t block_capacity) |
Set the maximum item size given the block capacity. More... | |
void | set_changes (GlassChanges *changes) |
Set the GlassChanges object to write changed blocks to. More... | |
string | get_path () const |
Static Public Member Functions | |
static string | make_key (const string &term, Xapian::docid did) |
Compose a key from a termname and docid. More... | |
static string | make_key (const string &term) |
Compose a key from a termname. More... | |
Static Public Member Functions inherited from GlassTable | |
static void | throw_database_closed () |
Throw an exception indicating that the database is closed. More... | |
Private Attributes | |
AutoPtr< GlassPostList > | doclen_pl |
PostList for looking up document lengths. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from GlassTable | |
bool | find (Glass::Cursor *) const |
find(C_) searches for the key of B->kt in the B-tree. More... | |
int | delete_kt () |
void | read_block (uint4 n, uint8_t *p) const |
read_block(n, p) reads block n of the DB file to address p. More... | |
void | write_block (uint4 n, const uint8_t *p, bool appending=false) const |
write_block(n, p, appending) writes block n in the DB file from address p. More... | |
void | set_overwritten () const |
void | block_to_cursor (Glass::Cursor *C_, int j, uint4 n) const |
void | alter () |
Btree::alter(); is called when the B-tree is to be altered. More... | |
void | compact (uint8_t *p) |
compact(p) compact the block at p by shuffling all the items up to the end. More... | |
void | enter_key_above_leaf (Glass::LeafItem previtem, Glass::LeafItem newitem) |
enter_key_above_leaf(previtem, newitem) is called after a leaf block split. More... | |
void | enter_key_above_branch (int j, Glass::BItem newitem) |
enter_key_above_branch(j, newkey) is called after a branch block split. More... | |
int | mid_point (uint8_t *p) const |
mid_point(p) finds the directory entry in c that determines the approximate mid point of the data in the block at p. More... | |
void | add_item_to_leaf (uint8_t *p, Glass::LeafItem kt, int c) |
add_item_to_leaf(p, kt_, c) adds item kt_ to the leaf block at p. More... | |
void | add_item_to_branch (uint8_t *p, Glass::BItem kt, int c) |
add_item_to_branch(p, kt_, c) adds item kt_ to the branch block at p. More... | |
void | add_leaf_item (Glass::LeafItem kt) |
GlassTable::add_leaf_item(kt_) adds item kt_ to the leaf block. More... | |
void | add_branch_item (Glass::BItem kt, int j) |
GlassTable::add_item(kt_, j) adds item kt_ to the block at cursor level C[j]. More... | |
void | delete_leaf_item (bool repeatedly) |
GlassTable::delete_leaf_item(repeatedly) is (almost) the converse of add_leaf_item. More... | |
void | delete_branch_item (int j) |
GlassTable::delete_branch_item(j, repeatedly) is (almost) the converse of add_branch_item. More... | |
int | add_kt (bool found) |
add_kt(found) adds the item (key-tag pair) at B->kt into the B-tree, using cursor C. More... | |
void | read_root () |
void | split_root (uint4 split_n) |
Btree needs to gain a new level to insert more items: so split root block and construct a new one. More... | |
void | form_key (const std::string &key) const |
bool | single_file () const |
bool | prev (Glass::Cursor *C_, int j) const |
bool | next (Glass::Cursor *C_, int j) const |
bool | prev_default (Glass::Cursor *C_, int j) const |
bool | next_default (Glass::Cursor *C_, int j) const |
bool | prev_for_sequential (Glass::Cursor *C_, int dummy) const |
bool | next_for_sequential (Glass::Cursor *C_, int dummy) const |
Static Protected Member Functions inherited from GlassTable | |
static int | find_in_leaf (const uint8_t *p, Glass::LeafItem item, int c, bool &exact) |
find_in_leaf(p, key, c, exact) searches for the key in the leaf block at p. More... | |
static int | find_in_branch (const uint8_t *p, Glass::LeafItem item, int c) |
static int | find_in_branch (const uint8_t *p, Glass::BItem item, int c) |
static uint4 | block_given_by (const uint8_t *p, int c) |
block_given_by(p, c) finds the item at block address p, directory offset c, and returns its tag value as an integer. More... | |
Protected Attributes inherited from GlassTable | |
const char * | tablename |
The name of the table (used when writing changesets). More... | |
glass_revision_number_t | revision_number |
revision number of the opened B-tree. More... | |
glass_tablesize_t | item_count |
keeps a count of the number of items in the B-tree. More... | |
unsigned int | block_size |
block size of the B tree in bytes More... | |
int | flags |
Flags like DB_NO_SYNC and DB_DANGEROUS. More... | |
bool | faked_root_block |
true if the root block is faked (not written to disk). More... | |
bool | sequential |
true iff the data has been written in a single write in sequential order. More... | |
int | handle |
File descriptor of the table. More... | |
int | level |
number of levels, counting from 0 More... | |
uint4 | root |
the root block of the B-tree More... | |
Glass::LeafItem_wr | kt |
buffer of size block_size for making up key-tag items More... | |
uint8_t * | buffer |
buffer of size block_size for reforming blocks More... | |
GlassFreeList | free_list |
List of free blocks. More... | |
std::string | name |
The path name of the B tree. More... | |
int | seq_count |
count of the number of successive instances of purely sequential addition, starting at SEQ_START_POINT (neg) and going up to zero. More... | |
uint4 | changed_n |
the last block to be changed by an addition More... | |
int | changed_c |
directory offset corresponding to last block to be changed by an addition More... | |
size_t | max_item_size |
maximum size of an item (key-tag pair) More... | |
bool | Btree_modified |
Set to true the first time the B-tree is modified. More... | |
bool | full_compaction |
set to true when full compaction is to be achieved More... | |
bool | writable |
Set to true when the database is opened to write. More... | |
bool | cursor_created_since_last_modification |
Flag for tracking when cursors need to rebuild. More... | |
unsigned long | cursor_version |
Version count for tracking when cursors need to rebuild. More... | |
GlassChanges * | changes_obj |
The GlassChanges object to write block changes to. More... | |
Glass::Cursor | C [GLASS_BTREE_CURSOR_LEVELS] |
uint8_t * | split_p |
Buffer used when splitting a block. More... | |
uint4 | compress_min |
Minimum size tag to try compressing (0 for no compression). More... | |
CompressionStream | comp_stream |
bool | lazy |
If true, don't create the table until it's needed. More... | |
uint4 | last_readahead |
Last block readahead_key() preread. More... | |
off_t | offset |
offset to start of table in file. More... | |
Definition at line 224 of file glass_postlist.h.
|
inline |
Create a new table object.
This does not create the table on disk - the create() method must be called before the table is created on disk
This also does not open the table - the open() method must be called before use is made of the table.
path_ | - Path at which the table is stored. |
readonly_ | - whether to open the table for read only access. |
Definition at line 241 of file glass_postlist.h.
|
inline |
Definition at line 246 of file glass_postlist.h.
bool GlassPostListTable::document_exists | ( | Xapian::docid | did, |
Xapian::Internal::intrusive_ptr< const GlassDatabase > | db | ||
) | const |
Check if document did exists.
Definition at line 210 of file glass_postlist.cc.
References doclen_pl.
Referenced by GlassWritableDatabase::replace_document().
Xapian::docid GlassPostListTable::get_chunk | ( | const string & | tname, |
Xapian::docid | did, | ||
bool | adding, | ||
Glass::PostlistChunkReader ** | from, | ||
Glass::PostlistChunkWriter ** | to | ||
) |
Definition at line 1052 of file glass_postlist.cc.
References Assert, check_tname_in_key(), GlassPostList::cursor, GlassPostList::end, GlassPostList::first_did_in_chunk, GlassPostList::is_last_chunk, GlassPostList::last_did_in_chunk, LOGCALL, LOGVALUE, make_key(), GlassPostList::pos, read_start_of_chunk(), read_start_of_first_chunk(), report_read_error(), RETURN, and unpack_uint_preserving_sort().
Xapian::termcount GlassPostListTable::get_doclength | ( | Xapian::docid | did, |
Xapian::Internal::intrusive_ptr< const GlassDatabase > | db | ||
) | const |
Returns the length of document did.
Definition at line 197 of file glass_postlist.cc.
References doclen_pl, and Xapian::Internal::str().
Referenced by GlassDatabase::get_doclength().
void GlassPostListTable::get_freqs | ( | const std::string & | term, |
Xapian::doccount * | termfreq_ptr, | ||
Xapian::termcount * | collfreq_ptr, | ||
Xapian::termcount * | wdfub_ptr = NULL |
||
) | const |
Returns frequencies for a term.
term | The term to get frequencies for |
termfreq_ptr | Point to return number of docs indexed by term (or NULL not to return) |
collfreq_ptr | Point to return number of occurrences of term in the database (or NULL not to return) |
wdfub_ptr | Point to return an upper bound on the wdf of term in the database (or NULL not to return) |
Definition at line 153 of file glass_postlist.cc.
References GlassTable::get_exact_entry(), make_key(), GlassPostList::read_number_of_entries(), read_start_of_chunk(), report_read_error(), and unpack_uint().
Referenced by GlassDatabase::get_freqs(), and GlassDatabase::get_wdf_upper_bound().
void GlassPostListTable::get_used_docid_range | ( | Xapian::docid & | first, |
Xapian::docid & | last | ||
) | const |
Definition at line 1318 of file glass_postlist.cc.
References Assert, check_tname_in_key_lite(), dummy, GLASS_MAX_DOCID, LOGCALL, pack_glass_postlist_key(), read_start_of_chunk(), read_start_of_first_chunk(), report_read_error(), and unpack_uint_preserving_sort().
Referenced by GlassDatabase::get_used_docid_range().
|
inlinestatic |
Compose a key from a termname and docid.
Definition at line 271 of file glass_postlist.h.
References pack_glass_postlist_key().
Referenced by Glass::PostlistChunkWriter::append(), Glass::PostlistChunkWriter::flush(), get_freqs(), GlassPostList::init(), GlassPostList::move_to_chunk_containing(), and GlassDatabase::readahead_for_query().
|
inlinestatic |
Compose a key from a termname.
Definition at line 276 of file glass_postlist.h.
References pack_glass_postlist_key().
void GlassPostListTable::merge_changes | ( | const string & | term, |
const Inverter::PostingChanges & | changes | ||
) |
Merge changes for a term.
Definition at line 1205 of file glass_postlist.cc.
References Glass::PostlistChunkWriter::append(), Assert, check_tname_in_key_lite(), GlassCursor::current_key, GlassPostList::cursor, MutableGlassCursor::del(), GlassPostList::did, GlassPostList::end, GlassCursor::find_entry(), Glass::PostlistChunkWriter::flush(), Inverter::PostingChanges::get_cfdelta(), Glass::PostlistChunkReader::get_docid(), Inverter::PostingChanges::get_tfdelta(), Glass::PostlistChunkReader::get_wdf(), Glass::PostlistChunkReader::is_at_end(), LOGLINE, make_key(), make_start_of_chunk(), make_start_of_first_chunk(), Glass::PostlistChunkReader::next(), GlassPostList::next_chunk(), Inverter::PostingChanges::pl_changes, GlassPostList::pos, read_start_of_chunk(), and read_start_of_first_chunk().
Referenced by Inverter::flush_all_post_lists(), Inverter::flush_post_list(), and Inverter::flush_post_lists().
void GlassPostListTable::merge_doclen_changes | ( | const map< Xapian::docid, Xapian::termcount > & | doclens | ) |
Merge document length changes.
Definition at line 1137 of file glass_postlist.cc.
References Glass::PostlistChunkWriter::append(), Assert, GlassPostList::did, Glass::PostlistChunkWriter::flush(), Glass::PostlistChunkReader::get_docid(), Glass::PostlistChunkReader::get_wdf(), Glass::PostlistChunkReader::is_at_end(), LOGCALL_VOID, LOGLINE, LOGVALUE, make_key(), make_start_of_chunk(), make_start_of_first_chunk(), and Glass::PostlistChunkReader::next().
Referenced by Inverter::flush_doclengths().
|
inline |
Definition at line 251 of file glass_postlist.h.
References GlassTable::open().
Referenced by GlassDatabase::modifications_failed(), and GlassDatabase::open_tables().
|
inline |
Definition at line 280 of file glass_postlist.h.
References make_key().
Referenced by GlassDatabase::term_exists().
|
mutableprivate |
PostList for looking up document lengths.
Definition at line 226 of file glass_postlist.h.
Referenced by document_exists(), and get_doclength().