Class DiskValues

java.lang.Object
org.basex.index.value.ValueIndex
org.basex.index.value.DiskValues
All Implemented Interfaces:
Index
Direct Known Subclasses:
UpdatableDiskValues

public class DiskValues extends ValueIndex
This class provides access to attribute values and text contents stored on disk. The data structure is described in the DiskValuesBuilder class.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Summary

    Fields inherited from class org.basex.index.value.ValueIndex

    data, type
  • Constructor Summary

    Constructors
    Constructor
    Description
    DiskValues(Data data, IndexType type)
    Constructor, initializing the index structure.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(ValueCache values)
    Add entries to the index.
    final void
    Closes the index.
    Computes costs for performing the specified search.
    void
    Deletes entries from the index.
    final boolean
    Drops the index.
    Returns all entries that match the specified token.
    final void
    Flushes the buffered data.
    protected final int
    get(byte[] key)
    Binary search for key in the idxr reference file.
    protected final int
    get(byte[] key, int first, int last)
    Binary search for key in the #idxr reference file.
    final byte[]
    info(MainOptions options)
    Returns information on the index structure.
    iter(IndexSearch search)
    Returns an iterator for the index results.
    protected int
    pre(int id)
    Returns the pre value for the specified id.
    protected IntList
    pres(int sz, long offset)
    Iterator method.
    final int
    Returns the number of index entries.
     
    final String
    toString(boolean all)
    Returns a string representation of the index structure.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DiskValues

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

    • info

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

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

      public final 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 final 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
    • drop

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

      public final void close()
      Description copied from interface: Index
      Closes the index.
    • 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
    • entries

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

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

      protected int pre(int id)
      Returns the pre value for the specified id.
      Parameters:
      id - id value
      Returns:
      pre value
    • get

      protected final int get(byte[] key)
      Binary search for key in the idxr reference file.

      Important: This method is thread-safe.

      Parameters:
      key - token to be found
      Returns:
      index of the key, or (-(insertion point) - 1)
    • get

      protected final int get(byte[] key, int first, int last)
      Binary search for key in the #idxr reference file.

      Important: This method is thread-safe.

      Parameters:
      key - token to be found
      first - begin of the search interval (inclusive)
      last - end of the search interval (exclusive)
      Returns:
      index of the key, or (-(insertion point) - 1)
    • pres

      protected IntList pres(int sz, long offset)
      Iterator method.

      Important: This method is thread-safe.

      Parameters:
      sz - number of values
      offset - offset
      Returns:
      sorted pre values
    • toString

      public final String toString(boolean all)
      Returns a string representation of the index structure.
      Parameters:
      all - include database contents in the representation. During updates, database lookups must be avoided, as the data structures will be inconsistent
      Returns:
      string
    • toString

      public String toString()
      Overrides:
      toString in class Object