Package com.illumon.iris.db.v2.utils
Class GroupedRedirectionIndex
java.lang.Object
com.illumon.iris.db.v2.utils.GroupedRedirectionIndex
- All Implemented Interfaces:
RedirectionIndex
public class GroupedRedirectionIndex extends Object implements RedirectionIndex
The GroupedRedirectionIndex is intended for situations where you have several Indices that represent contiguous rows
of your output table and a flat output index.
When sorting a table by it's grouping column, instead of using a large contiguous RedirectionIndex, we simply store
the indices for each group and the accumulated cardinality. We then binary search in the accumulated cardinality
for a given key; and fetch the corresponding offset from that group's Index.
This RedirectionIndex does not support mutation.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.utils.RedirectionIndex
RedirectionIndex.Factory, RedirectionIndex.FillContext
-
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.utils.RedirectionIndex
DEFAULT_FILL_INSTANCE, EMPTY_CONTEXT, FACTORY, USE_LOCK_FREE_IMPL_PROPERTY_NAME
-
Constructor Summary
Constructors Constructor Description GroupedRedirectionIndex(long size, long[] groupSizes, ReadOnlyIndex[] groups)
-
Method Summary
Modifier and Type Method Description void
ensureUpdateCapacity(int capacity)
Ensure that there is enough space to perform at least 'capacity' updates.void
fillChunk(RedirectionIndex.FillContext fillContext, WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, OrderedKeys keysToMap)
Lookup each element in OrderedKeys and write the result to mappedKeysOutvoid
fillPrevChunk(RedirectionIndex.FillContext fillContext, WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, OrderedKeys keysToMap)
long
get(long key)
Get the current inner mapping for the specified key.long
getPrev(long key)
Get the previous mapping for the specified keylong
put(long key, long index)
Insert a mapping from key to inner index into this redirection.long
remove(long leftIndex)
Remove the specified mapping from the redirectionvoid
startTrackingPrevValues()
Indicate to the implementation that it should track changes with previous values for ticking updates.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.v2.utils.RedirectionIndex
applyShift, ascendingMapping, fillChunkUnordered, fillFromChunk, makeFillContext, makeFillFromContext, putVoid, removeAll, removeAllUnordered, removeVoid
-
Constructor Details
-
Method Details
-
get
public long get(long key)Description copied from interface:RedirectionIndex
Get the current inner mapping for the specified key.- Specified by:
get
in interfaceRedirectionIndex
- Parameters:
key
- the key to find a mapping for.- Returns:
- the current mapping for the specified key, or
ReadOnlyIndex.NULL_KEY
if there was none.
-
getPrev
public long getPrev(long key)Description copied from interface:RedirectionIndex
Get the previous mapping for the specified key- Specified by:
getPrev
in interfaceRedirectionIndex
- Parameters:
key
- the key to locate a mapping for- Returns:
- the mapped value or
ReadOnlyIndex.NULL_KEY
if none existed.
-
fillChunk
public void fillChunk(@NotNull RedirectionIndex.FillContext fillContext, @NotNull WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, @NotNull OrderedKeys keysToMap)Description copied from interface:RedirectionIndex
Lookup each element in OrderedKeys and write the result to mappedKeysOut- Specified by:
fillChunk
in interfaceRedirectionIndex
- Parameters:
fillContext
- the RedirectionIndex FillContextmappedKeysOut
- the result chunkkeysToMap
- the keys to lookup in this redirection index
-
fillPrevChunk
public void fillPrevChunk(@NotNull RedirectionIndex.FillContext fillContext, @NotNull WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, @NotNull OrderedKeys keysToMap)- Specified by:
fillPrevChunk
in interfaceRedirectionIndex
-
remove
public long remove(long leftIndex)Description copied from interface:RedirectionIndex
Remove the specified mapping from the redirection- Specified by:
remove
in interfaceRedirectionIndex
- Parameters:
leftIndex
- the index to unmap.- Returns:
- the previous mapping or
ReadOnlyIndex.NULL_KEY
if none existed.
-
put
public long put(long key, long index)Description copied from interface:RedirectionIndex
Insert a mapping from key to inner index into this redirection.- Specified by:
put
in interfaceRedirectionIndex
- Parameters:
key
- the key to be mappedindex
- the index the key should be mapped to on the inner source- Returns:
- the previous mapping for the specified key, or
ReadOnlyIndex.NULL_KEY
if there was none.
-
ensureUpdateCapacity
public void ensureUpdateCapacity(int capacity)Description copied from interface:RedirectionIndex
Ensure that there is enough space to perform at least 'capacity' updates.- Specified by:
ensureUpdateCapacity
in interfaceRedirectionIndex
- Parameters:
capacity
- the capacity of the update
-
startTrackingPrevValues
public void startTrackingPrevValues()Description copied from interface:RedirectionIndex
Indicate to the implementation that it should track changes with previous values for ticking updates.- Specified by:
startTrackingPrevValues
in interfaceRedirectionIndex
-