Package com.illumon.iris.db.v2.sources
Class AbstractColumnSource<T>
java.lang.Object
com.illumon.iris.db.v2.sources.AbstractColumnSource<T>
- All Implemented Interfaces:
ChunkSource<Attributes.Values>
,ChunkSource.WithPrev<Attributes.Values>
,DefaultChunkSource<Attributes.Values>
,DefaultChunkSource.WithPrev<Attributes.Values>
,FillContextMaker
,GetContextMaker
,ColumnSource<T>
,ElementSource<T>
,Releasable
,TupleExporter<T>
,TupleSource<T>
,Serializable
- Direct Known Subclasses:
AbstractColumnSource.DefaultedImmutable
,AbstractColumnSource.DefaultedMutable
,AbstractDeferredGroupingColumnSource
,BitMaskingColumnSource
,BitShiftingColumnSource
,BooleanAsByteColumnSource
,BoxedColumnSource
,BoxedLongAsTimeSource
,ByteAggregateColumnSource
,ByteSsmBackedSource
,CharAggregateColumnSource
,CharSsmBackedSource
,CrossJoinRightColumnSource
,DbDateTimeSsmSourceWrapper
,DeltaAwareColumnSource
,DoubleAggregateColumnSource
,DoubleNullToZeroColumnSource
,DoubleSsmBackedSource
,EmptyToNullStringRegionedColumnSource
,FloatAggregateColumnSource
,FloatSsmBackedSource
,HashTableColumnSource
,ImmutableBooleanArraySource
,ImmutableByteArraySource
,ImmutableCharArraySource
,ImmutableDateTimeArraySource
,ImmutableDoubleArraySource
,ImmutableFloatArraySource
,ImmutableInstantArraySource
,ImmutableIntArraySource
,ImmutableLongArraySource
,ImmutableObjectArraySource
,ImmutableShortArraySource
,IntAggregateColumnSource
,IntSsmBackedSource
,ListAggregateColumnSource
,LocalDateWrapperSource
,LocalTimeWrapperSource
,LongAggregateColumnSource
,LongSsmBackedSource
,MergeSortedHelper.SortedMergeColumnSource
,NullValueColumnSource
,ObjectAggregateColumnSource
,ObjectSsmBackedSource
,PrevColumnSource
,ReversedColumnSource
,RowIdSource
,ShortAggregateColumnSource
,ShortSsmBackedSource
,SingleValueColumnSource
,SingleValueObjectColumnSource
,SmartKeySource
,SwitchColumnSource
,SymbolTableToUniqueIdSource
,TableLogger.NoPrevColumnSource
,UnboxedLongBackedColumnSource
,UnboxedTimeBackedColumnSource
,UngroupedColumnSource
,UnionColumnSource
,ViewColumnSource
,ViewportColumnSource
public abstract class AbstractColumnSource<T> extends Object implements ColumnSource<T>, Serializable
The basis for all Column Sources. This class contains the default implementations for various grouping operations
as well as basic chunking.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractColumnSource.DefaultedImmutable<DATA_TYPE>
static class
AbstractColumnSource.DefaultedMutable<DATA_TYPE>
static interface
AbstractColumnSource.IsSerializable
We have a fair bit of internal state that must be serialized, but not all of our descendants in the class hierarchy should actually be sent over the wire.Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource
ChunkSource.FillContext, ChunkSource.GetContext, 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 Modifier and Type Field Description protected Class<?>
componentType
protected Map<T,ReadOnlyIndex>
groupToRange
protected Class<T>
type
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 Modifier Constructor Description protected
AbstractColumnSource(Class<T> type)
AbstractColumnSource(Class<T> type, Class elementType)
-
Method Summary
Modifier and Type Method Description <ALTERNATE_DATA_TYPE>
booleanallowsReinterpret(Class<ALTERNATE_DATA_TYPE> alternateDataType)
Test if a reinterpret call will succeed.static <TYPE> Map<TYPE,ReadOnlyIndex>
computeFlattenedGroupings(Index index, ColumnSource<TYPE> columnSource)
Get a map from unique, boxed values in this column to a flat index of keys where they are present.void
defaultFillChunk(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> destination, OrderedKeys orderedKeys)
protected <ALTERNATE_DATA_TYPE>
ColumnSource<ALTERNATE_DATA_TYPE>doReinterpret(Class<ALTERNATE_DATA_TYPE> alternateDataType)
Supply allowed reinterpret results.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
.static <TYPE> void
forEachGroup(Map<TYPE,ReadOnlyIndex> groupToIndex, BiConsumer<TYPE,ReadOnlyIndex> groupConsumer)
Consume all groups in a group-to-index map.static <TYPE> void
forEachResponsiveGroup(Map<TYPE,ReadOnlyIndex> groupToIndex, ReadOnlyIndex intersect, BiConsumer<TYPE,ReadOnlyIndex> groupConsumer)
Consume all responsive groups in a group-to-index map.Class<?>
getComponentType()
Map<T,ReadOnlyIndex>
getGroupToRange()
Compute grouping information for all keys present in this column source.Map<T,ReadOnlyIndex>
getGroupToRange(ReadOnlyIndex index)
Compute grouping information for (at least) all keys present in index.Class<T>
getNativeType()
Class<T>
getType()
Map<T,ReadOnlyIndex>
getValuesMapping(ReadOnlyIndex subRange)
static <TYPE> com.fishlib.base.Pair<ArrayBackedColumnSource<TYPE>,ObjectArraySource<ReadOnlyIndex>>
groupingToFlatSources(ColumnSource<TYPE> originalKeyColumnSource, Map<TYPE,ReadOnlyIndex> groupToIndex)
Convert a group-to-index map to a pair of flat in-memory column sources, one for the keys and one for the indexes.static <TYPE> com.fishlib.base.Pair<ArrayBackedColumnSource<TYPE>,ObjectArraySource<ReadOnlyIndex>>
groupingToFlatSources(ColumnSource<TYPE> originalKeyColumnSource, Map<TYPE,ReadOnlyIndex> groupToIndex, ReadOnlyIndex intersect, org.apache.commons.lang3.mutable.MutableInt responsiveGroups)
Convert a group-to-index map to a pair of flat in-memory column sources, one for the keys and one for the indexes.static <TYPE> com.fishlib.base.Pair<ArrayBackedColumnSource<TYPE>,ObjectArraySource<ReadOnlyIndex>>
groupingToFlatSources(Class valueType, Class componentType, Map<TYPE,ReadOnlyIndex> groupToIndex)
Convert a group-to-index map to a pair of flat in-memory column sources, one for the keys and one for the indexes.boolean
isSerializable()
Finds the most derived class that has an IsSerializable annotation, and returns its value.Index
match(boolean invertMatch, boolean usePrev, boolean caseInsensitive, Index mapper, Object... keys)
<ALTERNATE_DATA_TYPE>
ColumnSource<ALTERNATE_DATA_TYPE>reinterpret(Class<ALTERNATE_DATA_TYPE> alternateDataType)
Provide an alternative view into the data underlying this column source.void
setGroupToRange(Map<T,ReadOnlyIndex> groupToRange)
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
cast, createPreviousTuple, createTuple, createTupleFromValues, exportElement, exportElement, exportToExternalKey, getColumnSources, getPrevSource, isImmutable, releaseCachedResources, startTrackingPrevValues
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource
getChunk, getChunk, getChunkByFilling, makeFillContext, makeGetContext
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource.WithPrev
getPrevChunk, getPrevChunk, getPrevChunkByFilling
Methods inherited from interface com.illumon.iris.db.v2.sources.ElementSource
get, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getPrev, getPrevBoolean, getPrevByte, getPrevChar, getPrevDouble, getPrevFloat, getPrevInt, getPrevLong, getPrevShort, getShort
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.tuples.TupleExporter
exportElementReinterpreted
Methods inherited from interface com.illumon.iris.db.v2.tuples.TupleSource
createTupleFromReinterpretedValues
-
Field Details
-
Constructor Details
-
Method Details
-
getType
- Specified by:
getType
in interfaceColumnSource<T>
-
getComponentType
- Specified by:
getComponentType
in interfaceColumnSource<T>
-
getGroupToRange
Description copied from interface:ColumnSource
Compute grouping information for all keys present in this column source.- Specified by:
getGroupToRange
in interfaceColumnSource<T>
- Returns:
- A map from distinct data values to an index that contains those values
-
getGroupToRange
Description copied from interface:ColumnSource
Compute grouping information for (at least) all keys present in index.- Specified by:
getGroupToRange
in interfaceColumnSource<T>
- Parameters:
index
- The index to consider- Returns:
- A map from distinct data values to an index that contains those values
-
setGroupToRange
-
match
public Index match(boolean invertMatch, boolean usePrev, boolean caseInsensitive, Index mapper, Object... keys)- Specified by:
match
in interfaceColumnSource<T>
-
getValuesMapping
- Specified by:
getValuesMapping
in interfaceColumnSource<T>
-
isSerializable
public boolean isSerializable()Finds the most derived class that has an IsSerializable annotation, and returns its value. If no annotation is found, then returns false. Note: This is an internal Deephaven function and may be removed or changed at any time. -
getNativeType
- Specified by:
getNativeType
in interfaceChunkSource<T>
- Specified by:
getNativeType
in interfaceColumnSource<T>
-
fillChunk
public 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<T>
- 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
-
defaultFillChunk
@VisibleForTesting public final void defaultFillChunk(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> destination, @NotNull OrderedKeys orderedKeys) -
fillPrevChunk
public 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<T>
- 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
-
allowsReinterpret
public <ALTERNATE_DATA_TYPE> boolean allowsReinterpret(@NotNull Class<ALTERNATE_DATA_TYPE> alternateDataType)Description copied from interface:ColumnSource
Test if a reinterpret call will succeed.- Specified by:
allowsReinterpret
in interfaceColumnSource<T>
- Parameters:
alternateDataType
- The alternative type to consider- Returns:
- If a reinterpret on this column source with the supplied alternateDataType will succeed.
-
reinterpret
public final <ALTERNATE_DATA_TYPE> ColumnSource<ALTERNATE_DATA_TYPE> reinterpret(@NotNull Class<ALTERNATE_DATA_TYPE> alternateDataType) throws IllegalArgumentExceptionDescription copied from interface:ColumnSource
Provide an alternative view into the data underlying this column source.- Specified by:
reinterpret
in interfaceColumnSource<T>
- Parameters:
alternateDataType
- The alternative type to expose- Returns:
- A column source of the alternate data type, backed by the same underlying data.
- Throws:
IllegalArgumentException
- If the alternativeDataType supplied is not supported
-
doReinterpret
protected <ALTERNATE_DATA_TYPE> ColumnSource<ALTERNATE_DATA_TYPE> doReinterpret(@NotNull Class<ALTERNATE_DATA_TYPE> alternateDataType)Supply allowed reinterpret results. The default implementation handles the most common case to avoid code duplication.- Parameters:
alternateDataType
- The alternate data type- Returns:
- The resulting
ColumnSource
-
computeFlattenedGroupings
public static <TYPE> Map<TYPE,ReadOnlyIndex> computeFlattenedGroupings(@NotNull Index index, @Nullable ColumnSource<TYPE> columnSource)Get a map from unique, boxed values in this column to a flat index of keys where they are present.- Parameters:
index
- The index that defines the column along with the column sourcecolumnSource
- The column source that defines the column along with the index- Returns:
- A new value to range map (i.e. grouping metadata)
-
forEachGroup
public static <TYPE> void forEachGroup(@NotNull Map<TYPE,ReadOnlyIndex> groupToIndex, @NotNull BiConsumer<TYPE,ReadOnlyIndex> groupConsumer)Consume all groups in a group-to-index map.- Parameters:
groupToIndex
- The group-to-index map to consumegroupConsumer
- Consumer for responsive groups
-
groupingToFlatSources
public static <TYPE> com.fishlib.base.Pair<ArrayBackedColumnSource<TYPE>,ObjectArraySource<ReadOnlyIndex>> groupingToFlatSources(@NotNull ColumnSource<TYPE> originalKeyColumnSource, @NotNull Map<TYPE,ReadOnlyIndex> groupToIndex)Convert a group-to-index map to a pair of flat in-memory column sources, one for the keys and one for the indexes.- Parameters:
originalKeyColumnSource
- The key column source whose contents are reflected by the group-to-index map (used for typing, only)groupToIndex
- The group-to-index map to convert- Returns:
- A pair of a flat key column source and a flat index column source
-
groupingToFlatSources
public static <TYPE> com.fishlib.base.Pair<ArrayBackedColumnSource<TYPE>,ObjectArraySource<ReadOnlyIndex>> groupingToFlatSources(@NotNull Class valueType, Class componentType, @NotNull Map<TYPE,ReadOnlyIndex> groupToIndex)Convert a group-to-index map to a pair of flat in-memory column sources, one for the keys and one for the indexes.- Parameters:
valueType
- The column type of the value columncomponentType
- The component type of the columngroupToIndex
- The group-to-index map to convert- Returns:
- A pair of a flat key column source and a flat index column source
-
forEachResponsiveGroup
public static <TYPE> void forEachResponsiveGroup(@NotNull Map<TYPE,ReadOnlyIndex> groupToIndex, @NotNull ReadOnlyIndex intersect, @NotNull BiConsumer<TYPE,ReadOnlyIndex> groupConsumer)Consume all responsive groups in a group-to-index map.- Parameters:
groupToIndex
- The group-to-index map to consumeintersect
- Limit indices to values contained within intersect, eliminating empty result groupsgroupConsumer
- Consumer for responsive groups
-
groupingToFlatSources
public static <TYPE> com.fishlib.base.Pair<ArrayBackedColumnSource<TYPE>,ObjectArraySource<ReadOnlyIndex>> groupingToFlatSources(@NotNull ColumnSource<TYPE> originalKeyColumnSource, @NotNull Map<TYPE,ReadOnlyIndex> groupToIndex, @NotNull ReadOnlyIndex intersect, @NotNull org.apache.commons.lang3.mutable.MutableInt responsiveGroups)Convert a group-to-index map to a pair of flat in-memory column sources, one for the keys and one for the indexes.- Parameters:
originalKeyColumnSource
- The key column source whose contents are reflected by the group-to-index map (used for typing, only)groupToIndex
- The group-to-index map to convertintersect
- Limit returned indices to values contained within intersectresponsiveGroups
- Set to the number of responsive groups on exit- Returns:
- A pair of a flat key column source and a flat index column source
-