Class SparseArrayColumnSource<T>
- All Implemented Interfaces:
RowSetShiftCallback,ChunkSink<Values>,ChunkSource<Values>,ChunkSource.WithPrev<Values>,ColumnSource<T>,ElementSource<T>,FillContextMaker,GetContextMaker,DefaultChunkSource<Values>,DefaultChunkSource.WithPrev<Values>,PushdownFilterMatcher,FillUnordered<Values>,InMemoryColumnSource,PossiblyImmutableColumnSource,Releasable,TupleExporter<T>,TupleSource<T>,WritableColumnSource<T>,WritableSourceWithPrepareForParallelPopulation
- Direct Known Subclasses:
BooleanSparseArraySource,ByteSparseArraySource,CharacterSparseArraySource,DoubleSparseArraySource,FloatSparseArraySource,IntegerSparseArraySource,LongSparseArraySource,ObjectSparseArraySource,ShortSparseArraySource
To store the blocks, we use a multi-level page table like structure. Each entry that exists is complete, i.e. we never reallocate partial blocks, we always allocate the complete block. The row key is divided as follows:
| Description | Size | Bits |
|---|---|---|
| Block 0 | 19 | 62-44 |
| Block 1 | 18 | 43-26 |
| Block 2 | 18 | 25-8 |
| Index Within Block | 8 | 7-0 |
Bit 63, the sign bit, is used to indicate null (that is, all negative numbers are defined to be null)
Parallel structures are used for previous values and prevInUse. We recycle all levels of the previous blocks, so that the previous structure takes up memory only while it is in use.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classNested classes/interfaces inherited from class io.deephaven.engine.table.impl.AbstractColumnSource
AbstractColumnSource.DefaultedImmutable<DATA_TYPE>, AbstractColumnSource.DefaultedMutable<DATA_TYPE>Nested classes/interfaces inherited from interface io.deephaven.engine.table.ChunkSink
ChunkSink.FillFromContextNested classes/interfaces inherited from interface io.deephaven.engine.table.ChunkSource
ChunkSource.FillContext, ChunkSource.GetContext, ChunkSource.WithPrev<ATTR extends Any>Nested classes/interfaces inherited from interface io.deephaven.engine.table.impl.DefaultChunkSource
DefaultChunkSource.SupportsContiguousGet<ATTR extends Any>, DefaultChunkSource.WithPrev<ATTR extends Any>Nested classes/interfaces inherited from interface io.deephaven.engine.table.TupleExporter
TupleExporter.ExportElementFunction<TUPLE_TYPE>Nested classes/interfaces inherited from interface io.deephaven.engine.table.WritableColumnSource
WritableColumnSource.ByteFiller, WritableColumnSource.CharFiller, WritableColumnSource.DoubleFiller, WritableColumnSource.FloatFiller, WritableColumnSource.IntFiller, WritableColumnSource.LongFiller, WritableColumnSource.ObjectFiller, WritableColumnSource.ShortFiller, WritableColumnSource.SinkFiller -
Field Summary
Fields inherited from class io.deephaven.engine.table.impl.AbstractColumnSource
componentType, type, updateGraph, USE_RANGES_AVERAGE_RUN_LENGTHFields inherited from interface io.deephaven.engine.table.ChunkSink
DEFAULT_FILL_FROM_INSTANCEFields inherited from interface io.deephaven.engine.table.ChunkSource
DEFAULT_FILL_INSTANCE, ZERO_LENGTH_CHUNK_SOURCE_ARRAYFields inherited from interface io.deephaven.engine.table.ChunkSource.WithPrev
ZERO_LENGTH_CHUNK_SOURCE_WITH_PREV_ARRAYFields inherited from interface io.deephaven.engine.table.ColumnSource
ZERO_LENGTH_COLUMN_SOURCE_ARRAYFields inherited from interface io.deephaven.engine.table.impl.sources.InMemoryColumnSource
TWO_DIMENSIONAL_COLUMN_SOURCE_THRESHOLD -
Method Summary
Modifier and TypeMethodDescriptionvoidclearBlocks(RowSet blocksToClear, RowSet removeBlocks2, RowSet removeBlocks1, boolean empty) At the end of this cycle, clear the provided rowsets of blocks by releasing the blocks back to the recyclers.abstract longReturn an estimate of the heap size taken by the current values within this sparse array source.voidfillChunk(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Values> dest, @NotNull RowSequence rowSequence) Populates the given destination chunk with data corresponding to the keys from the givenRowSequence.voidfillChunkUnordered(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Values> dest, @NotNull LongChunk<? extends RowKeys> keys) Populates a contiguous portion of the given destination chunk with data corresponding to the keys from the givenLongChunk.voidfillFromChunk(@NotNull ChunkSink.FillFromContext context, @NotNull Chunk<? extends Values> src, @NotNull RowSequence rowSequence) Our default, inefficient, implementation.voidfillPrevChunkUnordered(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Values> dest, @NotNull LongChunk<? extends RowKeys> keys) Populates a contiguous portion of the given destination chunk with prev data corresponding to the keys from the givenLongChunk.static WritableColumnSource<Instant>getInstantMemoryColumnSource(long[] data) intUsing a preferred chunk size of BLOCK_SIZE gives us the opportunity to directly return chunks from our data structure rather than copying data.static SparseArrayColumnSource<Byte>getSparseMemoryColumnSource(byte[] data) static SparseArrayColumnSource<Character>getSparseMemoryColumnSource(char[] data) static SparseArrayColumnSource<Double>getSparseMemoryColumnSource(double[] data) static SparseArrayColumnSource<Float>getSparseMemoryColumnSource(float[] data) static SparseArrayColumnSource<Integer>getSparseMemoryColumnSource(int[] data) static SparseArrayColumnSource<Long>getSparseMemoryColumnSource(long[] data) static <T> WritableColumnSource<T>getSparseMemoryColumnSource(long size, Class<T> type) static <T> WritableColumnSource<T>getSparseMemoryColumnSource(long size, Class<T> type, @Nullable Class<?> componentType) static SparseArrayColumnSource<Short>getSparseMemoryColumnSource(short[] data) static <T> WritableColumnSource<T>getSparseMemoryColumnSource(Class<T> type) static <T> WritableColumnSource<T>getSparseMemoryColumnSource(Class<T> type, Class<?> componentType) static ColumnSource<?>getSparseMemoryColumnSource(Object dataArray) static <T> WritableColumnSource<T>getSparseMemoryColumnSource(Collection<T> data, Class<T> type) booleanDetermine if this column source is immutable, meaning that the values at a given row key never change.makeFillFromContext(int chunkCapacity) booleanReturns true if this column source can efficiently provide an unordered fill.voidvoidset(long key, byte value) voidset(long key, char value) voidset(long key, double value) voidset(long key, float value) voidset(long key, int value) voidset(long key, long value) voidset(long key, short value) voidSet this column source as having an immutable result.voidsetNull(RowSequence rowSequence) Methods inherited from class io.deephaven.engine.table.impl.AbstractColumnSource
allowsReinterpret, defaultFillChunk, defaultFillPrevChunk, doReinterpret, estimatePushdownFilterCost, fillPrevChunk, getComponentType, getPrevSource, getType, makePushdownFilterContext, match, pushdownFilter, pushdownManager, reinterpretMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.engine.table.ChunkSource.WithPrev
fillPrevChunkMethods inherited from interface io.deephaven.engine.table.ColumnSource
allowsReinterpret, cast, cast, cast, cast, createPreviousTuple, createTuple, createTupleFromValues, exportAllTo, exportElement, exportElement, getChunkType, getComponentType, getPrevSource, getType, isStateless, match, reinterpret, releaseCachedResources, startTrackingPrevValues, tupleLengthMethods inherited from interface io.deephaven.engine.table.impl.DefaultChunkSource
getChunk, getChunk, getChunkByFilling, makeFillContext, makeGetContextMethods inherited from interface io.deephaven.engine.table.impl.DefaultChunkSource.WithPrev
getPrevChunk, getPrevChunk, getPrevChunkByFillingMethods inherited from interface io.deephaven.engine.table.ElementSource
get, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getPrev, getPrevBoolean, getPrevByte, getPrevChar, getPrevDouble, getPrevFloat, getPrevInt, getPrevLong, getPrevShort, getShortMethods inherited from interface io.deephaven.engine.table.FillContextMaker
makeFillContextMethods inherited from interface io.deephaven.engine.table.GetContextMaker
makeGetContextMethods inherited from interface io.deephaven.engine.table.impl.sources.InMemoryColumnSource
isInMemoryMethods inherited from interface io.deephaven.engine.rowset.RowSetShiftCallback
shiftMethods inherited from interface io.deephaven.engine.table.TupleExporter
exportAllReinterpretedTo, exportAllReinterpretedTo, exportAllTo, exportElementReinterpretedMethods inherited from interface io.deephaven.engine.table.TupleSource
createTupleFromReinterpretedValuesMethods inherited from interface io.deephaven.engine.table.WritableColumnSource
ensureCapacity, ensureCapacity, fillFromChunkUnordered, set, setNullMethods inherited from interface io.deephaven.engine.table.WritableSourceWithPrepareForParallelPopulation
prepareForParallelPopulation
-
Method Details
-
set
public void set(long key, byte value) - Specified by:
setin interfaceWritableColumnSource<T>
-
set
public void set(long key, char value) - Specified by:
setin interfaceWritableColumnSource<T>
-
set
public void set(long key, double value) - Specified by:
setin interfaceWritableColumnSource<T>
-
set
public void set(long key, float value) - Specified by:
setin interfaceWritableColumnSource<T>
-
set
public void set(long key, int value) - Specified by:
setin interfaceWritableColumnSource<T>
-
set
public void set(long key, long value) - Specified by:
setin interfaceWritableColumnSource<T>
-
set
public void set(long key, short value) - Specified by:
setin interfaceWritableColumnSource<T>
-
remove
-
clearBlocks
public void clearBlocks(RowSet blocksToClear, RowSet removeBlocks2, RowSet removeBlocks1, boolean empty) At the end of this cycle, clear the provided rowsets of blocks by releasing the blocks back to the recyclers.- Parameters:
blocksToClear- the lowest level blocks to clearremoveBlocks2- Block2 structures to clear from the Block1 structuresremoveBlocks1- Block1 structures to clear from the Block0 structureempty- if the resulting table is empty
-
getSparseMemoryColumnSource
public static <T> WritableColumnSource<T> getSparseMemoryColumnSource(Collection<T> data, Class<T> type) -
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getInstantMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
public static <T> WritableColumnSource<T> getSparseMemoryColumnSource(Class<T> type, Class<?> componentType) -
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
public static <T> WritableColumnSource<T> getSparseMemoryColumnSource(long size, Class<T> type, @Nullable @Nullable Class<?> componentType) -
getSparseMemoryColumnSource
-
getPreferredChunkSize
public int getPreferredChunkSize()Using a preferred chunk size of BLOCK_SIZE gives us the opportunity to directly return chunks from our data structure rather than copying data. -
fillChunk
public void fillChunk(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> dest, @NotNull @NotNull RowSequence rowSequence) Description copied from interface:ChunkSourcePopulates the given destination chunk with data corresponding to the keys from the givenRowSequence.- Specified by:
fillChunkin interfaceChunkSource<T>- Overrides:
fillChunkin classAbstractColumnSource<T>- Parameters:
context- A context containing all mutable/state related data used in retrieving the Chunk.dest- The chunk to be populated according torowSequence. No assumptions shall be made about the size of the chunk shall be made. The chunk will be populated from position [0,rowSequence.size()).rowSequence- AnRowSequencerepresenting the keys to be fetched
-
setNull
- Specified by:
setNullin interfaceWritableColumnSource<T>
-
fillChunkUnordered
public void fillChunkUnordered(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> dest, @NotNull @NotNull LongChunk<? extends RowKeys> keys) Description copied from interface:FillUnorderedPopulates a contiguous portion of the given destination chunk with data corresponding to the keys from the givenLongChunk.It behaves as if the following code were executed:
destination.setSize(keys.size()); for (int ii = 0; ii < keys.size(); ++ii) { destination.set(ii, get(keys.get(ii))); }- Specified by:
fillChunkUnorderedin interfaceFillUnordered<T>- Parameters:
context- A context containing all mutable/state related data used in retrieving the Chunk.dest- The chunk to be populated according tokeyskeys- A chunk of individual, not assumed to be ordered keys to be fetched
-
fillPrevChunkUnordered
public void fillPrevChunkUnordered(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> dest, @NotNull @NotNull LongChunk<? extends RowKeys> keys) Description copied from interface:FillUnorderedPopulates a contiguous portion of the given destination chunk with prev data corresponding to the keys from the givenLongChunk.It behaves as if the following code were executed:
destination.setSize(keys.size()); for (int ii = 0; ii < keys.size(); ++ii) { destination.set(ii, getPrev(keys.get(ii))); }- Specified by:
fillPrevChunkUnorderedin interfaceFillUnordered<T>- Parameters:
context- A context containing all mutable/state related data used in retrieving the Chunk.dest- The chunk to be populated according tokeyskeys- A chunk of individual, not assumed to be ordered keys to be fetched
-
makeFillFromContext
Description copied from interface:WritableColumnSourceProvide a default, emptyChunkSink.FillFromContextfor use with our defaultWritableColumnSource.fillFromChunk(io.deephaven.engine.table.ChunkSink.FillFromContext, io.deephaven.chunk.Chunk<? extends io.deephaven.chunk.attributes.Values>, io.deephaven.engine.rowset.RowSequence).- Specified by:
makeFillFromContextin interfaceChunkSink<T>- Specified by:
makeFillFromContextin interfaceWritableColumnSource<T>
-
fillFromChunk
public void fillFromChunk(@NotNull @NotNull ChunkSink.FillFromContext context, @NotNull @NotNull Chunk<? extends Values> src, @NotNull @NotNull RowSequence rowSequence) Description copied from interface:WritableColumnSourceOur default, inefficient, implementation. Inheritors who care should provide a better implementation.- Specified by:
fillFromChunkin interfaceChunkSink<T>- Specified by:
fillFromChunkin interfaceWritableColumnSource<T>- Parameters:
context- A context containing all mutable/state related data used in writing the Chunk.src- The source of the datarowSequencerowSequence- AnRowSequencerepresenting the keys to be written
-
isImmutable
public boolean isImmutable()Description copied from interface:ColumnSourceDetermine if this column source is immutable, meaning that the values at a given row key never change.- Specified by:
isImmutablein interfaceColumnSource<T>- Returns:
- true if the values at a given row key of the column source never change, false otherwise
-
setImmutable
public void setImmutable()Description copied from interface:PossiblyImmutableColumnSourceSet this column source as having an immutable result.- Specified by:
setImmutablein interfacePossiblyImmutableColumnSource
-
providesFillUnordered
public boolean providesFillUnordered()Description copied from interface:FillUnorderedReturns true if this column source can efficiently provide an unordered fill. If this method returns false, then fillChunkUnordered and fillPrevChunkUnordered may throw an UnsupportedOperationException.- Specified by:
providesFillUnorderedin interfaceFillUnordered<T>- Returns:
- if this column source can provide an unordered fill
-
estimateSize
Return an estimate of the heap size taken by the current values within this sparse array source.Only leaf nodes and the size arrays of references are included in this estimate. Intermediate objects are ignored, and an array of references is assumed to take 8 bytes per element with no overhead.
- Returns:
- an estimate of the size of this column source's current data
-