Class: Ferret::Index::TermDocEnum

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Method Details

#closeObject

Frees associated resources.

Raises:

  • (NotImplementedError)


53
# File 'lib/ferret/index/term_doc_enum.rb', line 53

def close() raise NotImplementedError end

#docObject

Returns the current document number.

This is invalid until #next() is called for the first time.

Raises:

  • (NotImplementedError)


20
# File 'lib/ferret/index/term_doc_enum.rb', line 20

def doc() raise NotImplementedError end

#freqObject

Returns the frequency of the term within the current document. This is invalid until #next() is called for the first time.

Raises:

  • (NotImplementedError)


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.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


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