24 #ifndef XAPIAN_INCLUDED_INMEMORY_DATABASE_H
25 #define XAPIAN_INCLUDED_INMEMORY_DATABASE_H
35 #include <string_view>
97 std::vector<InMemoryPosting>
docs;
115 std::vector<InMemoryTermEntry>
terms;
138 std::vector<InMemoryPosting>::const_iterator
pos;
139 std::vector<InMemoryPosting>::const_iterator
end;
215 std::vector<InMemoryTermEntry>::const_iterator
pos;
216 std::vector<InMemoryTermEntry>::const_iterator
end;
254 std::map<std::string, InMemoryTerm, std::less<>>
postlists;
257 std::vector<std::map<Xapian::valueno, std::string>>
valuelists;
262 std::map<std::string, std::string, std::less<>>
metadata;
277 void make_term(
const std::string& tname);
285 const std::map<Xapian::valueno, std::string>& values_);
288 const std::string& tname,
292 bool use_position =
true);
348 bool need_read_pos)
const;
356 void set_metadata(std::string_view key, std::string_view value);
359 std::string_view tname)
const;
361 std::string_view tname)
const;
368 if (path) *path = std::string();
381 #ifdef DISABLE_GPL_LIBXAPIAN
382 # error GPL source we cannot relicense included in libxapian
A PostList over all docs in an inmemory database.
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 ...
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
Xapian::docid get_docid() const
Return the current docid.
Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db
Xapian::termcount get_unique_terms() const
bool at_end() const
Return true if the current position is past the last entry in this list.
InMemoryAllDocsPostList(const InMemoryDatabase *db)
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
std::string get_description() const
Return a string description of this object.
Xapian::termcount get_wdf_upper_bound() const
Xapian::termcount get_doclength() const
PositionList * read_position_list()
Read the position list for the term in the current document and return a pointer to it (owned by the ...
A database held entirely in memory.
Xapian::termcount get_wdfdocmax(Xapian::docid did) const
Get the max wdf in document.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
static void throw_database_closed()
bool locked() const
Return true if the database is open for writing.
TermList * open_term_list_direct(Xapian::docid did) const
Like open_term_list() but without MultiTermList wrapper.
Xapian::termcount get_doclength(Xapian::docid did) const
TermList * open_term_list(Xapian::docid did) const
Xapian::termcount get_wdf_upper_bound(std::string_view term) const
Get an upper bound on the wdf of term term.
std::vector< InMemoryDoc > termlists
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
TermList * open_metadata_keylist(std::string_view prefix) const
Open a termlist returning each metadata key.
void commit()
Implementation of virtual methods: see Database for details.
std::vector< Xapian::termcount > doclengths
void cancel()
Cancel pending modifications to the database.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
InMemoryDatabase(const InMemoryDatabase &)
void replace_document(Xapian::docid did, const Xapian::Document &document)
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
void get_used_docid_range(Xapian::docid &first, Xapian::docid &last) const
Find lowest and highest docids actually in use.
std::string get_description() const
Return a string describing this object.
void add_values(Xapian::docid did, const std::map< Xapian::valueno, std::string > &values_)
std::map< Xapian::valueno, ValueStats > valuestats
PostList * open_post_list(std::string_view tname) const
Return a PostList suitable for use in a PostingIterator.
Xapian::docid add_document(const Xapian::Document &document)
void make_term(const std::string &tname)
Xapian::docid get_lastdocid() const
Return the last used document id of this (sub) database.
void delete_document(Xapian::docid did)
LeafPostList * open_leaf_post_list(std::string_view term, bool need_read_pos) const
Create a LeafPostList for use during a match.
PositionList * open_position_list(Xapian::docid did, std::string_view tname) const
Xapian::docid make_doc(const std::string &docdata)
Xapian::termcount positionlist_count(Xapian::docid did, std::string_view tname) const
bool reopen()
Reopen the database to the latest available revision.
Xapian::Database::Internal * update_lock(int flags)
Lock a read-only database for writing or unlock a writable database.
void make_posting(InMemoryDoc *doc, const std::string &tname, Xapian::docid did, Xapian::termpos position, Xapian::termcount wdf, bool use_position=true)
InMemoryDatabase & operator=(const InMemoryDatabase &)
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
bool doc_exists(Xapian::docid did) const
std::vector< std::string > doclists
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a handle on a document.
Xapian::doccount get_doccount() const
bool term_exists(std::string_view term) const
void close()
Close the database.
TermList * open_allterms(std::string_view prefix) const
std::map< std::string, std::string, std::less<> > metadata
Xapian::totallength totlen
std::map< std::string, InMemoryTerm, std::less<> > postlists
std::vector< std::map< Xapian::valueno, std::string > > valuelists
void finish_add_doc(Xapian::docid did, const Xapian::Document &document)
void set_metadata(std::string_view key, std::string_view value)
Set the metadata associated with a given key.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
void get_freqs(std::string_view term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
int get_backend_info(std::string *path) const
Get backend information about this database.
std::string get_metadata(std::string_view key) const
Get the metadata associated with a given key.
Xapian::totallength get_total_length() const
Return the total length of all documents in this database.
bool has_positions() const
Check whether this database contains any positional information.
InMemoryDatabase()
Create and open an in-memory database.
Class representing a document and the terms indexing it.
InMemoryDoc(bool is_valid_)
void add_posting(const std::string &tname, Xapian::termcount wdf, Xapian::termpos position, bool use_position)
std::vector< InMemoryTermEntry > terms
A document read from a InMemoryDatabase.
PositionList from an InMemory DB or a Document object.
A PostList in an inmemory database.
std::string get_description() const
Return a string description of this object.
Xapian::termcount wdf_upper_bound
Xapian::docid get_docid() const
Return the current docid.
InMemoryPositionList mypositions
List of positions of the current term.
InMemoryPostList(const InMemoryDatabase *db, const InMemoryTerm &imterm, std::string_view term_)
void get_docid_range(Xapian::docid &first, Xapian::docid &last) const
Get the bounds on the range of docids this PostList can return.
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
Xapian::termcount get_wdfdocmax() const
std::vector< InMemoryPosting >::const_iterator pos
bool at_end() const
Return true if the current position is past the last entry in this list.
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::Internal::intrusive_ptr< const InMemoryDatabase > db
PositionList * read_position_list()
Read the position list for the term in the current document and return a pointer to it (owned by the ...
Xapian::termcount get_wdf_upper_bound() const
std::vector< InMemoryPosting >::const_iterator end
int operator()(const InMemoryPosting &p1, const InMemoryPosting &p2) const
void add_position(Xapian::termpos pos)
Xapian::VecCOW< Xapian::termpos > positions
int operator()(const InMemoryTermEntry &p1, const InMemoryTermEntry &p2) const
void add_position(Xapian::termpos pos)
Xapian::VecCOW< Xapian::termpos > positions
InMemoryTermList(Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db, Xapian::docid did, const InMemoryDoc &doc, Xapian::termcount len)
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
void accumulate_stats(Xapian::Internal::ExpandStats &stats) const
Collate weighting information for the current term.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::Internal::intrusive_ptr< const InMemoryDatabase > db
TermList * next()
Advance the current position to the next term in the termlist.
std::vector< InMemoryTermEntry >::const_iterator pos
TermList * skip_to(std::string_view term)
Skip forward to the specified term.
Xapian::termcount document_length
std::vector< InMemoryTermEntry >::const_iterator end
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
PositionList * positionlist_begin() const
Return PositionList for the current position.
Xapian::termcount collection_freq
void add_posting(Xapian::docid did, Xapian::termcount wdf, Xapian::termpos position, bool use_position)
Xapian::termcount term_freq
std::vector< InMemoryPosting > docs
Abstract base class for leaf postlists.
Virtual base class for Database internals.
virtual void replace_document(docid did, const Document &document)
virtual void delete_document(docid did)
Abstract base class for a document.
Xapian::docid did
The document ID this document came from in database.
Class representing a document.
Collates statistics while calculating term weight in an ESet.
Abstract base class for postlists.
PostList * next()
Advance the current position to the next document in the postlist.
Abstract base class for iterating term positions in a document.
Abstract base class for termlists.
Suitable for "simple" type T.
Virtual base class for Database internals.
Class representing a document.
PositionList from an InMemory DB or a Document object.
Abstract base class for leaf postlists.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
Various assertion macros.
Custom vector implementations using small vector optimisation.
Abstract base class for termlists.