Class PersistentSecondarySortedIndex
java.lang.Object
com.semedy.reasoner.edb.persistentstore.PersistentSecondarySortedIndex
- All Implemented Interfaces:
Index,SortedIndex
Container for a persistent sorted index
- Author:
- angele
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPersistentSecondarySortedIndex(PersistentRelation persistentTuples, BPlusTree<long[], TupleBuffer> btreelong, FileName name, boolean compress) PersistentSecondarySortedIndex(PersistentRelation persistentTuples, BPlusTree<long[], TupleBuffer> btreelong, FileName name, int[] indexedpositions, boolean compress) PersistentSecondarySortedIndex(PersistentRelation persistentTuples, FileName name, boolean compress) PersistentSecondarySortedIndex(PersistentRelation persistentTuples, FileName filename, String filepath, boolean compress) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTuple(long[] buffer) voidaddTuple(TupleBuffer buffer) booleancheckSanity(String message, boolean shadow) check sanity of indexvoidclear()clear indexvoidclose()close the index filebooleancontainsTuple(long[] values) returns true if there exist matching valuesbooleancontainsTuple(TupleBuffer values) returns true if there exist matching valuesvoidcreateIndex(String logDir) voiddelete()delete the index fileelements()voidflush()flush the index fileint[]Returns the indexed positionslonggetNumberOfMatchingTuples(long[] values) returns the number of matching tuplesReturn an iterator for index values.
Note not tuples are enumerated but index values in sorted orderReturn an iterator for index values.booleanbooleanis it a full index, i.e. all arguments are indexedvoidopen()voidremoveTuple(long[] tuple) voidremoveTuple(TupleBuffer tuple) booleanreplaceNotIndexedValues(long[] oldTuple, long[] newTuple) Modify tuple in index at non indexed positions.booleanreplaceNotIndexedValues(TupleBuffer oldTuple, TupleBuffer newTuple) Modify tuple in index at non indexed positions.booleansearchForRecord(long record) selectMatchingTuples(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 tuplesvoidlongsize()returns the number of indexed tupleslongreturn number of bytes used in main memory.toString()voidvoidvoid
-
Field Details
-
_btree
the bplus tree for the index
-
-
Constructor Details
-
PersistentSecondarySortedIndex
public PersistentSecondarySortedIndex(PersistentRelation persistentTuples, FileName name, boolean compress) -
PersistentSecondarySortedIndex
public PersistentSecondarySortedIndex(PersistentRelation persistentTuples, BPlusTree<long[], TupleBuffer> btreelong, FileName name, int[] indexedpositions, boolean compress) -
PersistentSecondarySortedIndex
public PersistentSecondarySortedIndex(PersistentRelation persistentTuples, BPlusTree<long[], TupleBuffer> btreelong, FileName name, boolean compress) -
PersistentSecondarySortedIndex
public PersistentSecondarySortedIndex(PersistentRelation persistentTuples, FileName filename, String filepath, boolean compress)
-
-
Method Details
-
close
close the index file- Throws:
IOExceptionEDBException
-
checkSanity
check sanity of index- Returns:
- Throws:
IOException
-
flush
flush the index file- Throws:
IOExceptionEDBException
-
sizeInBytes
public long sizeInBytes()return number of bytes used in main memory. Used for cache management- Specified by:
sizeInBytesin interfaceIndex- Returns:
-
searchForRecord
- Throws:
IOException
-
delete
delete the index file- Throws:
IOException
-
isFullIndex
public boolean isFullIndex()is it a full index, i.e. all arguments are indexed- Returns:
-
toString
-
clear
public void clear()clear index -
open
- Throws:
IOExceptionEDBException
-
createIndex
- Throws:
IOExceptionEDBException
-
transactionCommit
- Throws:
IOExceptionEDBException
-
transactionRollback
- Throws:
IOException
-
transactionBegin
- Throws:
IOException
-
addTuple
- Throws:
IOExceptionEDBException
-
addTuple
- Throws:
IOExceptionEDBException
-
removeTuple
- Throws:
IOExceptionEDBException
-
removeTuple
- Throws:
IOExceptionEDBException
-
replaceNotIndexedValues
public boolean replaceNotIndexedValues(long[] oldTuple, long[] newTuple) throws IOException, EDBException Modify tuple in index at non indexed positions.
Returns null if there is more than one tuple
matching the index positions.
If there is exactly one tuple it is modified
and the original tuple is returned.
If there is no matching tuple, the
tuple is added and the input tuple is returned.- Parameters:
oldTuple-newTuple-- Returns:
- Throws:
IOExceptionEDBException
-
replaceNotIndexedValues
public boolean replaceNotIndexedValues(TupleBuffer oldTuple, TupleBuffer newTuple) throws IOException, EDBException Modify tuple in index at non indexed positions.
Returns null if there is more than one tuple
matching the index positions.
If there is exactly one tuple it is modified
and the original tuple is returned.
If there is no matching tuple, the
tuple is added and the input tuple is returned.- Parameters:
oldTuple-newTuple-- Returns:
- Throws:
IOExceptionEDBException
-
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- Throws:
IOException
-
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
- Throws:
IOException
-
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
- Throws:
IOException
-
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
- Throws:
IOException
-
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
- Throws:
IOException
-
selectMatchingTuples
Description copied from interface:Indexreturns an enumerator for matching tuples reuse tuple enumerator- Specified by:
selectMatchingTuplesin interfaceIndex- Returns:
- Throws:
IOException
-
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:
IOException
-
getIndexedPositions
public int[] getIndexedPositions()Description copied from interface:IndexReturns the indexed positions- Specified by:
getIndexedPositionsin interfaceIndex- Returns:
- the indexed positions
-
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- Throws:
IOException
-
elements
-
size
public long size()Description copied from interface:Indexreturns the number of indexed tuples -
setPersistentRelation
-
isEmptyIndex
public boolean isEmptyIndex()
-