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 TypeMethodDescriptionvoid
addTuple
(long[] buffer) void
addTuple
(TupleBuffer buffer) boolean
checkSanity
(String message, boolean shadow) check sanity of indexvoid
clear()
clear indexvoid
close()
close the index fileboolean
containsTuple
(long[] values) returns true if there exist matching valuesboolean
containsTuple
(TupleBuffer values) returns true if there exist matching valuesvoid
createIndex
(String logDir) void
delete()
delete the index fileelements()
void
flush()
flush the index fileint[]
Returns the indexed positionslong
getNumberOfMatchingTuples
(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.boolean
boolean
is it a full index, i.e. all arguments are indexedvoid
open()
void
removeTuple
(long[] tuple) void
removeTuple
(TupleBuffer tuple) boolean
replaceNotIndexedValues
(long[] oldTuple, long[] newTuple) Modify tuple in index at non indexed positions.boolean
replaceNotIndexedValues
(TupleBuffer oldTuple, TupleBuffer newTuple) Modify tuple in index at non indexed positions.boolean
searchForRecord
(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 tuplesvoid
long
size()
returns the number of indexed tupleslong
return number of bytes used in main memory.toString()
void
void
void
-
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:
IOException
EDBException
-
checkSanity
check sanity of index- Returns:
- Throws:
IOException
-
flush
flush the index file- Throws:
IOException
EDBException
-
sizeInBytes
public long sizeInBytes()return number of bytes used in main memory. Used for cache management- Specified by:
sizeInBytes
in 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:
IOException
EDBException
-
createIndex
- Throws:
IOException
EDBException
-
transactionCommit
- Throws:
IOException
EDBException
-
transactionRollback
- Throws:
IOException
-
transactionBegin
- Throws:
IOException
-
addTuple
- Throws:
IOException
EDBException
-
addTuple
- Throws:
IOException
EDBException
-
removeTuple
- Throws:
IOException
EDBException
-
removeTuple
- Throws:
IOException
EDBException
-
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:
IOException
EDBException
-
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:
IOException
EDBException
-
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
- Throws:
IOException
-
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
- Throws:
IOException
-
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
- Throws:
IOException
-
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
- Throws:
IOException
-
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
- Throws:
IOException
-
selectMatchingTuples
Description copied from interface:Index
returns an enumerator for matching tuples reuse tuple enumerator- Specified by:
selectMatchingTuples
in interfaceIndex
- Returns:
- Throws:
IOException
-
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:
IOException
-
getIndexedPositions
public int[] getIndexedPositions()Description copied from interface:Index
Returns the indexed positions- Specified by:
getIndexedPositions
in interfaceIndex
- Returns:
- the indexed positions
-
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
- Throws:
IOException
-
elements
-
size
public long size()Description copied from interface:Index
returns the number of indexed tuples -
setPersistentRelation
-
isEmptyIndex
public boolean isEmptyIndex()
-