Package com.illumon.iris.db.v2.utils
Interface RedirectionIndex
- All Known Subinterfaces:
SingleValueRedirectionIndex
- All Known Implementing Classes:
ContiguousRedirectionIndexImpl
,GroupedRedirectionIndex
,IntColumnSourceRedirectionIndex
,InverseIndexRedirectionIndexImpl
,LongColumnSourceRedirectionIndex
,RedirectionIndexLockFreeImpl
,StaticSingleValueRedirectionIndexImpl
,TickingSingleValueRedirectionIndexImpl
,WrappedIndexRedirectionIndexImpl
public interface RedirectionIndex
A RedirectionIndex can be in one of two states: tracking prev values or not. The typical lifecycle looks like this:
- A RedirectionIndex is created with an initial map, but not tracking prev values. In this state, get() and getPrev() behave identically; put() and remove() affect current values but do no "prev value" tracking.
- Prev value tracking begins when the caller calls startTrackingPrevValues(). Immediately after this call, the data is logically "forked": getPrev() will still refer to the same set of entries as before; this set will be frozen until the end of the generation.
- Additionally, a terminal listener will be registered so that the prev map will be updated at the end of the generation.
- Meanwhile, get(), put(), and remove() will logically refer to a fork of that map: it will initially have the same entries as prev, but it will diverge over time as the caller does put() and remove() operations.
- At the end of the generation (when the TerminalListener runs), the prev set is (logically) discarded, prev gets current, and current becomes the new fork of the map.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
RedirectionIndex.Factory
static interface
RedirectionIndex.FillContext
-
Field Summary
Fields Modifier and Type Field Description static RedirectionIndex.FillContext
DEFAULT_FILL_INSTANCE
static WritableChunkSink.FillFromContext
EMPTY_CONTEXT
static RedirectionIndex.Factory
FACTORY
static String
USE_LOCK_FREE_IMPL_PROPERTY_NAME
-
Method Summary
Modifier and Type Method Description default void
applyShift(ReadOnlyIndex tableIndex, IndexShiftData shiftData)
Update this RedirectionIndex according to the IndexShiftData.default boolean
ascendingMapping()
If this RedirectionIndex is guaranteed to map outer keys in ascending order to inner keys in ascending order; then return true; all other redirections must return false.void
ensureUpdateCapacity(int capacity)
Ensure that there is enough space to perform at least 'capacity' updates.default void
fillChunk(RedirectionIndex.FillContext fillContext, WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, OrderedKeys keysToMap)
Lookup each element in OrderedKeys and write the result to mappedKeysOutdefault void
fillChunkUnordered(RedirectionIndex.FillContext fillContext, WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, LongChunk<Attributes.KeyIndices> keysToMap)
default void
fillFromChunk(WritableChunkSink.FillFromContext context, Chunk<Attributes.Values> src, OrderedKeys orderedKeys)
Our default, inefficient, implementation.default void
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 keydefault RedirectionIndex.FillContext
makeFillContext(int chunkCapacity, SharedContext sharedContext)
default WritableChunkSink.FillFromContext
makeFillFromContext(int chunkCapacity)
Provide a default, emptyWritableChunkSink.FillFromContext
for use with our defaultWritableSource.fillFromChunk(com.illumon.iris.db.v2.sources.WritableChunkSink.FillFromContext, com.illumon.iris.db.v2.sources.chunk.Chunk<? extends com.illumon.iris.db.v2.sources.chunk.Attributes.Values>, com.illumon.iris.db.v2.utils.OrderedKeys)
.long
put(long key, long index)
Insert a mapping from key to inner index into this redirection.default void
putVoid(long key, long index)
Like put, but we do not care about a return value.long
remove(long key)
Remove the specified mapping from the redirectiondefault void
removeAll(OrderedKeys keys)
Remove all the keys contained in theOrderedKeys
from this redirectiondefault void
removeAllUnordered(LongChunk<Attributes.KeyIndices> keys)
default void
removeVoid(long key)
Like remove, but we do not care about a return value.void
startTrackingPrevValues()
Indicate to the implementation that it should track changes with previous values for ticking updates.
-
Field Details
-
Method Details
-
put
long put(long key, long index)Insert a mapping from key to inner index into this redirection.- 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.
-
get
long get(long key)Get the current inner mapping for the specified key.- 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.
-
ensureUpdateCapacity
void ensureUpdateCapacity(int capacity)Ensure that there is enough space to perform at least 'capacity' updates.- Parameters:
capacity
- the capacity of the update
-
makeFillContext
default RedirectionIndex.FillContext makeFillContext(int chunkCapacity, SharedContext sharedContext) -
fillChunk
default void fillChunk(@NotNull RedirectionIndex.FillContext fillContext, @NotNull WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, @NotNull OrderedKeys keysToMap)Lookup each element in OrderedKeys and write the result to mappedKeysOut- Parameters:
fillContext
- the RedirectionIndex FillContextmappedKeysOut
- the result chunkkeysToMap
- the keys to lookup in this redirection index
-
fillChunkUnordered
default void fillChunkUnordered(@NotNull RedirectionIndex.FillContext fillContext, @NotNull WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, @NotNull LongChunk<Attributes.KeyIndices> keysToMap) -
fillPrevChunk
default void fillPrevChunk(@NotNull RedirectionIndex.FillContext fillContext, @NotNull WritableLongChunk<Attributes.KeyIndices> mappedKeysOut, @NotNull OrderedKeys keysToMap) -
getPrev
long getPrev(long key)Get the previous mapping for the specified key- Parameters:
key
- the key to locate a mapping for- Returns:
- the mapped value or
ReadOnlyIndex.NULL_KEY
if none existed.
-
remove
long remove(long key)Remove the specified mapping from the redirection- Parameters:
key
- the index to unmap.- Returns:
- the previous mapping or
ReadOnlyIndex.NULL_KEY
if none existed.
-
startTrackingPrevValues
void startTrackingPrevValues()Indicate to the implementation that it should track changes with previous values for ticking updates. -
putVoid
default void putVoid(long key, long index)Like put, but we do not care about a return value.- Parameters:
key
- the key to putindex
- the inner value to insert into the redirection index
-
removeVoid
default void removeVoid(long key)Like remove, but we do not care about a return value.- Parameters:
key
- the key to remove
-
removeAll
Remove all the keys contained in theOrderedKeys
from this redirection- Parameters:
keys
- the keys to remove.
-
removeAllUnordered
-
ascendingMapping
default boolean ascendingMapping()If this RedirectionIndex is guaranteed to map outer keys in ascending order to inner keys in ascending order; then return true; all other redirections must return false.- Returns:
- if our output maintains ascending order
-
makeFillFromContext
Provide a default, emptyWritableChunkSink.FillFromContext
for use with our defaultWritableSource.fillFromChunk(com.illumon.iris.db.v2.sources.WritableChunkSink.FillFromContext, com.illumon.iris.db.v2.sources.chunk.Chunk<? extends com.illumon.iris.db.v2.sources.chunk.Attributes.Values>, com.illumon.iris.db.v2.utils.OrderedKeys)
. -
fillFromChunk
default void fillFromChunk(@NotNull WritableChunkSink.FillFromContext context, @NotNull Chunk<Attributes.Values> src, @NotNull OrderedKeys orderedKeys)Our default, inefficient, implementation. Inheritors who care should provide a better implementation. -
applyShift
Update this RedirectionIndex according to the IndexShiftData.- Parameters:
tableIndex
- an Index to filter which rows should be shiftedshiftData
- the IndexShiftData for this update
-