|
xapian-core
2.0.0
|
A postlist in a glass database. More...
#include <glass_postlist.h>
Inheritance diagram for GlassPostList:
Collaboration diagram for GlassPostList:Public Member Functions | |
| GlassPostList (Xapian::Internal::intrusive_ptr< const GlassDatabase > this_db_, std::string_view term, bool keep_reference) | |
| Default constructor. More... | |
| ~GlassPostList () | |
| Destructor. More... | |
| bool | open_nearby_postlist (std::string_view term_, bool need_read_pos, LeafPostList *&pl) const |
| Open another postlist from the same database. More... | |
| bool | jump_to (Xapian::docid desired_did) |
| Used for looking up doclens. More... | |
| Xapian::docid | get_docid () const |
| Returns the current docid. More... | |
| Xapian::termcount | get_wdf () const |
| Returns the Within Document Frequency of the term in the current document. More... | |
| PositionList * | read_position_list () |
| Get the list of positions of the term in the current document. More... | |
| PositionList * | open_position_list () const |
| Get the list of positions of the term in the current document. More... | |
| PostList * | next (double w_min) |
| Move to the next document. More... | |
| PostList * | skip_to (Xapian::docid desired_did, double w_min) |
| Skip to next document with docid >= docid. More... | |
| bool | at_end () const |
| Return true if and only if we're off the end of the list. More... | |
| Xapian::termcount | get_wdf_upper_bound () const |
| void | get_docid_range (Xapian::docid &first, Xapian::docid &last) const |
| Get the bounds on the range of docids this PostList can return. More... | |
| std::string | get_description () const |
| Get a description of the document. More... | |
Public Member Functions inherited from LeafPostList | |
| ~LeafPostList () | |
| Xapian::termcount | get_collfreq () const |
| Get the collection frequency of the term. More... | |
| void | set_termweight (const Xapian::Weight *weight_) |
| Set the weighting scheme to use during matching. More... | |
| double | resolve_lazy_termweight (Xapian::Weight *weight_, Xapian::Weight::Internal *stats, Xapian::termcount qlen, Xapian::termcount wqf, double factor, const Xapian::Database::Internal *shard) |
| double | get_weight (Xapian::termcount doclen, Xapian::termcount unique_terms, Xapian::termcount wdfdocmax) const |
| Return the weight contribution for the current position. More... | |
| double | recalc_maxweight () |
| Recalculate the upper bound on what get_weight() can return. More... | |
| Xapian::termcount | count_matching_subqs () const |
| Count the number of leaf subqueries which match at the current position. More... | |
| void | gather_position_lists (OrPositionList *orposlist) |
| Gather PositionList* objects for a subtree. More... | |
| const std::string & | get_term () const |
| Get the term name. More... | |
| void | set_term (std::string_view term_) |
| Set the term name. More... | |
Public Member Functions inherited from Xapian::Internal::PostList | |
| virtual | ~PostList () |
| We have virtual methods and want to be able to delete derived classes using a pointer to the base class, so we need a virtual destructor. More... | |
| Xapian::doccount | get_termfreq () const |
| Get an estimate of the number of documents this PostList will return. More... | |
| virtual PostList * | check (Xapian::docid did, double w_min, bool &valid) |
| Check if the specified docid occurs in this postlist. More... | |
| PostList * | next () |
| Advance the current position to the next document in the postlist. More... | |
| PostList * | skip_to (Xapian::docid did) |
| Skip forward to the specified docid. More... | |
Static Public Member Functions | |
| static void | read_freqs (const char **posptr, const char *end, Xapian::doccount *number_of_entries_ptr, Xapian::termcount *collection_freq_ptr) |
| Read the term frequency and collection frequency. More... | |
Private Member Functions | |
| GlassPostList (const GlassPostList &) | |
| Copying is not allowed. More... | |
| void | operator= (const GlassPostList &) |
| Assignment is not allowed. More... | |
| bool | next_in_chunk () |
| Move to the next item in the chunk, if possible. More... | |
| void | next_chunk () |
| Move to the next chunk. More... | |
| bool | current_chunk_contains (Xapian::docid desired_did) |
| Return true if the given document ID lies in the range covered by the current chunk. More... | |
| void | move_to_chunk_containing (Xapian::docid desired_did) |
| Move to chunk containing the specified document ID. More... | |
| bool | move_forward_in_chunk_to_at_least (Xapian::docid desired_did) |
| Scan forward in the current chunk for the specified document ID. More... | |
| GlassPostList (Xapian::Internal::intrusive_ptr< const GlassDatabase > this_db_, std::string_view term, GlassCursor *cursor_) | |
| void | init () |
Private Attributes | |
| Xapian::Internal::intrusive_ptr< const GlassDatabase > | this_db |
| The database we are searching. More... | |
| GlassRePositionList * | positionlist = NULL |
| The position list object for this posting list. More... | |
| bool | have_started |
| Whether we've started reading the list yet. More... | |
| bool | is_last_chunk |
| True if this is the last chunk. More... | |
| bool | is_at_end |
| Whether we've run off the end of the list yet. More... | |
| std::unique_ptr< GlassCursor > | cursor |
| Cursor pointing to current chunk of postlist. More... | |
| Xapian::docid | first_did_in_chunk |
| The first document id in this chunk. More... | |
| Xapian::docid | last_did_in_chunk |
| The last document id in this chunk. More... | |
| const char * | pos |
| Position of iteration through current chunk. More... | |
| const char * | end |
| Pointer to byte after end of current chunk. More... | |
| Xapian::docid | did |
| Document id we're currently at. More... | |
| Xapian::termcount | wdf |
| The wdf of the current document. More... | |
| Xapian::termcount | wdf_upper_bound |
| Upper bound on wdf for this postlist. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from LeafPostList | |
| LeafPostList (std::string_view term_) | |
| Only constructable as a base class for derived classes. More... | |
Protected Member Functions inherited from Xapian::Internal::PostList | |
| PostList () | |
| Only constructable as a base class for derived classes. More... | |
Protected Attributes inherited from LeafPostList | |
| const Xapian::Weight * | weight = nullptr |
| std::string | term |
| The term name for this postlist (empty for an alldocs postlist). More... | |
| Xapian::termcount | collfreq |
| The collection frequency of the term. More... | |
Protected Attributes inherited from Xapian::Internal::PostList | |
| Xapian::doccount | termfreq |
| Estimate of the number of documents this PostList will return. More... | |
A postlist in a glass database.
Definition at line 53 of file glass_postlist.h.
|
private |
Copying is not allowed.
Referenced by open_nearby_postlist().
|
private |
Definition at line 709 of file glass_postlist.cc.
References Xapian::Internal::intrusive_ptr< T >::get(), init(), and LOGCALL_CTOR.
| GlassPostList::GlassPostList | ( | Xapian::Internal::intrusive_ptr< const GlassDatabase > | this_db_, |
| std::string_view | term, | ||
| bool | keep_reference | ||
| ) |
Default constructor.
The format of a postlist is:
Split into chunks. Key for first chunk is the termname (encoded as length : name). Key for subsequent chunks is the same, followed by the document ID of the first document in the chunk (encoded as length of representation in first byte, and then docid).
A chunk (except for the first chunk) contains:
1) bool - true if this is the last chunk. 2) difference between final docid in chunk and first docid. 3) wdf for the first item. 4) increment in docid to next item, followed by wdf for the item. 5) (4) repeatedly.
The first chunk begins with the number of entries, the collection frequency, then the docid of the first document, then has the header of a standard chunk.
Definition at line 696 of file glass_postlist.cc.
References Xapian::Internal::intrusive_ptr< T >::get(), init(), and LOGCALL_CTOR.
| GlassPostList::~GlassPostList | ( | ) |
Destructor.
Definition at line 757 of file glass_postlist.cc.
References LOGCALL_DTOR, and positionlist.
|
inlinevirtual |
Return true if and only if we're off the end of the list.
Implements Xapian::Internal::PostList.
Definition at line 195 of file glass_postlist.h.
References is_at_end.
Referenced by GlassAllDocsPostList::get_wdf().
|
private |
Return true if the given document ID lies in the range covered by the current chunk.
This does not say whether the document ID is actually present. It will return false if the document ID is greater than the last document ID in the chunk, even if it is less than the first document ID in the next chunk: it is possible for no chunk to contain a particular document ID.
Definition at line 888 of file glass_postlist.cc.
References first_did_in_chunk, last_did_in_chunk, LOGCALL, and RETURN.
|
virtual |
Get a description of the document.
Implements Xapian::Internal::PostList.
Definition at line 1050 of file glass_postlist.cc.
References description_append(), Xapian::Internal::str(), LeafPostList::term, and Xapian::Internal::PostList::termfreq.
|
inlinevirtual |
Returns the current docid.
Implements Xapian::Internal::PostList.
Definition at line 173 of file glass_postlist.h.
References Assert, did, and have_started.
|
virtual |
Get the bounds on the range of docids this PostList can return.
| [out] | first | Set to a lower bound on the docids that can be returned, or not changed if there's no known lower bound (other than 1). |
| [out] | last | Set to an upper bound on the docids that can be returned, or not changed if there's no known upper bound (other than the highest used docid). |
The default implementation (PostList::get_docid_range()) does nothing, which is suitable when there's no known lower or upper bound.
Reimplemented from Xapian::Internal::PostList.
Definition at line 1037 of file glass_postlist.cc.
References first_did_in_chunk, is_last_chunk, last_did_in_chunk, and pos.
|
inlinevirtual |
Returns the Within Document Frequency of the term in the current document.
Reimplemented from Xapian::Internal::PostList.
Definition at line 178 of file glass_postlist.h.
References Assert, have_started, and wdf.
|
virtual |
Implements LeafPostList.
Definition at line 1379 of file glass_postlist.cc.
References Assert, LeafPostList::term, and wdf_upper_bound.
|
private |
Definition at line 723 of file glass_postlist.cc.
References LeafPostList::collfreq, cursor, did, end, first_did_in_chunk, is_at_end, is_last_chunk, last_did_in_chunk, LOGLINE, GlassPostListTable::make_key(), pos, read_start_of_chunk(), read_start_of_first_chunk(), read_wdf(), LeafPostList::term, Xapian::Internal::PostList::termfreq, wdf, and wdf_upper_bound.
Referenced by GlassPostList().
| bool GlassPostList::jump_to | ( | Xapian::docid | desired_did | ) |
Used for looking up doclens.
Definition at line 1008 of file glass_postlist.cc.
References current_chunk_contains(), did, have_started, is_at_end, LOGCALL, move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), pos, and RETURN.
|
private |
Scan forward in the current chunk for the specified document ID.
This is particularly efficient if the desired document ID is greater than the last in the chunk - it then skips straight to the end.
Definition at line 947 of file glass_postlist.cc.
References Assert, did, end, last_did_in_chunk, LOGCALL, pos, read_did_increase(), read_wdf(), RETURN, and wdf.
|
private |
Move to chunk containing the specified document ID.
This moves to the chunk whose starting document ID is <= desired_did, but such that the next chunk's starting document ID is > desired_did.
It is thus possible that current_chunk_contains(desired_did) will return false after this call, since the document ID might lie after the end of this chunk, but before the start of the next chunk.
Definition at line 899 of file glass_postlist.cc.
References Assert, check_tname_in_key_lite(), cursor, did, end, first_did_in_chunk, is_at_end, is_last_chunk, last_did_in_chunk, LOGCALL_VOID, GlassPostListTable::make_key(), next_chunk(), pos, read_start_of_chunk(), read_start_of_first_chunk(), read_wdf(), report_read_error(), LeafPostList::term, Xapian::Internal::PostList::termfreq, unpack_uint_preserving_sort(), and wdf.
|
virtual |
Move to the next document.
Implements Xapian::Internal::PostList.
Definition at line 867 of file glass_postlist.cc.
References did, have_started, is_at_end, LOGCALL, LOGLINE, next_chunk(), next_in_chunk(), RETURN, and wdf.
|
private |
Move to the next chunk.
If there are no more chunks in this postlist, this will set is_at_end to true.
Definition at line 800 of file glass_postlist.cc.
References check_tname_in_key_lite(), cursor, did, end, first_did_in_chunk, is_at_end, is_last_chunk, last_did_in_chunk, LOGCALL_VOID, pos, read_start_of_chunk(), read_wdf(), report_read_error(), Xapian::Internal::str(), LeafPostList::term, unpack_uint_preserving_sort(), and wdf.
Referenced by move_to_chunk_containing(), and next().
|
private |
Move to the next item in the chunk, if possible.
If already at the end of the chunk, returns false.
Definition at line 783 of file glass_postlist.cc.
References Assert, did, end, last_did_in_chunk, LOGCALL, pos, read_did_increase(), read_wdf(), RETURN, and wdf.
Referenced by next().
|
virtual |
Open another postlist from the same database.
| term_ | The term to open a postlist for (must not be an empty string). If term_ is near to this postlist's term, then this can be a lot more efficient (and if it isn't very near, there's not much of a penalty). Using this method can make a wildcard expansion much more memory efficient. | |
| need_read_pos | Does the postlist need to support read_position_list()? Note that open_position_list() may still be called even if need_read_pos is false. | |
| [out] | pl | If true is returned, set to a new LeafPostList object (or may be set to NULL if the term doesn't index any documents). The caller takes ownership of the returned object. |
Reimplemented from LeafPostList.
Definition at line 764 of file glass_postlist.cc.
References cursor, Xapian::Internal::PostList::get_termfreq(), GlassPostList(), GlassTable::is_writable(), LOGCALL, GlassDatabase::postlist_table, RETURN, and this_db.
|
virtual |
Get the list of positions of the term in the current document.
Reimplemented from Xapian::Internal::PostList.
Definition at line 859 of file glass_postlist.cc.
References Assert, did, LOGCALL, GlassDatabase::open_position_list(), RETURN, LeafPostList::term, and this_db.
|
private |
Assignment is not allowed.
|
static |
Read the term frequency and collection frequency.
Read the number of entries in the posting list.
This must only be called when *posptr is pointing to the start of the first chunk of the posting list.
Definition at line 666 of file glass_postlist.cc.
References report_read_error(), and unpack_uint().
Referenced by GlassPostListTable::get_freqs(), read_start_of_first_chunk(), and GlassAllTermsList::read_termfreq().
|
virtual |
Get the list of positions of the term in the current document.
Reimplemented from Xapian::Internal::PostList.
Definition at line 845 of file glass_postlist.cc.
References Assert, did, LOGCALL, GlassDatabase::position_table, positionlist, rare, GlassDatabase::read_position_list(), RETURN, LeafPostList::term, and this_db.
|
virtual |
Skip to next document with docid >= docid.
Implements Xapian::Internal::PostList.
Definition at line 973 of file glass_postlist.cc.
References Assert, current_chunk_contains(), did, have_started, is_at_end, LOGCALL, LOGLINE, move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), RETURN, and wdf.
|
private |
Cursor pointing to current chunk of postlist.
Definition at line 73 of file glass_postlist.h.
Referenced by init(), move_to_chunk_containing(), next_chunk(), and open_nearby_postlist().
|
private |
Document id we're currently at.
Definition at line 88 of file glass_postlist.h.
Referenced by get_docid(), init(), jump_to(), move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next(), next_chunk(), next_in_chunk(), open_position_list(), read_position_list(), and skip_to().
|
private |
Pointer to byte after end of current chunk.
Definition at line 85 of file glass_postlist.h.
Referenced by init(), move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next_chunk(), and next_in_chunk().
|
private |
The first document id in this chunk.
Definition at line 76 of file glass_postlist.h.
Referenced by current_chunk_contains(), get_docid_range(), init(), move_to_chunk_containing(), and next_chunk().
|
private |
Whether we've started reading the list yet.
Definition at line 64 of file glass_postlist.h.
Referenced by get_docid(), get_wdf(), jump_to(), next(), and skip_to().
|
private |
Whether we've run off the end of the list yet.
Definition at line 70 of file glass_postlist.h.
Referenced by at_end(), init(), jump_to(), move_to_chunk_containing(), next(), next_chunk(), and skip_to().
|
private |
True if this is the last chunk.
Definition at line 67 of file glass_postlist.h.
Referenced by get_docid_range(), init(), move_to_chunk_containing(), and next_chunk().
|
private |
The last document id in this chunk.
Definition at line 79 of file glass_postlist.h.
Referenced by current_chunk_contains(), get_docid_range(), init(), move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next_chunk(), and next_in_chunk().
|
private |
Position of iteration through current chunk.
Definition at line 82 of file glass_postlist.h.
Referenced by get_docid_range(), init(), jump_to(), move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next_chunk(), and next_in_chunk().
|
private |
The position list object for this posting list.
Definition at line 61 of file glass_postlist.h.
Referenced by read_position_list(), and ~GlassPostList().
|
private |
The database we are searching.
This pointer is held so that the database doesn't get deleted before us, and also to give us access to the position_table.
Definition at line 58 of file glass_postlist.h.
Referenced by open_nearby_postlist(), open_position_list(), and read_position_list().
|
private |
The wdf of the current document.
Definition at line 91 of file glass_postlist.h.
Referenced by get_wdf(), init(), move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next(), next_chunk(), next_in_chunk(), and skip_to().
|
private |
Upper bound on wdf for this postlist.
Definition at line 94 of file glass_postlist.h.
Referenced by get_wdf_upper_bound(), and init().