Package com.semedy.reasoner.edb.ramstore
Class AVLTree
java.lang.Object
com.semedy.reasoner.edb.ramstore.AVLTree
- All Implemented Interfaces:
Index,SortedIndex,MainMemoryIndex
-
Constructor Summary
ConstructorsConstructorDescriptionAVLTree(int[] indexedPositions, int arity, TupleStore tupleStore, boolean duplicates, ReasoningMonitor monitor) avl index used for merge join of tuples -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddTuple(int element) additional add method for main memory indicesvoidclear()booleancontainsTuple(int values) contains method for main memory indicesbooleancontainsTuple(long[] values) returns true if there exist matching valuesbooleancontainsTuple(TupleBuffer values) returns true if there exist matching valuesbooleandelete(int x) elements()iterator for all elementsint[]Returns the indexed positionslonggetNumberOfMatchingTuples(long[] values) returns the number of matching tuplesintgetTupleAddress(int tuple) get the address of a tupleintgetTupleAddress(long[] tuple) get the address of a tupleReturn an iterator for index values.
Note not tuples are enumerated but index values in sorted orderReturn an iterator for index values.booleaninsert(int x) booleanisEmpty()booleanremoveTuple(int element) additional remove method for main memory indicesselectMatchingTuples(long[] values) returns an enumerator for matching tuplesselectMatchingTuples(long[] values, TupleEnumerator it) returns an enumerator for matching tuples reuse tuple enumeratorselectMatchingTuples(TupleBuffer values) returns an enumerator for matching tupleslongsize()returns the number of indexed tupleslongReturns size in bytes used in main memory.toString()voidChecks the AVL tree for correctness.intverifyTree(int node)
-
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 tuplearity- , arity of tuplestupleStore- , store for tuplesmonitor- , reasoning monitor
-
-
Method Details
-
sizeInBytes
public long sizeInBytes()Description copied from interface:IndexReturns size in bytes used in main memory. Used for cache management- Specified by:
sizeInBytesin interfaceIndex- Returns:
-
insert
- Throws:
IOException
-
delete
public boolean delete(int x) -
toString
-
verifyTree
public void verifyTree()Checks the AVL tree for correctness. This method will throw anIllegalStateExceptionif the check fails. -
verifyTree
public int verifyTree(int node) -
isEmpty
public boolean isEmpty() -
addTuple
Description copied from interface:MainMemoryIndexadditional add method for main memory indices- Specified by:
addTuplein interfaceMainMemoryIndex- Returns:
- Throws:
IOException
-
removeTuple
public boolean removeTuple(int element) Description copied from interface:MainMemoryIndexadditional remove method for main memory indices- Specified by:
removeTuplein interfaceMainMemoryIndex- Returns:
-
getIndexedPositions
public int[] getIndexedPositions()Description copied from interface:IndexReturns the indexed positions- Specified by:
getIndexedPositionsin interfaceIndex- Returns:
- the indexed positions
-
selectMatchingTuples
Description copied from interface:Indexreturns an enumerator for matching tuples- Specified by:
selectMatchingTuplesin interfaceIndex- Parameters:
values- , values for indexed positions- Returns:
- enumerator for matching tuples
-
containsTuple
public boolean containsTuple(long[] values) Description copied from interface:Indexreturns true if there exist matching values- Specified by:
containsTuplein interfaceIndex- Parameters:
values- , values for indexed positions- Returns:
- boolean, true if there exist matching values
-
containsTuple
Description copied from interface:Indexreturns true if there exist matching values- Specified by:
containsTuplein interfaceIndex- Parameters:
values- , values for indexed positions- Returns:
- boolean, true if there exist matching values
-
containsTuple
public boolean containsTuple(int values) Description copied from interface:MainMemoryIndexcontains method for main memory indices- Specified by:
containsTuplein interfaceMainMemoryIndex- Returns:
-
selectMatchingTuples
Description copied from interface:Indexreturns an enumerator for matching tuples reuse tuple enumerator- Specified by:
selectMatchingTuplesin interfaceIndex- Returns:
-
selectMatchingTuples
Description copied from interface:Indexreturns an enumerator for matching tuples- Specified by:
selectMatchingTuplesin interfaceIndex- Parameters:
values- , values for indexed positions- Returns:
- enumerator for matching tuples
-
getNumberOfMatchingTuples
Description copied from interface:Indexreturns the number of matching tuples- Specified by:
getNumberOfMatchingTuplesin interfaceIndex- Parameters:
values- , values for indexed positions- Returns:
- number of matching tuples
- Throws:
EDBExceptionIOException
-
size
public long size()Description copied from interface:Indexreturns the number of indexed tuples -
clear
public void clear() -
indexedValues
Description copied from interface:SortedIndexReturn an iterator for index values.
Note not tuples are enumerated but index values in sorted order- Specified by:
indexedValuesin interfaceSortedIndex
-
indexedValues
Description copied from interface:SortedIndexReturn an iterator for index values.
Note not tuples are enumerated but index values in sorted order- Specified by:
indexedValuesin interfaceSortedIndex
-
elements
Description copied from interface:MainMemoryIndexiterator for all elements- Specified by:
elementsin interfaceMainMemoryIndex- Returns:
-
getTupleAddress
public int getTupleAddress(int tuple) Description copied from interface:MainMemoryIndexget the address of a tuple- Specified by:
getTupleAddressin interfaceMainMemoryIndex- Returns:
-
getTupleAddress
public int getTupleAddress(long[] tuple) Description copied from interface:MainMemoryIndexget the address of a tuple- Specified by:
getTupleAddressin interfaceMainMemoryIndex- Returns:
-