Package com.illumon.iris.db.v2.ssa
Class NullAwareCharReverseSegmentedSortedArray
java.lang.Object
com.illumon.iris.db.v2.ssa.NullAwareCharReverseSegmentedSortedArray
- All Implemented Interfaces:
LongSizedDataStructure
,SegmentedSortedArray
public final class NullAwareCharReverseSegmentedSortedArray
extends Object
implements 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 char 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
ConstructorsConstructorDescriptionNullAwareCharReverseSegmentedSortedArray
(int leafSize) Create a NullAwareCharReverseSegmentedSortedArray with the given leafSize. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyShift
(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> keyChunk, long shiftDelta) void
applyShiftReverse
(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> keyChunk, long shiftDelta) void
forAllKeys
(LongConsumer longConsumer) Call the longConsumer for each of the long index keys in this SegmentedSortedArray.long
getFirst()
long
getLast()
int
void
insert
(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) boolean
void
remove
(Chunk<? extends Attributes.Any> valuesToRemove, LongChunk<? extends Attributes.KeyIndices> indicesToRemove) Remove valuesToRemove from this SSA.void
removeAndGetPrior
(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.long
size()
The size of this data structure.void
validate()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.util.LongSizedDataStructure
intSize, intSize
-
Constructor Details
-
NullAwareCharReverseSegmentedSortedArray
public NullAwareCharReverseSegmentedSortedArray(int leafSize) Create a NullAwareCharReverseSegmentedSortedArray 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:SegmentedSortedArray
Insert new valuesToInsert into this SSA. The valuesToInsert to insert must be sorted.- Specified by:
insert
in 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:
insertAndGetNextValue
in interfaceSegmentedSortedArray
-
remove
public void remove(Chunk<? extends Attributes.Any> valuesToRemove, LongChunk<? extends Attributes.KeyIndices> indicesToRemove) Description copied from interface:SegmentedSortedArray
Remove valuesToRemove from this SSA. The valuesToRemove to remove must be sorted.- Specified by:
remove
in 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:SegmentedSortedArray
Remove the values and indices referenced in stampChunk and indicesToRemove. Fill priorRedirections with the redirection value immediately preceding the removed value.- Specified by:
removeAndGetPrior
in 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:
applyShift
in interfaceSegmentedSortedArray
-
applyShiftReverse
public void applyShiftReverse(Chunk<? extends Attributes.Any> stampChunk, LongChunk<? extends Attributes.KeyIndices> keyChunk, long shiftDelta) - Specified by:
applyShiftReverse
in interfaceSegmentedSortedArray
-
validate
-
forAllKeys
Description copied from interface:SegmentedSortedArray
Call the longConsumer for each of the long index keys in this SegmentedSortedArray.- Specified by:
forAllKeys
in interfaceSegmentedSortedArray
- Parameters:
longConsumer
- the long consumer to call
-
size
public long size()Description copied from interface:LongSizedDataStructure
The size of this data structure.- Specified by:
size
in interfaceLongSizedDataStructure
- Returns:
- The size
-
getNodeSize
public int getNodeSize()- Specified by:
getNodeSize
in interfaceSegmentedSortedArray
-
isReversed
public boolean isReversed()- Specified by:
isReversed
in interfaceSegmentedSortedArray
-
getFirst
public long getFirst()- Specified by:
getFirst
in interfaceSegmentedSortedArray
- Returns:
- the first index in this SSA, Index.NULL_KEY when empty.
-
getLast
public long getLast()- Specified by:
getLast
in interfaceSegmentedSortedArray
- Returns:
- the last index in this SSA, Index.NULL_KEY when empty.
-
makeChecker
- Specified by:
makeChecker
in interfaceSegmentedSortedArray
-