Class: Ferret::Index::TermDocEnum
- Inherits:
-
Object
- Object
- Ferret::Index::TermDocEnum
- Defined in:
- lib/ferret/index/term_doc_enum.rb
Overview
TermDocEnum provides an interface for enumerating <document, frequency> pairs for a term.
The document portion names each document containing the term. Documents are indicated by number. The frequency portion gives the number of times the term occurred in each document.
The pairs are ordered by document number.
See IndexReader#term_docs
Direct Known Subclasses
MultiTermDocEnum, MultipleTermDocPosEnum, SegmentTermDocEnum
Instance Method Summary collapse
-
#close ⇒ Object
Frees associated resources.
-
#doc ⇒ Object
Returns the current document number.
-
#freq ⇒ Object
Returns the frequency of the term within the current document.
-
#next? ⇒ Boolean
Moves to the next pair in the enumeration.
-
#read(docs, freqs) ⇒ Object
Attempts to read multiple entries from the enumeration, up to length of docs.
-
#seek(term) ⇒ Object
Sets this to the data for a term.
-
#skip_to(target) ⇒ Object
Skips entries to the first beyond the current whose document number is greater than or equal to target.
Instance Method Details
#close ⇒ Object
Frees associated resources.
53 |
# File 'lib/ferret/index/term_doc_enum.rb', line 53 def close() raise NotImplementedError end |
#doc ⇒ Object
Returns the current document number.
This is invalid until #next() is called for the first time.
20 |
# File 'lib/ferret/index/term_doc_enum.rb', line 20 def doc() raise NotImplementedError end |
#freq ⇒ Object
Returns the frequency of the term within the current document. This is invalid until #next() is called for the first time.
24 |
# File 'lib/ferret/index/term_doc_enum.rb', line 24 def freq() raise NotImplementedError end |
#next? ⇒ Boolean
Moves to the next pair in the enumeration. Returns true iff there is such a next pair in the enumeration.
28 |
# File 'lib/ferret/index/term_doc_enum.rb', line 28 def next?() raise NotImplementedError end |
#read(docs, freqs) ⇒ Object
Attempts to read multiple entries from the enumeration, up to length of docs. Document numbers are stored in docs, and term frequencies are stored in freqs. The freqs array must be as long as the docs array.
Returns the number of entries read. Zero is only returned when the stream has been exhausted.
37 |
# File 'lib/ferret/index/term_doc_enum.rb', line 37 def read(docs, freqs) raise NotImplementedError end |
#seek(term) ⇒ Object
Sets this to the data for a term. The enumeration is reset to the start of the data for this term.
15 |
# File 'lib/ferret/index/term_doc_enum.rb', line 15 def seek(term) raise NotImplementedError end |
#skip_to(target) ⇒ Object
Skips entries to the first beyond the current whose document number is greater than or equal to target.
Returns true iff there is such an entry.
Some implementations are considerably more efficient than that.
45 46 47 48 49 50 |
# File 'lib/ferret/index/term_doc_enum.rb', line 45 def skip_to(target) while (target > doc()) return false if not next?() end return true end |