Class AVLTree

java.lang.Object
com.semedy.reasoner.edb.ramstore.AVLTree
All Implemented Interfaces:
Index, SortedIndex, MainMemoryIndex

public class AVLTree extends Object implements SortedIndex, MainMemoryIndex
  • Constructor Details

    • AVLTree

      public AVLTree(int[] indexedPositions, int arity, TupleStore tupleStore, boolean duplicates, ReasoningMonitor monitor)
      avl index used for merge join of tuples
      Parameters:
      indexedPositions - , the indexed positions in a tuple
      arity - , arity of tuples
      tupleStore - , store for tuples
      monitor - , reasoning monitor
  • Method Details

    • sizeInBytes

      public long sizeInBytes()
      Description copied from interface: Index
      Returns size in bytes used in main memory. Used for cache management
      Specified by:
      sizeInBytes in interface Index
      Returns:
    • insert

      public boolean insert(int x) throws IOException
      Throws:
      IOException
    • delete

      public boolean delete(int x)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • verifyTree

      public void verifyTree()
      Checks the AVL tree for correctness. This method will throw an IllegalStateException if the check fails.
    • verifyTree

      public int verifyTree(int node)
    • isEmpty

      public boolean isEmpty()
    • addTuple

      public boolean addTuple(int element) throws IOException
      Description copied from interface: MainMemoryIndex
      additional add method for main memory indices
      Specified by:
      addTuple in interface MainMemoryIndex
      Returns:
      Throws:
      IOException
    • removeTuple

      public boolean removeTuple(int element)
      Description copied from interface: MainMemoryIndex
      additional remove method for main memory indices
      Specified by:
      removeTuple in interface MainMemoryIndex
      Returns:
    • getIndexedPositions

      public int[] getIndexedPositions()
      Description copied from interface: Index
      Returns the indexed positions
      Specified by:
      getIndexedPositions in interface Index
      Returns:
      the indexed positions
    • selectMatchingTuples

      public TupleEnumerator selectMatchingTuples(long[] values)
      Description copied from interface: Index
      returns an enumerator for matching tuples
      Specified by:
      selectMatchingTuples in interface Index
      Parameters:
      values - , values for indexed positions
      Returns:
      enumerator for matching tuples
    • containsTuple

      public boolean containsTuple(long[] values)
      Description copied from interface: Index
      returns true if there exist matching values
      Specified by:
      containsTuple in interface Index
      Parameters:
      values - , values for indexed positions
      Returns:
      boolean, true if there exist matching values
    • containsTuple

      public boolean containsTuple(TupleBuffer values)
      Description copied from interface: Index
      returns true if there exist matching values
      Specified by:
      containsTuple in interface Index
      Parameters:
      values - , values for indexed positions
      Returns:
      boolean, true if there exist matching values
    • containsTuple

      public boolean containsTuple(int values)
      Description copied from interface: MainMemoryIndex
      contains method for main memory indices
      Specified by:
      containsTuple in interface MainMemoryIndex
      Returns:
    • selectMatchingTuples

      public TupleEnumerator selectMatchingTuples(long[] values, TupleEnumerator it)
      Description copied from interface: Index
      returns an enumerator for matching tuples reuse tuple enumerator
      Specified by:
      selectMatchingTuples in interface Index
      Returns:
    • selectMatchingTuples

      public TupleEnumerator selectMatchingTuples(TupleBuffer values)
      Description copied from interface: Index
      returns an enumerator for matching tuples
      Specified by:
      selectMatchingTuples in interface Index
      Parameters:
      values - , values for indexed positions
      Returns:
      enumerator for matching tuples
    • getNumberOfMatchingTuples

      public long getNumberOfMatchingTuples(long[] values) throws IOException, EDBException
      Description copied from interface: Index
      returns the number of matching tuples
      Specified by:
      getNumberOfMatchingTuples in interface Index
      Parameters:
      values - , values for indexed positions
      Returns:
      number of matching tuples
      Throws:
      EDBException
      IOException
    • size

      public long size()
      Description copied from interface: Index
      returns the number of indexed tuples
      Specified by:
      size in interface Index
      Returns:
    • clear

      public void clear()
    • indexedValues

      public SortedIndexEnumerator indexedValues()
      Description copied from interface: SortedIndex
      Return an iterator for index values.
      Note not tuples are enumerated but index values in sorted order
      Specified by:
      indexedValues in interface SortedIndex
    • indexedValues

      public SortedIndexEnumerator indexedValues(TupleBufferComparator comp)
      Description copied from interface: SortedIndex
      Return an iterator for index values.
      Note not tuples are enumerated but index values in sorted order
      Specified by:
      indexedValues in interface SortedIndex
    • elements

      public TupleEnumerator elements()
      Description copied from interface: MainMemoryIndex
      iterator for all elements
      Specified by:
      elements in interface MainMemoryIndex
      Returns:
    • getTupleAddress

      public int getTupleAddress(int tuple)
      Description copied from interface: MainMemoryIndex
      get the address of a tuple
      Specified by:
      getTupleAddress in interface MainMemoryIndex
      Returns:
    • getTupleAddress

      public int getTupleAddress(long[] tuple)
      Description copied from interface: MainMemoryIndex
      get the address of a tuple
      Specified by:
      getTupleAddress in interface MainMemoryIndex
      Returns: