it.unimi.dsi.mg4j.index
Interface TermMap

All Known Implementing Classes:
AbstractTermMap

public interface TermMap

A map from term to term indices.

To build document iterators at the base of a compound query, a parser need to know, given a term as a character sequence, which is the corresponding inverted list of the index. A class implementing this interface may be used to this purpose.

A term map must return, given a character sequence, a natural number. Optionally, it may return -1 if the character sequence was not indexed. The latter behaviour is not enforced, so that, for example, MinimalPerfectHash instances may be used when it is known a priori whether a term has been indexed or not.

Optionally, an instance of this class may provide two-way access to terms.

Since:
0.9
Author:
Sebastiano Vigna

Method Summary
 int get(CharSequence term)
          Returns the index corresponding to the given term, or possibly (but not necessarily) -1 if the term was not indexed.
 CharSequence get(int index)
          Returns the term corresponding to the given index (optional operation).
 MutableString get(int index, MutableString term)
          Writes in the given mutable string the term corresponding to the given index (optional operation).
 

Method Detail

get

public int get(CharSequence term)
Returns the index corresponding to the given term, or possibly (but not necessarily) -1 if the term was not indexed.

Parameters:
term - a term.
Returns:
its ordinal number, or possibly (but not necessarily) -1 if the term was not indexed.

get

public CharSequence get(int index)
Returns the term corresponding to the given index (optional operation).

Parameters:
index - a term index.
Returns:
the corresponding term, or possibly (but not necessarily) null if the term was not indexed.

get

public MutableString get(int index,
                         MutableString term)
Writes in the given mutable string the term corresponding to the given index (optional operation).

Parameters:
index - a term index.
term - a mutable string that will be fillted with the corresponding term.
Returns:
term, or possibly (but not necessarily) null if the term was not indexed.