24 #ifndef XAPIAN_INCLUDED_GLASS_DATABASE_H
25 #define XAPIAN_INCLUDED_GLASS_DATABASE_H
39 #include "../flint_lock.h"
47 #include <string_view>
184 const std::string & msg);
231 int flags = Xapian::DB_READONLY_,
232 unsigned int block_size = 0u);
266 bool need_read_pos)
const;
273 std::string_view
term)
const;
275 std::string_view
term)
const;
277 std::string_view
term)
const;
292 std::string_view start_revision,
327 const char * destdir,
329 const std::vector<const Xapian::Database::Internal*>& sources,
330 const std::vector<Xapian::docid> & offset,
439 bool need_read_pos)
const;
444 std::string_view
term)
const;
446 std::string_view
term)
const;
448 std::string_view
term)
const;
457 void add_synonym(std::string_view word, std::string_view synonym)
const;
458 void remove_synonym(std::string_view word, std::string_view synonym)
const;
461 void set_metadata(std::string_view key, std::string_view value);
471 #ifdef DISABLE_GPL_LIBXAPIAN
472 # error GPL source we cannot relicense included in libxapian
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
A cursor pointing to a position in a Btree table, for reading several entries in order,...
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree s...
void get_freqs(std::string_view term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
void get_used_docid_range(Xapian::docid &first, Xapian::docid &last) const
Find lowest and highest docids actually in use.
string get_metadata(std::string_view key) const
Get the metadata associated with a given key.
TermList * open_term_list(Xapian::docid did) const
Xapian::totallength get_total_length() const
Return the total length of all documents in this database.
bool locked() const
Return true if the database is open for writing.
Xapian::termcount get_wdf_upper_bound(std::string_view term) const
Get an upper bound on the wdf of term term.
void get_database_write_lock(int flags, bool creating)
Get a write lock on the database, or throw an Xapian::DatabaseLockError if failure.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
LeafPostList * open_leaf_post_list(std::string_view term, bool need_read_pos) const
Create a LeafPostList for use during a match.
void apply()
Apply any outstanding changes to the tables.
PostList * open_post_list(std::string_view tname) const
Return a PostList suitable for use in a PostingIterator.
void set_revision_number(int flags, glass_revision_number_t new_revision)
Set the revision number in the tables.
ValueList * open_value_list(Xapian::valueno slot) const
Open a value stream.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
GlassSpellingTable spelling_table
Table storing spelling correction data.
Xapian::Database::Internal * update_lock(int flags)
Lock a read-only database for writing or unlock a writable database.
std::string db_dir
Directory to store databases in.
void cancel()
Cancel any outstanding changes to the tables.
void get_changeset_revisions(const string &path, glass_revision_number_t *startrev, glass_revision_number_t *endrev) const
Get the revision stored in a changeset.
TermList * open_allterms(std::string_view prefix) const
PositionList * open_position_list(Xapian::docid did, std::string_view term) const
TermList * open_metadata_keylist(std::string_view prefix) const
Open a termlist returning each metadata key.
GlassTermListTable termlist_table
Table storing term lists.
Xapian::termcount get_doclength(Xapian::docid did) const
GlassValueManager value_manager
Value manager.
bool term_exists(std::string_view term) const
TermList * open_spelling_termlist(std::string_view word) const
Create a termlist tree from trigrams of word.
static void compact(Xapian::Compactor *compactor, const char *destdir, int fd, const std::vector< const Xapian::Database::Internal * > &sources, const std::vector< Xapian::docid > &offset, unsigned block_size, Xapian::Compactor::compaction_level compaction, unsigned flags, Xapian::docid last_docid)
Xapian::docid get_lastdocid() const
Return the last used document id of this (sub) database.
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a handle on a document.
void close()
Close all the tables permanently.
Xapian::doccount get_doccount() const
Virtual methods of Database::Internal.
virtual void read_position_list(GlassRePositionList *pos_list, Xapian::docid did, std::string_view term) const
string get_uuid() const
Get a UUID for the database.
void send_whole_database(RemoteConnection &conn, double end_time)
Send a set of messages which transfer the whole database.
GlassCursor * get_postlist_cursor() const
Get a postlist table cursor (used by GlassValueList).
GlassChanges changes
Replication changesets.
FlintLock lock
Lock object.
GlassVersion version_file
The file describing the Glass database.
void create_and_open_tables(int flags, unsigned int blocksize)
Create new tables, and open them.
void readahead_for_query(const Xapian::Query &query) const
glass_revision_number_t get_next_revision_number() const
Get an object holding the next revision number which should be used in the tables.
Xapian::termcount get_wdfdocmax(Xapian::docid did) const
Get the max wdf in document.
bool readonly
Whether the database is readonly.
void request_document(Xapian::docid) const
Request a document.
virtual Xapian::termcount positionlist_count(Xapian::docid did, std::string_view term) const
TermList * open_spelling_wordlist() const
Return a termlist which returns the words which are spelling correction targets.
Xapian::termcount get_unique_terms_lower_bound() const
Get a lower bound on the unique terms size of a document in this DB.
void modifications_failed(glass_revision_number_t new_revision, const std::string &msg)
Called if a modifications fail.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
GlassDatabase(std::string_view db_dir_, int flags=Xapian::DB_READONLY_, unsigned int block_size=0u)
Create and open a glass database.
virtual bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
std::string get_description() const
Return a string describing this object.
TermList * open_synonym_keylist(std::string_view prefix) const
Open a termlist returning each term which has synonyms.
GlassPositionListTable position_table
Table storing position lists.
bool reopen()
Re-open tables to recover from an overwritten condition, or just get most up-to-date version.
TermList * open_term_list_direct(Xapian::docid did) const
Like open_term_list() but without MultiTermList wrapper.
GlassDocDataTable docdata_table
Table storing document data.
bool database_exists()
Return true if a database exists at the path specified for this database.
Xapian::doccount get_spelling_frequency(std::string_view word) const
Return the number of times word was added as a spelling.
int get_backend_info(string *path) const
Get backend information about this database.
void write_changesets_to_fd(int fd, std::string_view start_revision, bool need_whole_db, Xapian::ReplicationInfo *info)
Write a set of changesets to a file descriptor.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
TermList * open_synonym_termlist(std::string_view term) const
Open a termlist returning synonyms for a term.
GlassPostListTable postlist_table
Table storing posting lists.
friend class GlassWritableDatabase
GlassSynonymTable synonym_table
Table storing synonym data.
bool open_tables(int flags)
Open all tables at most recent revision.
void throw_termlist_table_close_exception() const
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
Xapian::rev get_revision() const
Get the revision number which the tables are opened at.
bool has_positions() const
Check whether this database contains any positional information.
A postlist in a glass database.
A reusable position list in a glass database.
GlassCursor * cursor_get() const
Get a cursor for reading from the table.
A TermList in a glass database.
The GlassVersion class manages the revision files.
A writable glass database.
void flush_postlist_changes()
Flush any unflushed postlist changes, but don't commit them.
Xapian::docid add_document_(Xapian::docid did, const Xapian::Document &document)
bool term_exists(std::string_view term) const
void remove_synonym(std::string_view word, std::string_view synonym) const
Remove a synonym for a term.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
TermList * open_synonym_keylist(std::string_view prefix) const
Open a termlist returning each term which has synonyms.
std::map< Xapian::valueno, ValueStats > value_stats
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
TermList * open_spelling_wordlist() const
Return a termlist which returns the words which are spelling correction targets.
void get_freqs(std::string_view term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
void close()
Close all the tables permanently.
bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
ValueList * open_value_list(Xapian::valueno slot) const
Open a value stream.
void commit()
Implementation of virtual methods: see Database::Internal for details.
void replace_document(Xapian::docid did, const Xapian::Document &document)
void delete_document(Xapian::docid did)
void invalidate_doc_object(Xapian::Document::Internal *obj) const
Notify the database that document is no longer valid.
void add_synonym(std::string_view word, std::string_view synonym) const
Add a synonym for a term.
void apply()
Apply changes.
void cancel()
Cancel pending modifications to the database.
LeafPostList * open_leaf_post_list(std::string_view term, bool need_read_pos) const
Create a LeafPostList for use during a match.
void read_position_list(GlassRePositionList *pos_list, Xapian::docid did, std::string_view term) const
PostList * open_post_list(std::string_view term) const
Return a PostList suitable for use in a PostingIterator.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
Xapian::Document::Internal * modify_shortcut_document
A pointer to the last document which was returned by open_document(), or NULL if there is no such val...
void add_spelling(std::string_view word, Xapian::termcount freqinc) const
Add a word to the spelling dictionary.
Xapian::Database::Internal * update_lock(int flags)
Lock a read-only database for writing or unlock a writable database.
Xapian::termcount get_doclength(Xapian::docid did) const
Virtual methods of Database::Internal.
void check_flush_threshold()
Check if we should autoflush.
TermList * open_allterms(std::string_view prefix) const
Xapian::doccount flush_threshold
If change_count reaches this threshold we automatically flush.
Xapian::docid add_document(const Xapian::Document &document)
Xapian::docid modify_shortcut_docid
The document ID for the last document returned by open_document().
Xapian::termcount positionlist_count(Xapian::docid did, std::string_view term) const
PositionList * open_position_list(Xapian::docid did, std::string_view term) const
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a handle on a document.
bool has_positions() const
Check whether this database contains any positional information.
void set_metadata(std::string_view key, std::string_view value)
Set the metadata associated with a given key.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
Xapian::termcount remove_spelling(std::string_view word, Xapian::termcount freqdec) const
Remove a word from the spelling dictionary.
Xapian::doccount change_count
The number of documents added, deleted, or replaced since the last flush.
void clear_synonyms(std::string_view word) const
Clear all synonyms for a term.
Database using honey backend.
std::string path
Path of the directory.
Class which "inverts the file".
Abstract base class for leaf postlists.
A RemoteConnection object provides a bidirectional connection to another RemoteConnection object on a...
Compact a database, or merge and compact several.
compaction_level
Compaction level.
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.
Class representing a document.
Abstract base class for postlists.
Abstract base class for iterating term positions in a document.
Class representing a query.
Abstract base class for termlists.
Abstract base class for value streams.
Compact a database, or merge and compact several.
Constants in the Xapian namespace.
Virtual base class for Database internals.
Definitions, types, etc for use inside glass.
uint4 glass_revision_number_t
The revision number of a glass database.
Subclass of GlassTable which holds document data.
Inverter class which "inverts the file".
A position list in a glass database.
Postlists in glass databases.
Spelling correction data for a glass database.
Synonym data for a glass database.
Subclass of GlassTable which holds termlists.
double end_time(double timeout)
Return the end time for a timeout in timeout seconds.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
XAPIAN_REVISION_TYPE rev
Revision number of a database.
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.
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
Information about the steps involved in performing a replication.