Class FTIndex

All Implemented Interfaces:
Index

public final class FTIndex extends ValueIndex

This class provides access to a fuzzy full-text index structure stored on disk. Each token has an entry in sizes, saving its length and a pointer on ftdata, where to find the token and its ftdata. The three database index files start with the prefix DataText.DATAFTX and have the following format:

  • File x contains an entry for each token length. Structure: [l, p] .... l is the length of a token [byte]. p is the pointer of the first token with length l [int].
  • File y contains the tokens and references. Structure: [t0, t1, ... tl, z, s] t0, t1, ... tl-1 is the token [byte[l]] z is the pointer on the data entries of the token [long] s is the number of pre values, saved in data [int]
  • File z contains the id/pos references. The values are ordered, but not distinct: pre1/pos1, pre2/pos2, pre3/pos3, ... [Num]
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • FTIndex

      public FTIndex(Data data) throws IOException
      Constructor, initializing the index structure.
      Parameters:
      data - data reference
      Throws:
      IOException - I/O Exception
  • Method Details

    • costs

      public IndexCosts costs(IndexSearch search)
      Description copied from interface: Index
      Computes costs for performing the specified search. An integer is returned:
      • A negative value indicates that index access is not possible.
      • A value of zero indicates that no results will be returned.
      • A small value indicates that index access is fast.
      Smaller values are better, a value of zero indicates that no results will be returned.
      Parameters:
      search - index search definition
      Returns:
      cost estimation
    • iter

      public IndexIterator iter(IndexSearch search)
      Description copied from interface: Index
      Returns an iterator for the index results.
      Parameters:
      search - index search definition
      Returns:
      sorted pre values for the token
    • entries

      public EntryIterator entries(IndexEntries entries)
      Description copied from interface: Index
      Returns all entries that match the specified token.
      Parameters:
      entries - index entries
      Returns:
      entries
    • info

      public byte[] info(MainOptions options)
      Description copied from interface: Index
      Returns information on the index structure.
      Parameters:
      options - main options
      Returns:
      info
    • drop

      public boolean drop()
      Description copied from interface: Index
      Drops the index. Also returns true if the index does not exist.
      Returns:
      success flag
    • close

      public void close()
      Description copied from interface: Index
      Closes the index.
    • size

      public int size()
      Description copied from class: ValueIndex
      Returns the number of index entries.
      Specified by:
      size in class ValueIndex
      Returns:
      number of index entries
    • add

      public void add(ValueCache values)
      Description copied from class: ValueIndex
      Add entries to the index.
      Specified by:
      add in class ValueIndex
      Parameters:
      values - value cache with [key, id-list] pairs
    • delete

      public void delete(ValueCache values)
      Description copied from class: ValueIndex
      Deletes entries from the index.
      Specified by:
      delete in class ValueIndex
      Parameters:
      values - value cache with [key, id-list] pairs
    • flush

      public void flush()
      Description copied from class: ValueIndex
      Flushes the buffered data.
      Specified by:
      flush in class ValueIndex