it.unipi.di.textdb
Interface SearchableDB

All Known Implementing Classes:
FrontCoding

public interface SearchableDB

Search support for TextDBs. It includes the possibility to (prefix-)search for a string, or get its rank in the underlying TextDB. We assume that the records are lexicographically sorted, so that it makes sense to say that records having an equal prefix are contiguous in the TextDB.

Author:
Claudio Corsi, Paolo Ferragina

Method Summary
 Range prefix(String p)
          Returns the range [i, j) of consecutive records in the TextDB that are prefixed by string p.
 int rank(String p)
          Returns the position in this TextDB of the input string.
 

Method Detail

rank

int rank(String p)
         throws IOException
Returns the position in this TextDB of the input string. As the underlying TextDB is a sorted list of records (strings), if p is not found, the returned value is the negative value of the position where the input string should be placed in the TextDB.

Parameters:
p - the string to be searched
Returns:
the position pos of s, if s occurs in the TextDB, or the value -pos
Throws:
IOException

prefix

Range prefix(String p)
             throws IOException
Returns the range [i, j) of consecutive records in the TextDB that are prefixed by string p. Positions are counted from 1.

Parameters:
p - the prefix to search
Returns:
the range [i, j) of records sharing the common prefix p
Throws:
IOException