Class SmartKeySource
- All Implemented Interfaces:
ChunkSource<Attributes.Values>
,ChunkSource.WithPrev<Attributes.Values>
,DefaultChunkSource<Attributes.Values>
,DefaultChunkSource.WithPrev<Attributes.Values>
,FillContextMaker
,GetContextMaker
,ColumnSource<com.fishlib.datastructures.util.SmartKey>
,ColumnSourceGetDefaults.ForObject<com.fishlib.datastructures.util.SmartKey>
,ElementSource<com.fishlib.datastructures.util.SmartKey>
,MutableColumnSource<com.fishlib.datastructures.util.SmartKey>
,MutableColumnSourceGetDefaults.ForObject<com.fishlib.datastructures.util.SmartKey>
,Releasable
,TupleExporter<com.fishlib.datastructures.util.SmartKey>
,TupleSource<com.fishlib.datastructures.util.SmartKey>
,Serializable
public final class SmartKeySource extends AbstractColumnSource<com.fishlib.datastructures.util.SmartKey> implements TupleSource<com.fishlib.datastructures.util.SmartKey>, MutableColumnSourceGetDefaults.ForObject<com.fishlib.datastructures.util.SmartKey>
ColumnSource
that produces key column values as SmartKey
s from multiple ColumnSource
s.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.sources.AbstractColumnSource
AbstractColumnSource.DefaultedImmutable<DATA_TYPE>, AbstractColumnSource.DefaultedMutable<DATA_TYPE>, AbstractColumnSource.IsSerializable
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource
ChunkSource.WithPrev<ATTR extends Attributes.Any>
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource
DefaultChunkSource.SupportsContiguousGet<ATTR extends Attributes.Any>, DefaultChunkSource.WithPrev<ATTR extends Attributes.Any>
-
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource
DEFAULT_FILL_INSTANCE, ZERO_LENGTH_CHUNK_SOURCE_ARRAY
Fields inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource.WithPrev
ZERO_LENGTH_CHUNK_SOURCE_WITH_PREV_ARRAY
Fields inherited from interface com.illumon.iris.db.v2.sources.ColumnSource
ZERO_LENGTH_COLUMN_SOURCE_ARRAY
-
Constructor Summary
Constructors Constructor Description SmartKeySource(ColumnSource... columnSources)
Construct a new tuple source backed by the supplied column sources. -
Method Summary
Modifier and Type Method Description com.fishlib.datastructures.util.SmartKey
createPreviousTuple(long indexKey)
Create a tuple for previous key column values at the supplied index key.com.fishlib.datastructures.util.SmartKey
createTuple(long indexKey)
Create a tuple for key column values at the supplied index key.com.fishlib.datastructures.util.SmartKey
createTupleFromValues(Object... values)
Create a tuple for the supplied (boxed) values.Object
exportElement(com.fishlib.datastructures.util.SmartKey smartKey, int elementIndex)
Export a single element from the tuple, identified by its element index, to an Object<ELEMENT_TYPE>
voidexportElement(com.fishlib.datastructures.util.SmartKey smartKey, int elementIndex, WritableSource<ELEMENT_TYPE> writableSource, long destinationIndexKey)
Export a single element from the tuple, identified by its element index, to the destination index key of the supplied writable source.com.fishlib.datastructures.util.SmartKey
exportToExternalKey(com.fishlib.datastructures.util.SmartKey smartKey)
Export this tuple's element list as a key suitable for theTableMap
s resulting fromTable.byExternal(boolean, java.lang.String...)
.void
fillChunk(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> destination, OrderedKeys orderedKeys)
Populates the given destination chunk with data corresponding to the keys from the givenOrderedKeys
.void
fillPrevChunk(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> destination, OrderedKeys orderedKeys)
Populates the given destination chunk with data corresponding to the keys from the givenOrderedKeys
.com.fishlib.datastructures.util.SmartKey
get(long indexKey)
Get the value from the source.Chunk<Attributes.Values>
getChunk(ChunkSource.GetContext context, OrderedKeys orderedKeys)
Returns a chunk of data corresponding to the keys from the givenOrderedKeys
.List<ColumnSource>
getColumnSources()
Get theColumnSource
s backing this tuple source.Class<com.fishlib.datastructures.util.SmartKey>
getNativeType()
com.fishlib.datastructures.util.SmartKey
getPrev(long indexKey)
Get the previous value at the index.Chunk<Attributes.Values>
getPrevChunk(ChunkSource.GetContext context, OrderedKeys orderedKeys)
Returns a chunk of previous data corresponding to the keys from the givenOrderedKeys
.ChunkSource<Attributes.Values>
getPrevSource()
com.illumon.iris.db.v2.tuples.SmartKeySource.FillContext
makeFillContext(int chunkCapacity, SharedContext sharedContext)
Allocate a newChunkSource.FillContext
for filling chunks from thisFillContextMaker
, typically aChunkSource
.com.illumon.iris.db.v2.tuples.SmartKeySource.GetContext
makeGetContext(int chunkCapacity, SharedContext sharedContext)
Allocate a newChunkSource.GetContext
for retrieving chunks from thisGetContextMaker
, typically aChunkSource
.void
startTrackingPrevValues()
ColumnSource implementations that track previous values have the option to not actually start tracking previous values until this method is called.Methods inherited from class com.illumon.iris.db.v2.sources.AbstractColumnSource
allowsReinterpret, defaultFillChunk, doReinterpret, getComponentType, getGroupingBuilder, getGroupingProvider, getType, hasGrouping, isSerializable, match, reinterpret, setGroupingProvider
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.sources.ColumnSource
allowsReinterpret, cast, getComponentType, getGroupingBuilder, getGroupingProvider, getType, hasGrouping, match, reinterpret, releaseCachedResources, setGroupingProvider
Methods inherited from interface com.illumon.iris.db.v2.sources.ColumnSourceGetDefaults.ForObject
getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getShort
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource
getChunk, getChunkByFilling
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource.WithPrev
getPrevChunk, getPrevChunkByFilling
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.FillContextMaker
makeFillContext
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.GetContextMaker
makeGetContext
Methods inherited from interface com.illumon.iris.db.v2.sources.MutableColumnSourceGetDefaults.ForObject
getPrevBoolean, getPrevByte, getPrevChar, getPrevDouble, getPrevFloat, getPrevInt, getPrevLong, getPrevShort
Methods inherited from interface com.illumon.iris.db.v2.tuples.TupleExporter
exportElementReinterpreted
Methods inherited from interface com.illumon.iris.db.v2.tuples.TupleSource
createTupleFromReinterpretedValues
-
Constructor Details
-
SmartKeySource
Construct a new tuple source backed by the supplied column sources. The column sources array should not be changed after this call.- Parameters:
columnSources
- The column sources to produce tuples from
-
-
Method Details
-
startTrackingPrevValues
public final void startTrackingPrevValues()Description copied from interface:ColumnSource
ColumnSource implementations that track previous values have the option to not actually start tracking previous values until this method is called. This is an option, not an obligation: some simple ColumnSource implementations (like TSingleValueSource for various T) always track previous values; other implementations (like PrevColumnSource) never do; some (like TArrayColumnSource) only start tracking once this method is called. An immutable column source can not have distinct prev values; therefore it is implemented as a no-op.- Specified by:
startTrackingPrevValues
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
-
get
public final com.fishlib.datastructures.util.SmartKey get(long indexKey)Description copied from interface:ElementSource
Get the value from the source. This may return boxed values for basic types.- Specified by:
get
in interfaceElementSource<com.fishlib.datastructures.util.SmartKey>
- Parameters:
indexKey
- the location in index space to get the value from.- Returns:
- the value at the index, potentially null.
-
getPrev
public final com.fishlib.datastructures.util.SmartKey getPrev(long indexKey)Description copied from interface:ElementSource
Get the previous value at the index. Previous values are used during anLTM
update
cycle to process changes in data. Duringnormal
operation previous values will be identical tocurrent
values.- Specified by:
getPrev
in interfaceElementSource<com.fishlib.datastructures.util.SmartKey>
- Parameters:
indexKey
- the location in index space to get the value from.- Returns:
- the previous value at the index, or null.
-
getColumnSources
Description copied from interface:TupleSource
Get theColumnSource
s backing this tuple source.- Specified by:
getColumnSources
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
getColumnSources
in interfaceTupleSource<com.fishlib.datastructures.util.SmartKey>
- Returns:
- The column sources
-
createTuple
public final com.fishlib.datastructures.util.SmartKey createTuple(long indexKey)Description copied from interface:TupleSource
Create a tuple for key column values at the supplied index key.- Specified by:
createTuple
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
createTuple
in interfaceTupleSource<com.fishlib.datastructures.util.SmartKey>
- Parameters:
indexKey
- The index key- Returns:
- The resulting tuple
-
createPreviousTuple
public final com.fishlib.datastructures.util.SmartKey createPreviousTuple(long indexKey)Description copied from interface:TupleSource
Create a tuple for previous key column values at the supplied index key.- Specified by:
createPreviousTuple
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
createPreviousTuple
in interfaceTupleSource<com.fishlib.datastructures.util.SmartKey>
- Parameters:
indexKey
- The index key- Returns:
- The resulting tuple
-
createTupleFromValues
public final com.fishlib.datastructures.util.SmartKey createTupleFromValues(@NotNull Object... values)Description copied from interface:TupleSource
Create a tuple for the supplied (boxed) values.- Specified by:
createTupleFromValues
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
createTupleFromValues
in interfaceTupleSource<com.fishlib.datastructures.util.SmartKey>
- Parameters:
values
- The values- Returns:
- The resulting tuple
-
exportElement
public final <ELEMENT_TYPE> void exportElement(@NotNull com.fishlib.datastructures.util.SmartKey smartKey, int elementIndex, @NotNull WritableSource<ELEMENT_TYPE> writableSource, long destinationIndexKey)Description copied from interface:TupleExporter
Export a single element from the tuple, identified by its element index, to the destination index key of the supplied writable source.For the empty tuple, this is unsupported.
For singles, this will copy the sole element, possibly in boxed form.
For doubles and longer, this will copy the specified element without any unnecessary boxing.
- Specified by:
exportElement
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
exportElement
in interfaceTupleExporter<com.fishlib.datastructures.util.SmartKey>
- Type Parameters:
ELEMENT_TYPE
- the type of the element to be exported- Parameters:
smartKey
- The tuple to export an element fromelementIndex
- The element index to exportwritableSource
- The destinationdestinationIndexKey
- The destination index key
-
exportElement
public final Object exportElement(@NotNull com.fishlib.datastructures.util.SmartKey smartKey, int elementIndex)Description copied from interface:TupleExporter
Export a single element from the tuple, identified by its element index, to an ObjectFor the empty tuple, this is unsupported.
For singles, this will copy the sole element, possibly in boxed form.
For doubles and longer, this will copy the specified element without any unnecessary boxing.
- Specified by:
exportElement
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
exportElement
in interfaceTupleExporter<com.fishlib.datastructures.util.SmartKey>
- Parameters:
smartKey
- The tuple to export an element fromelementIndex
- The element index to export- Returns:
- a single value from the tuple
-
exportToExternalKey
public final com.fishlib.datastructures.util.SmartKey exportToExternalKey(@NotNull com.fishlib.datastructures.util.SmartKey smartKey)Description copied from interface:TupleExporter
Export this tuple's element list as a key suitable for the
TableMap
s resulting fromTable.byExternal(boolean, java.lang.String...)
.For the empty tuple this is a unsupported.
For singles, this is the (boxed) sole element itself.
For doubles and longer, this is a newly-allocated "
SmartKey
".- Specified by:
exportToExternalKey
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
exportToExternalKey
in interfaceTupleExporter<com.fishlib.datastructures.util.SmartKey>
- Parameters:
smartKey
- The tuple to export all elements from- Returns:
- The new smart key
-
getNativeType
- Specified by:
getNativeType
in interfaceChunkSource<Attributes.Values>
- Specified by:
getNativeType
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Overrides:
getNativeType
in classAbstractColumnSource<com.fishlib.datastructures.util.SmartKey>
-
getChunk
public final Chunk<Attributes.Values> getChunk(@NotNull ChunkSource.GetContext context, @NotNull OrderedKeys orderedKeys)Description copied from interface:ChunkSource
Returns a chunk of data corresponding to the keys from the givenOrderedKeys
.- Specified by:
getChunk
in interfaceChunkSource<Attributes.Values>
- Specified by:
getChunk
in interfaceDefaultChunkSource<Attributes.Values>
- Parameters:
context
- A context containing all mutable/state related data used in retrieving the Chunk. In particular, the Context may be used to provide a Chunk data poolorderedKeys
- AnOrderedKeys
representing the keys to be fetched- Returns:
- A chunk of data corresponding to the keys from the given
OrderedKeys
-
getPrevChunk
public final Chunk<Attributes.Values> getPrevChunk(@NotNull ChunkSource.GetContext context, @NotNull OrderedKeys orderedKeys)Description copied from interface:ChunkSource.WithPrev
Returns a chunk of previous data corresponding to the keys from the givenOrderedKeys
.- Specified by:
getPrevChunk
in interfaceChunkSource.WithPrev<Attributes.Values>
- Specified by:
getPrevChunk
in interfaceDefaultChunkSource.WithPrev<Attributes.Values>
- Parameters:
context
- A context containing all mutable/state related data used in retrieving the Chunk. In particular, the Context may be used to provide a Chunk data poolorderedKeys
- AnOrderedKeys
representing the keys to be fetched- Returns:
- A chunk of data corresponding to the keys from the given
OrderedKeys
.
-
fillChunk
public final void fillChunk(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> destination, @NotNull OrderedKeys orderedKeys)Description copied from interface:ChunkSource
Populates the given destination chunk with data corresponding to the keys from the givenOrderedKeys
.- Specified by:
fillChunk
in interfaceChunkSource<Attributes.Values>
- Overrides:
fillChunk
in classAbstractColumnSource<com.fishlib.datastructures.util.SmartKey>
- Parameters:
context
- A context containing all mutable/state related data used in retrieving the Chunk.destination
- The chunk to be populated according toorderedKeys
. No assumptions shall be made about the size of the chunk shall be made. The chunk will be populated from position [0,orderedKeys.size()).orderedKeys
- AnOrderedKeys
representing the keys to be fetched
-
fillPrevChunk
public final void fillPrevChunk(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> destination, @NotNull OrderedKeys orderedKeys)Description copied from interface:ChunkSource.WithPrev
Populates the given destination chunk with data corresponding to the keys from the givenOrderedKeys
.- Specified by:
fillPrevChunk
in interfaceChunkSource.WithPrev<Attributes.Values>
- Overrides:
fillPrevChunk
in classAbstractColumnSource<com.fishlib.datastructures.util.SmartKey>
- Parameters:
context
- A context containing all mutable/state related data used in retrieving the Chunk.destination
- The chunk to be populated according toorderedKeys
. No assumptions shall be made about the size of the chunk shall be made. The chunk will be populated from position [0,orderedKeys.size()).orderedKeys
- AnOrderedKeys
representing the keys to be fetched
-
makeGetContext
public final com.illumon.iris.db.v2.tuples.SmartKeySource.GetContext makeGetContext(int chunkCapacity, SharedContext sharedContext)Description copied from interface:GetContextMaker
Allocate a newChunkSource.GetContext
for retrieving chunks from thisGetContextMaker
, typically aChunkSource
.- Specified by:
makeGetContext
in interfaceDefaultChunkSource<Attributes.Values>
- Specified by:
makeGetContext
in interfaceGetContextMaker
- Parameters:
chunkCapacity
- The maximum size required for anyWritableChunk
allocated as part of the result.sharedContext
- Shared store of intermediate results.- Returns:
- A context for use with get operations
-
makeFillContext
public final com.illumon.iris.db.v2.tuples.SmartKeySource.FillContext makeFillContext(int chunkCapacity, SharedContext sharedContext)Description copied from interface:FillContextMaker
Allocate a newChunkSource.FillContext
for filling chunks from thisFillContextMaker
, typically aChunkSource
.- Specified by:
makeFillContext
in interfaceDefaultChunkSource<Attributes.Values>
- Specified by:
makeFillContext
in interfaceFillContextMaker
- Parameters:
chunkCapacity
- The maximum size of anyWritableChunk
that will be filled with this contextsharedContext
- Shared store of intermediate results.- Returns:
- A context for use with fill operations
-
getPrevSource
- Specified by:
getPrevSource
in interfaceChunkSource.WithPrev<Attributes.Values>
- Specified by:
getPrevSource
in interfaceColumnSource<com.fishlib.datastructures.util.SmartKey>
- Specified by:
getPrevSource
in interfaceDefaultChunkSource.WithPrev<Attributes.Values>
- Returns:
- a chunk source which accesses the previous values.
-