Class IndexTree

java.lang.Object
org.basex.index.IndexTree

public class IndexTree extends Object
This class indexes keys in a balanced binary tree, including their id values. Iterator methods are available to traverse through the tree.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen, Sebastian Gath
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    Current iterator node.
    protected static final double
    Factor for resize.
    Compressed id values.
    final TokenList
    Keys saved in the tree.
    protected TokenIntMap
    Mapping for using existing tree.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    add(byte[] key, int id, int pos)
    Indexes the specified key and id.
    protected final int
    add(byte[] key, int id, int pos, boolean exist)
    Indexes the specified key and id.
    final void
    Initializes the index iterator.
    final boolean
    Checks if the iterator returns more keys.
    final int
    Returns the next pointer.
    final int
    Returns the number of entries.
     

    Methods inherited from class java.lang.Object

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

    • FACTOR

      protected static final double FACTOR
      Factor for resize.
      See Also:
    • keys

      public final TokenList keys
      Keys saved in the tree.
    • ids

      public TokenList ids
      Compressed id values.
    • maps

      protected TokenIntMap maps
      Mapping for using existing tree.
    • cn

      protected int cn
      Current iterator node.
  • Constructor Details

    • IndexTree

      public IndexTree(IndexType type)
      Constructor.
      Parameters:
      type - index type
  • Method Details

    • add

      public final void add(byte[] key, int id, int pos)
      Indexes the specified key and id.
      Parameters:
      key - key to be indexed
      id - id to be indexed
      pos - token position (only relevant for token index)
    • add

      protected final int add(byte[] key, int id, int pos, boolean exist)
      Indexes the specified key and id. If the key has already been indexed, its id is appended to the existing array. Otherwise, a new index entry is created.
      Parameters:
      key - key to be indexed
      id - id to be indexed
      pos - token position (only relevant for token index)
      exist - flag for using existing index
      Returns:
      int node
    • size

      public final int size()
      Returns the number of entries.
      Returns:
      number of entries
    • init

      public final void init()
      Initializes the index iterator. will be removed to save memory.
    • more

      public final boolean more()
      Checks if the iterator returns more keys.
      Returns:
      true if more keys exist
    • next

      public final int next()
      Returns the next pointer.
      Returns:
      next pointer
    • toString

      public String toString()
      Overrides:
      toString in class Object