52 vector<InMemoryPosting>::iterator p;
53 p = lower_bound(
docs.begin(),
docs.end(),
57 }
else if (!p->valid) {
68 vector<InMemoryTermEntry>::iterator p;
69 p = lower_bound(terms.begin(), terms.end(),
72 terms.insert(p, post);
84 const std::string & term_)
86 pos(imterm.
docs.begin()),
87 end(imterm.
docs.end()),
95 auto first_wdf = (*pos).wdf;
143 while (!
at_end() && (*pos).did < did) {
212 :
pos(doc.terms.begin()),
end(doc.terms.
end()), terms(doc.terms.size()),
215 LOGLINE(DB,
"InMemoryTermList::InMemoryTermList(): " <<
216 terms <<
" terms starting from " <<
pos->tname);
287 while (
pos !=
end &&
pos->tname < term) {
338 Assert(did <= db->termlists.size());
381 }
while (did <= db->termlists.size() && !
db->
termlists[
did - 1].is_valid);
392 while (did <= db->termlists.size() && !
db->
termlists[
did - 1].is_valid) {
415 return "InMemoryAllDocsPostList " +
str(
did);
423 : totdocs(0), totlen(0), positions_present(
false), closed(
false)
467 map<string, InMemoryTerm>::const_iterator i =
postlists.find(tname);
468 if (i ==
postlists.end() || i->second.term_freq == 0) {
490 map<string, InMemoryTerm>::const_iterator i =
postlists.find(term);
493 *termfreq_ptr = i->second.term_freq;
495 *collfreq_ptr = i->second.collection_freq;
508 map<Xapian::valueno, ValueStats>::const_iterator i =
valuestats.find(slot);
510 return i->second.freq;
517 map<Xapian::valueno, ValueStats>::const_iterator i =
valuestats.find(slot);
519 return i->second.lower_bound;
526 map<Xapian::valueno, ValueStats>::const_iterator i =
valuestats.find(slot);
528 return i->second.upper_bound;
557 string(
" not found"));
568 string(
" not found"));
584 string(
" not found"));
598 string(
" not found"));
607 map<string, string>::const_iterator i =
metadata.find(key);
624 const std::string & value)
627 if (!value.empty()) {
636 const string & tname)
const 646 auto t = lower_bound(doc.
terms.begin(), doc.
terms.end(),
648 if (t != doc.
terms.end() && t->tname == tname) {
649 return t->positions.size();
656 const string & tname)
const 664 auto t = lower_bound(doc.
terms.begin(), doc.
terms.end(),
666 if (t != doc.
terms.end() && t->tname == tname) {
675 const map<Xapian::valueno, string> &values_)
684 map<Xapian::valueno, string>::const_iterator j;
685 for (j = values_.begin(); j != values_.end(); ++j) {
686 std::pair<map<Xapian::valueno, ValueStats>::iterator,
bool> i;
690 if ((i.first->second.freq)++ == 0) {
693 i.first->second.lower_bound = j->second;
694 i.first->second.upper_bound = j->second;
697 if (j->second < i.first->second.lower_bound) {
698 i.first->second.lower_bound = j->second;
700 if (j->second > i.first->second.upper_bound) {
701 i.first->second.upper_bound = j->second;
725 string(
" not found"));
729 map<Xapian::valueno, string>::const_iterator j;
731 map<Xapian::valueno, ValueStats>::iterator i;
733 if (--(i->second.freq) == 0) {
734 i->second.lower_bound.resize(0);
735 i->second.upper_bound.resize(0);
747 vector<InMemoryTermEntry>::const_iterator i;
748 for (i =
termlists[did - 1].terms.begin();
751 map<string, InMemoryTerm>::iterator t =
postlists.find(i->tname);
753 t->second.collection_freq -= i->wdf;
754 --t->second.term_freq;
761 auto p = lower_bound(t->second.docs.begin(), t->second.docs.end(),
763 if (p != t->second.docs.end() && p->did == did) {
774 LOGCALL_VOID(DB,
"InMemoryDatabase::replace_document", did | document);
779 map<Xapian::valueno, string>::const_iterator j;
781 map<Xapian::valueno, ValueStats>::iterator i;
783 if (--(i->second.freq) == 0) {
784 i->second.lower_bound.resize(0);
785 i->second.upper_bound.resize(0);
801 vector<InMemoryTermEntry>::const_iterator i;
802 for (i =
termlists[did - 1].terms.begin();
805 map<string, InMemoryTerm>::iterator t =
postlists.find(i->tname);
807 t->second.collection_freq -= i->wdf;
808 --t->second.term_freq;
815 auto p = lower_bound(t->second.docs.begin(), t->second.docs.end(),
817 if (p != t->second.docs.end() && p->did == did) {
845 map<Xapian::valueno, string> values;
849 LOGLINE(DB,
"InMemoryDatabase::finish_add_doc(): adding value " <<
860 LOGLINE(DB,
"InMemoryDatabase::finish_add_doc(): adding term " << *i);
902 const string & tname,
921 posting.
valid =
true;
928 termentry.
tname = tname;
943 map<string, InMemoryTerm>::const_iterator i =
postlists.find(tname);
945 return (i->second.term_freq != 0);
Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db
vector< InMemoryPosting >::const_iterator end
vector< InMemoryTermEntry >::const_iterator end
string get_description() const
Return a string description of this object.
Class to hold statistics for a given slot.
PositionList * read_position_list()
Read the position list for the term in the current document and return a pointer to it (owned by the ...
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
Abstract base class for postlists.
Xapian::docid make_doc(const string &docdata)
Indicates an attempt to access a closed database.
vector< Xapian::termpos > positions
PositionList * open_position_list() const
Read the position list for the term in the current document and return a pointer to it (not owned by ...
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a document.
Xapian::totallength get_total_length() const
Return the total length of all documents in this database.
void merge(const InMemoryPosting &post)
void make_posting(InMemoryDoc *doc, const string &tname, Xapian::docid did, Xapian::termpos position, Xapian::termcount wdf, bool use_position=true)
bool at_end() const
Return true if the current position is past the last entry in this list.
string get_description() const
Return a string description of this object.
Xapian::termcount wdf_upper_bound
void commit()
Implementation of virtual methods: see Database for details.
Iterate all terms in an inmemory db.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
friend class InMemoryAllDocsPostList
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
Xapian::doccount get_termfreq() const
Return the exact term frequency.
ValueIterator values_begin() const
Iterator for the values in this document.
Xapian::termcount get_doclength() const
Return the length of current document.
Xapian::totallength totlen
Xapian::termcount get_wdf_upper_bound() const
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
vector< Xapian::termcount > doclengths
void finish_add_doc(Xapian::docid did, const Xapian::Document &document)
A document in the database, possibly plus modifications.
Class for iterating over document values.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
Abstract base class for termlists.
A document read from a InMemoryDatabase.
Convert types to std::string.
void cancel()
Implementation of virtual methods: see Database for details.
PositionList * open_position_list() const
Read the position list for the term in the current document and return a pointer to it (not owned by ...
vector< InMemoryTermEntry >::const_iterator pos
Xapian::docid get_docid() const
Return the current docid.
LeafPostList * open_post_list(const string &tname) const
Open a posting list.
bool has_positions() const
Check whether this database contains any positional information.
TermList * open_allterms(const string &prefix) const
Open an allterms list.
Abstract base class for leaf postlists.
Xapian::doccount get_doccount() const
Return the number of docs in this (sub) database.
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
void add_posting(const InMemoryPosting &post)
void accumulate_stats(Xapian::Internal::ExpandStats &stats) const
Collate weighting information for the current term.
vector< Xapian::termpos > positions
InMemoryTermList(Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db, Xapian::docid did, const InMemoryDoc &doc, Xapian::termcount len)
Xapian::termcount document_length
PositionList * open_position_list(Xapian::docid did, const string &tname) const
Open a position list for the given term in the given document.
enum Xapian::Database::Internal::@2 transaction_state
Transaction state.
Hierarchy of classes which Xapian can throw as exceptions.
vector< InMemoryPosting > docs
Class for iterating over a list of terms.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
bool at_end() const
Return true if the current position is past the last entry in this list.
PositionIterator positionlist_end() const
Return an end PositionIterator for the current term.
Class representing a document and the terms indexing it.
void accumulate(size_t shard_index, Xapian::termcount wdf, Xapian::termcount doclen, Xapian::doccount subtf, Xapian::doccount subdbsize)
InMemoryPositionList mypositions
List of positions of the current term.
Xapian::docid add_document(const Xapian::Document &document)
Implementation of virtual methods: see Database for details.
Xapian::docid get_docid() const
Return the current docid.
bool doc_exists(Xapian::docid did) const
Xapian::docid get_lastdocid() const
Return the last used document id of this (sub) database.
Collate statistics and calculate the term weights for the ESet.
vector< InMemoryTermEntry > terms
Xapian::termcount collection_freq
InMemoryDatabase()
Create and open an in-memory database.
string get_termname() const
Return the termname at the current position.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
void replace_document(Xapian::docid did, const Xapian::Document &document)
Implementation of virtual methods: see Database for details.
std::map< string, string > metadata
Internal * next()
Advance the current position to the next document in the postlist.
Xapian::termcount get_unique_terms() const
Return the number of unique terms in the current document.
A PostList in an inmemory database.
string str(int value)
Convert int to std::string.
A position list in a inmemory database.
TermList * open_term_list(Xapian::docid did) const
Open a term list.
Class for iterating over document values.
C++ class definition for inmemory database access.
std::map< Xapian::valueno, ValueStats > valuestats
Class for iterating over term positions.
Xapian::termcount get_wdf_upper_bound() const
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
void close()
Close the database.
Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
ValueIterator values_end() const
Equivalent end iterator for values_begin().
Indicates an attempt to access a document not present in the database.
vector< std::map< Xapian::valueno, string > > valuelists
void get_freqs(const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
Xapian::doccount termfreq
void add_values(Xapian::docid did, const map< Xapian::valueno, string > &values_)
static void throw_database_closed()
TermList * skip_to(const std::string &term)
Skip forward to the specified term.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique term in document.
#define AssertEqParanoid(A, B)
class for alltermslists over several databases
vector< std::string > doclists
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Xapian::termcount positionlist_count(Xapian::docid did, const string &tname) const
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
map< string, InMemoryTerm > postlists
void delete_document(Xapian::docid did)
Implementation of virtual methods: see Database for details.
size_t shard_index
Which shard of a multidatabase this is from.
Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db
Xapian::termcount get_unique_terms() const
Return the number of unique terms in the current document.
bool term_exists(const string &tname) const
Check whether a given term is in the database.
Collates statistics while calculating term weight in an ESet.
bool reopen()
Reopen the database to the latest available revision.
void make_term(const string &tname)
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
void dtor_called()
Internal method to perform cleanup when a writable database is destroyed with uncommitted changes...
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a given document.
vector< InMemoryPosting >::const_iterator pos
TermList * open_metadata_keylist(const std::string &prefix) const
Open a termlist returning each metadata key.
friend class InMemoryDocument
Xapian::termcount get_doclength() const
Return the length of current document.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
std::string get_metadata(const std::string &key) const
Get the metadata associated with a given key.
std::string get_data() const
Get data stored in the document.
InMemoryPostList(Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db, const InMemoryTerm &imterm, const std::string &term_)
Abstract base class for iterating term positions in a document.
void set_metadata(const std::string &key, const std::string &value)
Set the metadata associated with a given key.
Xapian::doccount get_termfreq() const
Return the exact term frequency.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
A smart pointer that uses intrusive reference counting.
Xapian::PositionIterator positionlist_begin() const
Return a PositionIterator for the current position.
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
TermIterator termlist_begin() const
Iterator for the terms in this document.
PositionList * read_position_list()
Read the position list for the term in the current document and return a pointer to it (owned by the ...
InMemoryAllDocsPostList(Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db)
PositionIterator positionlist_begin() const
Return a PositionIterator for the current term.
A handle representing a document in a Xapian database.
bool at_end() const
Return true if the current position is past the last term in this list.
TermList * next()
Advance the current position to the next term in the termlist.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
void set_data(const OmDocumentTerm::term_positions &positions_)
Fill list with data, and move the position to the start.
Xapian::valueno get_valueno() const
Return the value slot number for the current position.
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
UnimplementedError indicates an attempt to use an unimplemented feature.
Xapian::termcount term_freq
void add_posting(const InMemoryTermEntry &post)
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
vector< InMemoryDoc > termlists