Package com.illumon.iris.db.v2.ssa
Class DoubleReverseSegmentedSortedArray
java.lang.Object
com.illumon.iris.db.v2.ssa.DoubleReverseSegmentedSortedArray
- All Implemented Interfaces:
LongSizedDataStructure,SegmentedSortedArray
For keeping track of incremental states of sorted values, we would ideally like to hold them in an Array or a Chunk;
with parallel index keys. However, if we just put them in an array we can not insert or remove values without
unnecessarily shifting everything.
The segmented array allows us to either insert or remove elements and only shift values in a "leaf" block and
possibly a "directory" block. It can be thought of as similar to a single-level b+ tree with only keys.
We must be totally ordered, which is accomplished by sorting on the double values, and then on the corresponding
index key.
-
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.ssa.SegmentedSortedArray
SEGMENTED_SORTED_ARRAY_VALIDATION -
Constructor Summary
ConstructorsConstructorDescriptionDoubleReverseSegmentedSortedArray(int leafSize) Create a DoubleReverseSegmentedSortedArray with the given leafSize. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyShift(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> keyChunk, long shiftDelta) voidapplyShiftReverse(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> keyChunk, long shiftDelta) voidforAllKeys(LongConsumer longConsumer) Call the longConsumer for each of the long index keys in this SegmentedSortedArray.longgetFirst()longgetLast()intvoidinsert(Chunk<? extends Attributes.Any> valuesToInsert, LongChunk<? extends Attributes.KeyIndices> indicesToInsert) Insert new valuesToInsert into this SSA.<T extends Attributes.Any>
intinsertAndGetNextValue(Chunk<T> valuesToInsert, LongChunk<? extends Attributes.KeyIndices> indicesToInsert, WritableChunk<T> nextValue) booleanvoidremove(Chunk<? extends Attributes.Any> valuesToRemove, LongChunk<? extends Attributes.KeyIndices> indicesToRemove) Remove valuesToRemove from this SSA.voidremoveAndGetPrior(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> indicesToRemove, WritableLongChunk<? extends Attributes.KeyIndices> priorRedirections) Remove the values and indices referenced in stampChunk and indicesToRemove.longsize()The size of this data structure.voidvalidate()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.illumon.iris.db.util.LongSizedDataStructure
intSize, intSize
-
Constructor Details
-
DoubleReverseSegmentedSortedArray
public DoubleReverseSegmentedSortedArray(int leafSize) Create a DoubleReverseSegmentedSortedArray with the given leafSize.- Parameters:
leafSize- the maximumSize for any leaf
-
-
Method Details
-
insert
public void insert(Chunk<? extends Attributes.Any> valuesToInsert, LongChunk<? extends Attributes.KeyIndices> indicesToInsert) Description copied from interface:SegmentedSortedArrayInsert new valuesToInsert into this SSA. The valuesToInsert to insert must be sorted.- Specified by:
insertin interfaceSegmentedSortedArray- Parameters:
valuesToInsert- the valuesToInsert to insertindicesToInsert- the corresponding indicesToInsert
-
insertAndGetNextValue
public <T extends Attributes.Any> int insertAndGetNextValue(Chunk<T> valuesToInsert, LongChunk<? extends Attributes.KeyIndices> indicesToInsert, WritableChunk<T> nextValue) - Specified by:
insertAndGetNextValuein interfaceSegmentedSortedArray
-
remove
public void remove(Chunk<? extends Attributes.Any> valuesToRemove, LongChunk<? extends Attributes.KeyIndices> indicesToRemove) Description copied from interface:SegmentedSortedArrayRemove valuesToRemove from this SSA. The valuesToRemove to remove must be sorted.- Specified by:
removein interfaceSegmentedSortedArray- Parameters:
valuesToRemove- the valuesToRemove to removeindicesToRemove- the corresponding indices
-
removeAndGetPrior
public void removeAndGetPrior(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> indicesToRemove, WritableLongChunk<? extends Attributes.KeyIndices> priorRedirections) Description copied from interface:SegmentedSortedArrayRemove the values and indices referenced in stampChunk and indicesToRemove. Fill priorRedirections with the redirection value immediately preceding the removed value.- Specified by:
removeAndGetPriorin interfaceSegmentedSortedArray- Parameters:
stampChunk- the values to removeindicesToRemove- the indices (parallel to the values)priorRedirections- the output prior redirections (parallel to valeus/indices)
-
applyShift
public void applyShift(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> keyChunk, long shiftDelta) - Specified by:
applyShiftin interfaceSegmentedSortedArray
-
applyShiftReverse
public void applyShiftReverse(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> keyChunk, long shiftDelta) - Specified by:
applyShiftReversein interfaceSegmentedSortedArray
-
validate
-
forAllKeys
Description copied from interface:SegmentedSortedArrayCall the longConsumer for each of the long index keys in this SegmentedSortedArray.- Specified by:
forAllKeysin interfaceSegmentedSortedArray- Parameters:
longConsumer- the long consumer to call
-
size
public long size()Description copied from interface:LongSizedDataStructureThe size of this data structure.- Specified by:
sizein interfaceLongSizedDataStructure- Returns:
- The size
-
getNodeSize
public int getNodeSize()- Specified by:
getNodeSizein interfaceSegmentedSortedArray
-
isReversed
public boolean isReversed()- Specified by:
isReversedin interfaceSegmentedSortedArray
-
getFirst
public long getFirst()- Specified by:
getFirstin interfaceSegmentedSortedArray- Returns:
- the first index in this SSA, Index.NULL_KEY when empty.
-
getLast
public long getLast()- Specified by:
getLastin interfaceSegmentedSortedArray- Returns:
- the last index in this SSA, Index.NULL_KEY when empty.
-
makeChecker
- Specified by:
makeCheckerin interfaceSegmentedSortedArray
-