QuartzPostList Class Reference

A postlist in a quartz database. More...

#include <quartz_postlist.h>

Inheritance diagram for QuartzPostList:

Inheritance graph
[legend]
Collaboration diagram for QuartzPostList:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 QuartzPostList (Xapian::Internal::RefCntPtr< const Xapian::Database::Internal > this_db_, const Btree *table_, const Btree *positiontable_, const string &tname)
 Default constructor.
 ~QuartzPostList ()
 Destructor.
Xapian::doccount get_termfreq () const
 Returns number of docs indexed by this term.
Xapian::docid get_docid () const
 Returns the current docid.
Xapian::doclength get_doclength () const
 Returns the length of current document.
Xapian::termcount get_wdf () const
 Returns the Within Document Frequency of the term in the current document.
PositionListread_position_list ()
 Get the list of positions of the term in the current document.
PositionListopen_position_list () const
 Get the list of positions of the term in the current document.
PostListnext (Xapian::weight w_min)
 Move to the next document.
PostListskip_to (Xapian::docid desired_did, Xapian::weight w_min)
 Skip to next document with docid >= docid.
bool at_end () const
 Return true if and only if we're off the end of the list.
std::string get_description () const
 Get a description of the document.

Static Public Member Functions

static void read_number_of_entries (const char **posptr, const char *end, Xapian::termcount *number_of_entries_ptr, Xapian::termcount *collection_freq_ptr)
 Read the number of entries and the collection frequency.

Private Member Functions

 QuartzPostList (const QuartzPostList &)
 Copying is not allowed.
void operator= (const QuartzPostList &)
 Assignment is not allowed.
bool next_in_chunk ()
 Move to the next item in the chunk, if possible.
void next_chunk ()
 Move to the next chunk.
bool current_chunk_contains (Xapian::docid desired_did)
 Return true if the given document ID lies in the range covered by the current chunk.
void move_to_chunk_containing (Xapian::docid desired_did)
 Move to chunk containing the specified document ID.
bool move_forward_in_chunk_to_at_least (Xapian::docid desired_did)
 Scan forward in the current chunk for the specified document ID.

Private Attributes

Xapian::Internal::RefCntPtr<
const Xapian::Database::Internal
this_db
 The database we are searching.
const Btreetable
 The table containing the postlist.
const Btreepositiontable
 The table containing positionlists.
string tname
 The termname for this postlist.
AutoPtr< Bcursorcursor
 Cursor pointing to current chunk of postlist.
bool is_last_chunk
 True if this is the last chunk.
Xapian::docid first_did_in_chunk
 The first document id in this chunk.
Xapian::docid last_did_in_chunk
 The last document id in this chunk.
const char * pos
 Position of iteration through current chunk.
const char * end
 Pointer to byte after end of current chunk.
Xapian::docid did
 Document id we're currently at.
quartz_doclen_t doclength
 The (absolute) length of the current document.
Xapian::termcount wdf
 The wdf of the current document.
bool is_at_end
 Whether we've run off the end of the list yet.
bool have_started
 Whether we've started reading the list yet.
Xapian::doccount number_of_entries
 The number of entries in the posting list.
QuartzPositionList positionlist
 The position list object for this posting list.

Detailed Description

A postlist in a quartz database.

Definition at line 89 of file quartz_postlist.h.


Constructor & Destructor Documentation

QuartzPostList::QuartzPostList ( const QuartzPostList  )  [private]

Copying is not allowed.

QuartzPostList::QuartzPostList ( Xapian::Internal::RefCntPtr< const Xapian::Database::Internal this_db_,
const Btree table_,
const Btree positiontable_,
const string &  tname_ 
)

Default constructor.

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, then doclength of first item. 4) increment in docid to next item, followed by wdf and doclength of item 5) (4) repeatedly.

The first chunk begins with the number of entries, then the docid of the first document, then has the header of a standard chunk.

Definition at line 668 of file quartz_postlist.cc.

References cursor, DEBUGCALL, did, doclength, end, first_did_in_chunk, Xapian::Internal::RefCntPtr< T >::get(), is_at_end, is_last_chunk, last_did_in_chunk, make_key(), number_of_entries, pos, read_start_of_chunk(), read_start_of_first_chunk(), read_wdf_and_length(), tname, and wdf.

QuartzPostList::~QuartzPostList (  ) 

Destructor.

Definition at line 706 of file quartz_postlist.cc.

References DEBUGCALL.


Member Function Documentation

void QuartzPostList::operator= ( const QuartzPostList  )  [private]

Assignment is not allowed.

bool QuartzPostList::next_in_chunk (  )  [private]

Move to the next item in the chunk, if possible.

If already at the end of the chunk, returns false.

Definition at line 712 of file quartz_postlist.cc.

References Assert, DEBUGCALL, did, doclength, end, last_did_in_chunk, pos, read_did_increase(), read_wdf_and_length(), RETURN, and wdf.

Referenced by move_forward_in_chunk_to_at_least(), and next().

void QuartzPostList::next_chunk (  )  [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 729 of file quartz_postlist.cc.

References check_tname_in_key_lite(), cursor, DEBUGCALL, did, doclength, end, first_did_in_chunk, is_at_end, is_last_chunk, last_did_in_chunk, om_tostring(), pos, read_start_of_chunk(), read_wdf_and_length(), report_read_error(), tname, unpack_uint_preserving_sort(), and wdf.

Referenced by move_to_chunk_containing(), and next().

bool QuartzPostList::current_chunk_contains ( Xapian::docid  desired_did  )  [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 816 of file quartz_postlist.cc.

References DEBUGCALL, first_did_in_chunk, last_did_in_chunk, and RETURN.

Referenced by skip_to().

void QuartzPostList::move_to_chunk_containing ( Xapian::docid  desired_did  )  [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 827 of file quartz_postlist.cc.

References Assert, check_tname_in_key_lite(), cursor, DEBUGCALL, did, doclength, end, first_did_in_chunk, is_at_end, is_last_chunk, last_did_in_chunk, make_key(), next_chunk(), number_of_entries, pos, read_start_of_chunk(), read_start_of_first_chunk(), read_wdf_and_length(), report_read_error(), tname, unpack_uint_preserving_sort(), and wdf.

Referenced by skip_to().

bool QuartzPostList::move_forward_in_chunk_to_at_least ( Xapian::docid  desired_did  )  [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.

Returns:
true if we moved to a valid document, false if we reached the end of the chunk.

Definition at line 878 of file quartz_postlist.cc.

References DEBUGCALL, did, end, last_did_in_chunk, next_in_chunk(), pos, and RETURN.

Referenced by skip_to().

Xapian::doccount QuartzPostList::get_termfreq (  )  const [inline, virtual]

Returns number of docs indexed by this term.

This is the length of the postlist.

Implements LeafPostList.

Definition at line 209 of file quartz_postlist.h.

Xapian::docid QuartzPostList::get_docid (  )  const [inline, virtual]

Returns the current docid.

Implements Xapian::PostingIterator::Internal.

Definition at line 212 of file quartz_postlist.h.

References Assert.

Xapian::doclength QuartzPostList::get_doclength (  )  const [inline, virtual]

Returns the length of current document.

Implements Xapian::PostingIterator::Internal.

Definition at line 215 of file quartz_postlist.h.

References Assert.

Xapian::termcount QuartzPostList::get_wdf (  )  const [inline, virtual]

Returns the Within Document Frequency of the term in the current document.

Reimplemented from Xapian::PostingIterator::Internal.

Definition at line 223 of file quartz_postlist.h.

References Assert.

PositionList * QuartzPostList::read_position_list (  )  [virtual]

Get the list of positions of the term in the current document.

Reimplemented from Xapian::PostingIterator::Internal.

Definition at line 775 of file quartz_postlist.cc.

References DEBUGCALL, did, positionlist, positiontable, QuartzPositionList::read_data(), RETURN, and tname.

PositionList * QuartzPostList::open_position_list (  )  const [virtual]

Get the list of positions of the term in the current document.

Reimplemented from Xapian::PostingIterator::Internal.

Definition at line 785 of file quartz_postlist.cc.

References DEBUGCALL, did, positiontable, AutoPtr< _Tp >::release(), RETURN, and tname.

PostList * QuartzPostList::next ( Xapian::weight  w_min  )  [virtual]

Move to the next document.

Implements Xapian::PostingIterator::Internal.

Definition at line 796 of file quartz_postlist.cc.

References DEBUGCALL, DEBUGLINE, did, doclength, have_started, is_at_end, next_chunk(), next_in_chunk(), om_tostring(), RETURN, and wdf.

PostList * QuartzPostList::skip_to ( Xapian::docid  desired_did,
Xapian::weight  w_min 
) [virtual]

Skip to next document with docid >= docid.

Implements Xapian::PostingIterator::Internal.

Definition at line 896 of file quartz_postlist.cc.

References Assert, current_chunk_contains(), DEBUGCALL, DEBUGLINE, did, doclength, have_started, is_at_end, move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), om_tostring(), RETURN, and wdf.

bool QuartzPostList::at_end (  )  const [inline, virtual]

Return true if and only if we're off the end of the list.

Implements Xapian::PostingIterator::Internal.

Definition at line 240 of file quartz_postlist.h.

string QuartzPostList::get_description (  )  const [virtual]

Get a description of the document.

Implements Xapian::PostingIterator::Internal.

Definition at line 933 of file quartz_postlist.cc.

References number_of_entries, om_tostring(), and tname.

void QuartzPostList::read_number_of_entries ( const char **  posptr,
const char *  end,
Xapian::termcount number_of_entries_ptr,
Xapian::termcount collection_freq_ptr 
) [static]

Read the number of entries and the collection frequency.

This must only be called when *posptr is pointing to the start of the first chunk of the posting list.

Definition at line 639 of file quartz_postlist.cc.

References report_read_error(), and unpack_uint().

Referenced by QuartzAllTermsList::get_stats(), and read_start_of_first_chunk().


Member Data Documentation

Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> QuartzPostList::this_db [private]

The database we are searching.

This pointer is held so that the database doesn't get deleted before us.

Definition at line 94 of file quartz_postlist.h.

const Btree* QuartzPostList::table [private]

The table containing the postlist.

Definition at line 97 of file quartz_postlist.h.

const Btree* QuartzPostList::positiontable [private]

The table containing positionlists.

Definition at line 100 of file quartz_postlist.h.

Referenced by open_position_list(), and read_position_list().

string QuartzPostList::tname [private]

The termname for this postlist.

Definition at line 103 of file quartz_postlist.h.

Referenced by get_description(), move_to_chunk_containing(), next_chunk(), open_position_list(), QuartzPostList(), and read_position_list().

AutoPtr<Bcursor> QuartzPostList::cursor [private]

Cursor pointing to current chunk of postlist.

Definition at line 106 of file quartz_postlist.h.

Referenced by move_to_chunk_containing(), next_chunk(), and QuartzPostList().

bool QuartzPostList::is_last_chunk [private]

True if this is the last chunk.

Definition at line 109 of file quartz_postlist.h.

Referenced by move_to_chunk_containing(), next_chunk(), and QuartzPostList().

Xapian::docid QuartzPostList::first_did_in_chunk [private]

The first document id in this chunk.

Definition at line 112 of file quartz_postlist.h.

Referenced by current_chunk_contains(), move_to_chunk_containing(), next_chunk(), and QuartzPostList().

Xapian::docid QuartzPostList::last_did_in_chunk [private]

The last document id in this chunk.

Definition at line 115 of file quartz_postlist.h.

Referenced by current_chunk_contains(), move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next_chunk(), next_in_chunk(), and QuartzPostList().

const char* QuartzPostList::pos [private]

Position of iteration through current chunk.

Definition at line 118 of file quartz_postlist.h.

Referenced by move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next_chunk(), next_in_chunk(), and QuartzPostList().

const char* QuartzPostList::end [private]

Pointer to byte after end of current chunk.

Definition at line 121 of file quartz_postlist.h.

Referenced by move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next_chunk(), next_in_chunk(), and QuartzPostList().

Xapian::docid QuartzPostList::did [private]

Document id we're currently at.

Definition at line 124 of file quartz_postlist.h.

Referenced by move_forward_in_chunk_to_at_least(), move_to_chunk_containing(), next(), next_chunk(), next_in_chunk(), open_position_list(), QuartzPostList(), read_position_list(), and skip_to().

quartz_doclen_t QuartzPostList::doclength [private]

The (absolute) length of the current document.

Definition at line 127 of file quartz_postlist.h.

Referenced by move_to_chunk_containing(), next(), next_chunk(), next_in_chunk(), QuartzPostList(), and skip_to().

Xapian::termcount QuartzPostList::wdf [private]

The wdf of the current document.

Definition at line 130 of file quartz_postlist.h.

Referenced by move_to_chunk_containing(), next(), next_chunk(), next_in_chunk(), QuartzPostList(), and skip_to().

bool QuartzPostList::is_at_end [private]

Whether we've run off the end of the list yet.

Definition at line 133 of file quartz_postlist.h.

Referenced by move_to_chunk_containing(), next(), next_chunk(), QuartzPostList(), and skip_to().

bool QuartzPostList::have_started [private]

Whether we've started reading the list yet.

Definition at line 136 of file quartz_postlist.h.

Referenced by next(), and skip_to().

Xapian::doccount QuartzPostList::number_of_entries [private]

The number of entries in the posting list.

Definition at line 139 of file quartz_postlist.h.

Referenced by get_description(), move_to_chunk_containing(), and QuartzPostList().

QuartzPositionList QuartzPostList::positionlist [private]

The position list object for this posting list.

Definition at line 142 of file quartz_postlist.h.

Referenced by read_position_list().


The documentation for this class was generated from the following files:
Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.