21 #ifndef XAPIAN_INCLUDED_DOCUMENTINTERNAL_H
22 #define XAPIAN_INCLUDED_DOCUMENTINTERNAL_H
38 #include <string_view>
50 friend class ::DocumentTermList;
51 friend class ::DocumentValueList;
53 friend class ::GlassValueManager;
54 friend class ::HoneyValueManager;
55 friend class ::ValueStreamDocument;
67 std::unique_ptr<std::string>
data;
78 std::unique_ptr<std::map<std::string, TermInfo, std::less<>>>
terms;
140 mutable std::unique_ptr<std::map<Xapian::valueno, std::string>>
values;
166 std::map<Xapian::valueno, std::string>&& values_)
167 :
data(new std::string(std::move(data_))),
186 std::string>& values_)
const;
270 data.reset(
new std::string(data_));
278 if (i ==
terms->end()) {
282 if (i->second.increase_wdf(wdf_inc))
292 if (i ==
terms->end()) {
295 if (i->second.has_positions()) {
298 if (!i->second.remove()) {
313 if (i ==
terms->end()) {
318 if (i->second.add_position(wdf_inc, term_pos))
332 if (i ==
terms->end() || i->second.is_deleted()) {
333 return remove_posting_result::NO_TERM;
335 if (!i->second.remove_position(term_pos)) {
336 return remove_posting_result::NO_POS;
338 if (i->second.decrease_wdf(wdf_dec))
341 return remove_posting_result::OK;
357 if (i ==
terms->end() || i->second.is_deleted()) {
358 return remove_posting_result::NO_TERM;
360 n_removed = i->second.remove_positions(term_pos_first,
367 wdf_delta = std::numeric_limits<Xapian::termcount>::max();
369 if (i->second.decrease_wdf(wdf_delta))
372 return remove_posting_result::OK;
383 terms.reset(
new std::map<std::string,
TermInfo, std::less<>>());
402 return tl->get_approx_size();
418 auto i =
values->find(slot);
421 return std::string();
431 if (!value.empty()) {
432 (*values)[slot] = value;
444 values.reset(
new std::map<Xapian::valueno, std::string>());
Iteration over terms in a document.
Iteration over values in a document.
Metadata for a term in a document.
A document which gets its values from a ValueStreamManager.
Virtual base class for Database internals.
virtual TermList * open_term_list(docid did) const =0
virtual bool has_positions() const =0
Check whether this database contains any positional information.
Abstract base class for a document.
void set_index(Xapian::doccount new_index)
Internal method used by MSet::diversify().
Xapian::docid did
The document ID this document came from in database.
std::unique_ptr< std::map< std::string, TermInfo, std::less<> > > terms
Terms in the document and their associated metadata.
void add_value(Xapian::valueno slot, std::string_view value)
Add a value to a slot in this document.
Xapian::termcount termlist_count() const
Return the number of distinct terms in this document.
virtual void fetch_all_values(std::map< Xapian::valueno, std::string > &values_) const
Fetch all set values from the database.
Internal(Xapian::Internal::intrusive_ptr< const Xapian::Database::Internal > database_, Xapian::docid did_)
Constructor used by subclasses.
void ensure_values_fetched() const
Ensure values have been fetched from database.
std::unique_ptr< std::map< Xapian::valueno, std::string > > values
Document value slots and their contents.
std::unique_ptr< std::string > data
The document data.
void ensure_terms_fetched() const
Ensure terms have been fetched from database.
void add_term(std::string_view term, Xapian::termcount wdf_inc)
Add a term to this document.
Xapian::docid get_docid() const
Get the document ID this document came from.
bool modified() const
Return true if the document might have been modified in any way.
bool data_modified() const
Return true if the document data might have been modified.
bool positions_modified_
Are there any changes to term positions in terms?
bool remove_term(std::string_view term)
Remove a term from this document.
void add_posting(std::string_view term, Xapian::termpos term_pos, Xapian::termcount wdf_inc)
Add a posting for a term.
Xapian::doccount index
An index value, unused by Document itself.
void set_data(std::string_view data_)
Set the document data.
virtual std::string fetch_data() const
Fetch the document data from the database.
Xapian::doccount get_index() const
Internal method used by MSet::diversify().
Xapian::ValueIterator values_begin() const
bool values_modified() const
Return true if the document's values might have been modified.
bool positions_modified() const
Return true if the document's term positions might have been modified.
std::string get_description() const
Return a string describing this object.
Xapian::termcount termlist_size
The number of distinct terms in terms.
virtual std::string fetch_value(Xapian::valueno slot) const
Fetch a single value from the database.
remove_posting_result remove_postings(std::string_view term, Xapian::termpos term_pos_first, Xapian::termpos term_pos_last, Xapian::termcount wdf_dec, Xapian::termpos &n_removed)
Remove a range of postings for a term.
Internal()
Construct an empty document.
remove_posting_result remove_posting(std::string_view term, Xapian::termpos term_pos, Xapian::termcount wdf_dec)
Remove a posting for a term.
Internal(const Internal &)=delete
Don't allow copying.
std::string get_data() const
Get the document data.
void operator=(const Internal &)=delete
Don't allow assignment.
Xapian::valueno values_count() const
Count the value slots used in this document.
void clear_terms()
Clear all terms from the document.
std::string get_value(Xapian::valueno slot) const
Read a value slot in this document.
TermList * open_term_list() const
Start iterating the terms in this document.
virtual ~Internal()
We have virtual methods and want to be able to delete derived classes using a pointer to the base cla...
void clear_values()
Clear all value slots in this document.
Xapian::Internal::intrusive_ptr< const Xapian::Database::Internal > database
Database this document came from.
bool terms_modified() const
Return true if the document's terms might have been modified.
Internal(const Xapian::Database::Internal *database_, Xapian::docid did_, std::string &&data_, std::map< Xapian::valueno, std::string > &&values_)
Constructor used by RemoteDocument subclass.
Base class for objects managed by intrusive_ptr.
Abstract base class for termlists.
Class for iterating over document values.
Virtual base class for Database internals.
Class representing a document.
The Xapian namespace contains public interfaces for the Xapian library.
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.
Arithmetic operations with overflow checks.
std::enable_if_t< std::is_unsigned_v< T1 > &&std::is_unsigned_v< T2 > &&std::is_unsigned_v< R >, bool > mul_overflows(T1 a, T2 b, R &res)
Multiplication with overflow checking.
Metadata for a term in a document.
Abstract base class for termlists.