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
ConstructorDescriptionAVLTree
(int[] indexedPositions, int arity, TupleStore tupleStore, boolean duplicates, ReasoningMonitor monitor) avl index used for merge join of tuples -
Method Summary
Modifier and TypeMethodDescriptionboolean
addTuple
(int element) additional add method for main memory indicesvoid
clear()
boolean
containsTuple
(int values) contains method for main memory indicesboolean
containsTuple
(long[] values) returns true if there exist matching valuesboolean
containsTuple
(TupleBuffer values) returns true if there exist matching valuesboolean
delete
(int x) elements()
iterator for all elementsint[]
Returns the indexed positionslong
getNumberOfMatchingTuples
(long[] values) returns the number of matching tuplesint
getTupleAddress
(int tuple) get the address of a tupleint
getTupleAddress
(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.boolean
insert
(int x) boolean
isEmpty()
boolean
removeTuple
(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 tupleslong
size()
returns the number of indexed tupleslong
Returns size in bytes used in main memory.toString()
void
Checks the AVL tree for correctness.int
verifyTree
(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:Index
Returns size in bytes used in main memory. Used for cache management- Specified by:
sizeInBytes
in 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 anIllegalStateException
if the check fails. -
verifyTree
public int verifyTree(int node) -
isEmpty
public boolean isEmpty() -
addTuple
Description copied from interface:MainMemoryIndex
additional add method for main memory indices- Specified by:
addTuple
in interfaceMainMemoryIndex
- 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 interfaceMainMemoryIndex
- Returns:
-
getIndexedPositions
public int[] getIndexedPositions()Description copied from interface:Index
Returns the indexed positions- Specified by:
getIndexedPositions
in interfaceIndex
- Returns:
- the indexed positions
-
selectMatchingTuples
Description copied from interface:Index
returns an enumerator for matching tuples- Specified by:
selectMatchingTuples
in interfaceIndex
- 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 interfaceIndex
- Parameters:
values
- , values for indexed positions- Returns:
- boolean, true if there exist matching values
-
containsTuple
Description copied from interface:Index
returns true if there exist matching values- Specified by:
containsTuple
in 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:MainMemoryIndex
contains method for main memory indices- Specified by:
containsTuple
in interfaceMainMemoryIndex
- Returns:
-
selectMatchingTuples
Description copied from interface:Index
returns an enumerator for matching tuples reuse tuple enumerator- Specified by:
selectMatchingTuples
in interfaceIndex
- Returns:
-
selectMatchingTuples
Description copied from interface:Index
returns an enumerator for matching tuples- Specified by:
selectMatchingTuples
in interfaceIndex
- Parameters:
values
- , values for indexed positions- Returns:
- enumerator for matching tuples
-
getNumberOfMatchingTuples
Description copied from interface:Index
returns the number of matching tuples- Specified by:
getNumberOfMatchingTuples
in interfaceIndex
- 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 -
clear
public void clear() -
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 interfaceSortedIndex
-
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 interfaceSortedIndex
-
elements
Description copied from interface:MainMemoryIndex
iterator for all elements- Specified by:
elements
in interfaceMainMemoryIndex
- Returns:
-
getTupleAddress
public int getTupleAddress(int tuple) Description copied from interface:MainMemoryIndex
get the address of a tuple- Specified by:
getTupleAddress
in interfaceMainMemoryIndex
- Returns:
-
getTupleAddress
public int getTupleAddress(long[] tuple) Description copied from interface:MainMemoryIndex
get the address of a tuple- Specified by:
getTupleAddress
in interfaceMainMemoryIndex
- Returns:
-