Class SmartKeySource

java.lang.Object
com.illumon.iris.db.v2.sources.AbstractColumnSource<com.fishlib.datastructures.util.SmartKey>
com.illumon.iris.db.v2.tuples.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 SmartKeys from multiple ColumnSources.

See Also:
Serialized Form
  • Constructor Details

    • SmartKeySource

      public SmartKeySource​(@NotNull ColumnSource... columnSources)
      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 interface ColumnSource<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 interface ElementSource<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 an LTM update cycle to process changes in data. During normal operation previous values will be identical to current values.
      Specified by:
      getPrev in interface ElementSource<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

      public final List<ColumnSource> getColumnSources()
      Description copied from interface: TupleSource
      Get the ColumnSources backing this tuple source.
      Specified by:
      getColumnSources in interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      getColumnSources in interface TupleSource<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 interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      createTuple in interface TupleSource<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 interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      createPreviousTuple in interface TupleSource<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 interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      createTupleFromValues in interface TupleSource<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 interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      exportElement in interface TupleExporter<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 from
      elementIndex - The element index to export
      writableSource - The destination
      destinationIndexKey - 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 Object

      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 interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      exportElement in interface TupleExporter<com.fishlib.datastructures.util.SmartKey>
      Parameters:
      smartKey - The tuple to export an element from
      elementIndex - 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 TableMaps resulting from Table.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 interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      exportToExternalKey in interface TupleExporter<com.fishlib.datastructures.util.SmartKey>
      Parameters:
      smartKey - The tuple to export all elements from
      Returns:
      The new smart key
    • getNativeType

      public final Class<com.fishlib.datastructures.util.SmartKey> getNativeType()
      Specified by:
      getNativeType in interface ChunkSource<Attributes.Values>
      Specified by:
      getNativeType in interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Overrides:
      getNativeType in class AbstractColumnSource<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 given OrderedKeys.
      Specified by:
      getChunk in interface ChunkSource<Attributes.Values>
      Specified by:
      getChunk in interface DefaultChunkSource<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 pool
      orderedKeys - An OrderedKeys 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 given OrderedKeys.
      Specified by:
      getPrevChunk in interface ChunkSource.WithPrev<Attributes.Values>
      Specified by:
      getPrevChunk in interface DefaultChunkSource.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 pool
      orderedKeys - An OrderedKeys 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 given OrderedKeys.
      Specified by:
      fillChunk in interface ChunkSource<Attributes.Values>
      Overrides:
      fillChunk in class AbstractColumnSource<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 to orderedKeys. 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 - An OrderedKeys 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 given OrderedKeys.
      Specified by:
      fillPrevChunk in interface ChunkSource.WithPrev<Attributes.Values>
      Overrides:
      fillPrevChunk in class AbstractColumnSource<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 to orderedKeys. 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 - An OrderedKeys 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 new ChunkSource.GetContext for retrieving chunks from this GetContextMaker, typically a ChunkSource.
      Specified by:
      makeGetContext in interface DefaultChunkSource<Attributes.Values>
      Specified by:
      makeGetContext in interface GetContextMaker
      Parameters:
      chunkCapacity - The maximum size required for any WritableChunk 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 new ChunkSource.FillContext for filling chunks from this FillContextMaker, typically a ChunkSource.
      Specified by:
      makeFillContext in interface DefaultChunkSource<Attributes.Values>
      Specified by:
      makeFillContext in interface FillContextMaker
      Parameters:
      chunkCapacity - The maximum size of any WritableChunk that will be filled with this context
      sharedContext - Shared store of intermediate results.
      Returns:
      A context for use with fill operations
    • getPrevSource

      public final ChunkSource<Attributes.Values> getPrevSource()
      Specified by:
      getPrevSource in interface ChunkSource.WithPrev<Attributes.Values>
      Specified by:
      getPrevSource in interface ColumnSource<com.fishlib.datastructures.util.SmartKey>
      Specified by:
      getPrevSource in interface DefaultChunkSource.WithPrev<Attributes.Values>
      Returns:
      a chunk source which accesses the previous values.