Package com.illumon.iris.db.v2.sources
Class ArrayBackedColumnSource<T>
java.lang.Object
com.illumon.iris.db.v2.sources.AbstractColumnSource<T>
com.illumon.iris.db.v2.sources.ArrayBackedColumnSource<T>
- All Implemented Interfaces:
ChunkSource<Attributes.Values>
,ChunkSource.WithPrev<Attributes.Values>
,DefaultChunkSource<Attributes.Values>
,DefaultChunkSource.WithPrev<Attributes.Values>
,FillContextMaker
,GetContextMaker
,ColumnSource<T>
,ElementSource<T>
,FillUnordered
,Releasable
,WritableChunkSink<Attributes.Values>
,WritableSource<T>
,TupleExporter<T>
,TupleSource<T>
,ShiftData.ShiftCallback
,Serializable
- Direct Known Subclasses:
BooleanArraySource
,ByteArraySource
,CharacterArraySource
,DoubleArraySource
,FloatArraySource
,IntegerArraySource
,LongArraySource
,NanosBasedTimeArraySource
,ObjectArraySource
,ShortArraySource
public abstract class ArrayBackedColumnSource<T>
extends AbstractColumnSource<T>
implements FillUnordered, ShiftData.ShiftCallback, WritableSource<T>, Serializable
A ColumnSource backed by in-memory arrays of data.
The column source is dense with keys from 0 to capacity, there can be no holes. Arrays are divided into blocks
so that the column source can be incrementally expanded without copying data from one array to another.
- See Also:
-
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.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>
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.sources.WritableChunkSink
WritableChunkSink.FillFromContext
-
Field Summary
FieldsFields inherited from class com.illumon.iris.db.v2.sources.AbstractColumnSource
componentType, 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
Fields inherited from interface com.illumon.iris.db.v2.sources.WritableChunkSink
DEFAULT_FILL_FROM_INSTANCE
Fields inherited from interface com.illumon.iris.db.v2.sources.WritableSource
ZERO_LENGTH_WRITABLE_SOURCE_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
ensureCapacity
(long size, boolean nullFill) 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
fillChunkUnordered
(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> destination, LongChunk<? extends Attributes.KeyIndices> keyIndices) Populates a contiguous portion of the given destination chunk with data corresponding to the keys from the givenLongChunk
.void
fillPrevChunkUnordered
(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> destination, LongChunk<? extends Attributes.KeyIndices> keyIndices) Populates a contiguous portion of the given destination chunk with prev data corresponding to the keys from the givenLongChunk
.protected abstract void
fillSparseChunk
(WritableChunk<? super Attributes.Values> destination, OrderedKeys indices) protected abstract void
fillSparseChunkUnordered
(WritableChunk<? super Attributes.Values> destination, LongChunk<? extends Attributes.KeyIndices> indices) protected abstract void
fillSparsePrevChunk
(WritableChunk<? super Attributes.Values> destination, OrderedKeys indices) protected abstract void
fillSparsePrevChunkUnordered
(WritableChunk<? super Attributes.Values> destination, LongChunk<? extends Attributes.KeyIndices> indices) getChunk
(ChunkSource.GetContext context, OrderedKeys orderedKeys) Returns a chunk of data corresponding to the keys from the givenOrderedKeys
.static ArrayBackedColumnSource<DBDateTime>
getDateTimeMemoryColumnSource
(long[] data) Produces an DateTimeArraySource with the given data.static ArrayBackedColumnSource<DBDateTime>
Produces an DateTimeArraySource with the given data.static ColumnSource
getImmutableMemoryColumnSource
(Object dataArray) Wrap the input array in an immutableColumnSource
.static ColumnSource
getImmutableMemoryColumnSource
(Object dataArray, Class<?> type) Wrap the input array in an immutableColumnSource
.static ArrayBackedColumnSource<Byte>
getMemoryColumnSource
(byte[] data) Produces an ByteArraySource with the given data.static ArrayBackedColumnSource<Character>
getMemoryColumnSource
(char[] data) Produces an CharacterArraySource with the given data.static ArrayBackedColumnSource<Double>
getMemoryColumnSource
(double[] data) Produces an DoubleArraySource with the given data.static ArrayBackedColumnSource<Float>
getMemoryColumnSource
(float[] data) Produces an FloatArraySource with the given data.static ArrayBackedColumnSource<Integer>
getMemoryColumnSource
(int[] data) Produces an IntegerArraySource with the given data.static ArrayBackedColumnSource<Long>
getMemoryColumnSource
(long[] data) Produces an LongArraySource with the given data.static <T> ArrayBackedColumnSource<T>
getMemoryColumnSource
(long size, Class<T> type) Produces an empty ArrayBackedColumnSource with the given type and capacity.static <T> ArrayBackedColumnSource<T>
getMemoryColumnSource
(long size, Class<T> type, Class componentType) Produces an empty ArrayBackedColumnSource with the given type and capacity.static ArrayBackedColumnSource<Short>
getMemoryColumnSource
(short[] data) Produces an ShortArraySource with the given data.static <T> ArrayBackedColumnSource<T>
getMemoryColumnSource
(Class<T> type, Class componentType) static WritableSource
getMemoryColumnSource
(Object dataArray) Creates an in-memory ColumnSource from the supplied dataArray, using instanceof checks to determine the appropriate type of column source to produce.static <T> ArrayBackedColumnSource<T>
getMemoryColumnSource
(Collection<T> data, Class<T> type) Produces an ArrayBackedColumnSource with the given data.static <T> ArrayBackedColumnSource<T>
getMemoryColumnSource
(T[] data, Class<T> type) Produces an ArrayBackedColumnSource with the given data.boolean
Determine if this column source is immutable, meaning that the values at a given index key never change.abstract long
resetWritableChunkToBackingStore
(ResettableWritableChunk chunk, long position) Resets the given chunk to provide a write-through reference to our backing array.void
set
(long key, byte value) void
set
(long key, char value) void
set
(long key, double value) void
set
(long key, float value) void
set
(long key, int value) void
set
(long key, long value) void
set
(long key, short value) void
shift
(long start, long end, long offset) Methods inherited from class com.illumon.iris.db.v2.sources.AbstractColumnSource
allowsReinterpret, canUseGrouping, defaultFillChunk, doReinterpret, fillPrevChunk, getComponentType, getGroupingBuilder, getGroupingProvider, getNativeType, getType, hasGrouping, isSerializable, match, matchWithGrouping, 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.chunk.ChunkSource
getChunkType
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource.WithPrev
fillPrevChunk
Methods inherited from interface com.illumon.iris.db.v2.sources.ColumnSource
allowsReinterpret, cast, createPreviousTuple, createTuple, createTupleFromValues, exportElement, exportElement, exportToExternalKey, getColumnSources, getComponentType, getGroupingBuilder, getGroupingProvider, getNativeType, getPrevSource, getType, hasGrouping, match, reinterpret, releaseCachedResources, setGroupingProvider, startTrackingPrevValues
Methods inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource
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
Methods inherited from interface com.illumon.iris.db.v2.sources.WritableSource
copy, ensureCapacity, fillFromChunk, fillFromChunkUnordered, makeFillFromContext, set, setNull, setNull
-
Field Details
-
BLOCK_SIZE
public static final int BLOCK_SIZE- See Also:
-
-
Method Details
-
set
public void set(long key, byte value) - Specified by:
set
in interfaceWritableSource<T>
-
set
public void set(long key, char value) - Specified by:
set
in interfaceWritableSource<T>
-
set
public void set(long key, double value) - Specified by:
set
in interfaceWritableSource<T>
-
set
public void set(long key, float value) - Specified by:
set
in interfaceWritableSource<T>
-
set
public void set(long key, int value) - Specified by:
set
in interfaceWritableSource<T>
-
set
public void set(long key, long value) - Specified by:
set
in interfaceWritableSource<T>
-
set
public void set(long key, short value) - Specified by:
set
in interfaceWritableSource<T>
-
getMemoryColumnSource
public static <T> ArrayBackedColumnSource<T> getMemoryColumnSource(Collection<T> data, Class<T> type) Produces an ArrayBackedColumnSource with the given data.- Parameters:
data
- a collection containing the data to insert into the ColumnSource.type
- the type of the resulting column source- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an ArrayBackedColumnSource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.type
- the type of the resulting column source- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an ByteArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an CharacterArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an DoubleArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an FloatArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an IntegerArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an LongArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.- Returns:
- an in-memory column source with the requested data
-
getDateTimeMemoryColumnSource
Produces an DateTimeArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource, represented as long nanoseconds since the epoch- Returns:
- an in-memory column source with the requested data
-
getDateTimeMemoryColumnSource
public static ArrayBackedColumnSource<DBDateTime> getDateTimeMemoryColumnSource(LongChunk<Attributes.Values> data) Produces an DateTimeArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource, represented as long nanoseconds since the epoch- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an ShortArraySource with the given data.- Parameters:
data
- an array containing the data to insert into the ColumnSource.- Returns:
- an in-memory column source with the requested data
-
getMemoryColumnSource
Produces an empty ArrayBackedColumnSource with the given type and capacity.- Type Parameters:
T
- the type parameter for the ColumnSource's type- Parameters:
size
- the capacity of the returned column sourcetype
- the type of the resultant column source- Returns:
- an in-memory column source of the requested type
-
getMemoryColumnSource
public static <T> ArrayBackedColumnSource<T> getMemoryColumnSource(Class<T> type, @Nullable Class componentType) -
getMemoryColumnSource
public static <T> ArrayBackedColumnSource<T> getMemoryColumnSource(long size, Class<T> type, @Nullable Class componentType) Produces an empty ArrayBackedColumnSource with the given type and capacity.- Type Parameters:
T
- the type parameter for the ColumnSource's type- Parameters:
size
- the capacity of the returned column sourcetype
- the type of the resultant column sourcecomponentType
- the component type for column sources of arrays or DbArrays- Returns:
- an in-memory column source of the requested type
-
ensureCapacity
public abstract void ensureCapacity(long size, boolean nullFill) -
shift
public void shift(long start, long end, long offset) - Specified by:
shift
in interfaceShiftData.ShiftCallback
-
getMemoryColumnSource
Creates an in-memory ColumnSource from the supplied dataArray, using instanceof checks to determine the appropriate type of column source to produce.- Parameters:
dataArray
- the data to insert into the new column source- Returns:
- a ColumnSource with the supplied data.
-
getImmutableMemoryColumnSource
Wrap the input array in an immutableColumnSource
. This method will unbox any boxed values, and directly use the result array.- Parameters:
dataArray
- The array to turn into a ColumnSource- Returns:
- An Immutable ColumnSource that directly wraps the input array.
-
getImmutableMemoryColumnSource
Wrap the input array in an immutableColumnSource
. This method will unbox any boxed values, and directly use the result array. This version allows the user to specify the column type. It will automatically map column type Boolean/boolean with input array types byte[] toImmutableBooleanArraySource
and columnType DBDateTime / array type long[] toImmutableDateTimeArraySource
- Parameters:
dataArray
- The array to turn into a ColumnSource- Returns:
- An Immutable ColumnSource that directly wraps the input array.
-
isImmutable
public boolean isImmutable()Description copied from interface:ColumnSource
Determine if this column source is immutable, meaning that the values at a given index key never change.- Specified by:
isImmutable
in interfaceColumnSource<T>
- Returns:
- true if the values at a given index of the column source never change, false otherwise
-
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>
- Overrides:
fillChunk
in classAbstractColumnSource<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
-
fillChunkUnordered
public void fillChunkUnordered(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> destination, @NotNull LongChunk<? extends Attributes.KeyIndices> keyIndices) Description copied from interface:FillUnordered
Populates a contiguous portion of the given destination chunk with data corresponding to the keys from the givenLongChunk
.- Specified by:
fillChunkUnordered
in interfaceFillUnordered
- Parameters:
context
- A context containing all mutable/state related data used in retrieving the Chunk.destination
- The chunk to be populated according tokeys
keyIndices
- A chunk of individual, not assumed to be ordered keys to be fetched
-
fillPrevChunkUnordered
public void fillPrevChunkUnordered(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> destination, @NotNull LongChunk<? extends Attributes.KeyIndices> keyIndices) Description copied from interface:FillUnordered
Populates a contiguous portion of the given destination chunk with prev data corresponding to the keys from the givenLongChunk
.- Specified by:
fillPrevChunkUnordered
in interfaceFillUnordered
- Parameters:
context
- A context containing all mutable/state related data used in retrieving the Chunk.destination
- The chunk to be populated according tokeys
keyIndices
- A chunk of individual, not assumed to be ordered keys to be fetched
-
resetWritableChunkToBackingStore
public abstract long resetWritableChunkToBackingStore(@NotNull ResettableWritableChunk chunk, long position) Resets the given chunk to provide a write-through reference to our backing array. Note: This is unsafe to use if previous tracking has been enabled!- Parameters:
chunk
- the writable chunk to reset to our backing array.position
- position that we require- Returns:
- the first position addressable by the chunk
-
fillSparseChunk
protected abstract void fillSparseChunk(@NotNull WritableChunk<? super Attributes.Values> destination, @NotNull OrderedKeys indices) -
fillSparsePrevChunk
protected abstract void fillSparsePrevChunk(@NotNull WritableChunk<? super Attributes.Values> destination, @NotNull OrderedKeys indices) -
fillSparseChunkUnordered
protected abstract void fillSparseChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destination, @NotNull LongChunk<? extends Attributes.KeyIndices> indices) -
fillSparsePrevChunkUnordered
protected abstract void fillSparsePrevChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destination, @NotNull LongChunk<? extends Attributes.KeyIndices> indices) -
getChunk
public 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<T>
- Specified by:
getChunk
in interfaceDefaultChunkSource<T>
- 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
-