Package com.illumon.iris.db.v2.sources
Class SparseArrayColumnSource<T>
java.lang.Object
com.illumon.iris.db.v2.sources.AbstractColumnSource<T>
com.illumon.iris.db.v2.sources.SparseArrayColumnSource<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>,Serializable
- Direct Known Subclasses:
BooleanSparseArraySource,ByteSparseArraySource,CharacterSparseArraySource,DoubleSparseArraySource,FloatSparseArraySource,IntegerSparseArraySource,LongSparseArraySource,NanosBasedTimeSparseArraySource,ObjectSparseArraySource,ShortSparseArraySource
public abstract class SparseArrayColumnSource<T>
extends AbstractColumnSource<T>
implements FillUnordered, WritableSource<T>
A column source backed by arrays that may not be filled in all blocks.
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 index 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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classNested classes/interfaces inherited from class com.illumon.iris.db.v2.sources.AbstractColumnSource
AbstractColumnSource.DefaultedImmutable<DATA_TYPE>, AbstractColumnSource.DefaultedMutable<DATA_TYPE>, AbstractColumnSource.IsSerializableNested 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, typeFields inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource
DEFAULT_FILL_INSTANCE, ZERO_LENGTH_CHUNK_SOURCE_ARRAYFields inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource.WithPrev
ZERO_LENGTH_CHUNK_SOURCE_WITH_PREV_ARRAYFields inherited from interface com.illumon.iris.db.v2.sources.ColumnSource
ZERO_LENGTH_COLUMN_SOURCE_ARRAYFields inherited from interface com.illumon.iris.db.v2.sources.WritableChunkSink
DEFAULT_FILL_FROM_INSTANCEFields inherited from interface com.illumon.iris.db.v2.sources.WritableSource
ZERO_LENGTH_WRITABLE_SOURCE_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionvoidfillChunk(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> dest, OrderedKeys orderedKeys) Populates the given destination chunk with data corresponding to the keys from the givenOrderedKeys.voidfillChunkUnordered(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> dest, LongChunk<? extends Attributes.KeyIndices> keys) Populates a contiguous portion of the given destination chunk with data corresponding to the keys from the givenLongChunk.voidfillFromChunk(WritableChunkSink.FillFromContext context, Chunk<? extends Attributes.Values> src, OrderedKeys orderedKeys) Our default, inefficient, implementation.voidfillPrevChunkUnordered(ChunkSource.FillContext context, WritableChunk<? super Attributes.Values> dest, LongChunk<? extends Attributes.KeyIndices> keys) Populates a contiguous portion of the given destination chunk with prev data corresponding to the keys from the givenLongChunk.static SparseArrayColumnSource<DBDateTime>getDateTimeMemoryColumnSource(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> SparseArrayColumnSource<T>getSparseMemoryColumnSource(long size, Class<T> type) static <T> SparseArrayColumnSource<T>getSparseMemoryColumnSource(long size, Class<T> type, Class componentType) static SparseArrayColumnSource<Short>getSparseMemoryColumnSource(short[] data) static <T> SparseArrayColumnSource<T>getSparseMemoryColumnSource(Class<T> type) static <T> SparseArrayColumnSource<T>getSparseMemoryColumnSource(Class<T> type, Class componentType) static ColumnSourcegetSparseMemoryColumnSource(Object dataArray) static <T> SparseArrayColumnSource<T>getSparseMemoryColumnSource(Collection<T> data, Class<T> type) booleanDetermine if this column source is immutable, meaning that the values at a given index key never change.makeFillFromContext(int chunkCapacity) Provide a default, emptyWritableChunkSink.FillFromContextfor use with our defaultWritableSource.fillFromChunk(com.illumon.iris.db.v2.sources.WritableChunkSink.FillFromContext, com.illumon.iris.db.v2.sources.chunk.Chunk<? extends com.illumon.iris.db.v2.sources.chunk.Attributes.Values>, com.illumon.iris.db.v2.utils.OrderedKeys).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) voidvoidsetNull(OrderedKeys orderedKeys) voidshift(ReadOnlyIndex keysToShift, long shiftDelta) 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, setGroupingProviderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource
getChunkTypeMethods inherited from interface com.illumon.iris.db.v2.sources.chunk.ChunkSource.WithPrev
fillPrevChunkMethods 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, startTrackingPrevValuesMethods inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource
getChunk, getChunk, getChunkByFilling, makeFillContext, makeGetContextMethods inherited from interface com.illumon.iris.db.v2.sources.chunk.DefaultChunkSource.WithPrev
getPrevChunk, getPrevChunk, getPrevChunkByFillingMethods 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, getShortMethods inherited from interface com.illumon.iris.db.v2.sources.chunk.FillContextMaker
makeFillContextMethods inherited from interface com.illumon.iris.db.v2.sources.chunk.GetContextMaker
makeGetContextMethods inherited from interface com.illumon.iris.db.v2.tuples.TupleExporter
exportElementReinterpretedMethods inherited from interface com.illumon.iris.db.v2.tuples.TupleSource
createTupleFromReinterpretedValuesMethods inherited from interface com.illumon.iris.db.v2.sources.WritableSource
copy, ensureCapacity, fillFromChunkUnordered, set, setNull
-
Field Details
-
ZERO_LENGTH_SPARSE_ARRAY_COLUMN_SOURCE_ARRAY
-
-
Method Details
-
set
public void set(long key, byte value) - Specified by:
setin interfaceWritableSource<T>
-
set
public void set(long key, char value) - Specified by:
setin interfaceWritableSource<T>
-
set
public void set(long key, double value) - Specified by:
setin interfaceWritableSource<T>
-
set
public void set(long key, float value) - Specified by:
setin interfaceWritableSource<T>
-
set
public void set(long key, int value) - Specified by:
setin interfaceWritableSource<T>
-
set
public void set(long key, long value) - Specified by:
setin interfaceWritableSource<T>
-
set
public void set(long key, short value) - Specified by:
setin interfaceWritableSource<T>
-
shift
-
remove
-
getSparseMemoryColumnSource
public static <T> SparseArrayColumnSource<T> getSparseMemoryColumnSource(Collection<T> data, Class<T> type) -
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getDateTimeMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
public static <T> SparseArrayColumnSource<T> getSparseMemoryColumnSource(Class<T> type, Class componentType) -
getSparseMemoryColumnSource
-
getSparseMemoryColumnSource
public static <T> SparseArrayColumnSource<T> getSparseMemoryColumnSource(long size, Class<T> type, @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 ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> dest, @NotNull OrderedKeys orderedKeys) Description copied from interface:ChunkSourcePopulates the given destination chunk with data corresponding to the keys from the givenOrderedKeys.- 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 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- AnOrderedKeysrepresenting the keys to be fetched
-
setNull
- Specified by:
setNullin interfaceWritableSource<T>
-
fillChunkUnordered
public void fillChunkUnordered(@NotNull ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> dest, @NotNull LongChunk<? extends Attributes.KeyIndices> keys) Description copied from interface:FillUnorderedPopulates a contiguous portion of the given destination chunk with data corresponding to the keys from the givenLongChunk.- Specified by:
fillChunkUnorderedin interfaceFillUnordered- 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 ChunkSource.FillContext context, @NotNull WritableChunk<? super Attributes.Values> dest, @NotNull LongChunk<? extends Attributes.KeyIndices> keys) Description copied from interface:FillUnorderedPopulates a contiguous portion of the given destination chunk with prev data corresponding to the keys from the givenLongChunk.- Specified by:
fillPrevChunkUnorderedin interfaceFillUnordered- 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:WritableSourceProvide a default, emptyWritableChunkSink.FillFromContextfor use with our defaultWritableSource.fillFromChunk(com.illumon.iris.db.v2.sources.WritableChunkSink.FillFromContext, com.illumon.iris.db.v2.sources.chunk.Chunk<? extends com.illumon.iris.db.v2.sources.chunk.Attributes.Values>, com.illumon.iris.db.v2.utils.OrderedKeys).- Specified by:
makeFillFromContextin interfaceWritableChunkSink<T>- Specified by:
makeFillFromContextin interfaceWritableSource<T>
-
fillFromChunk
public void fillFromChunk(@NotNull WritableChunkSink.FillFromContext context, @NotNull Chunk<? extends Attributes.Values> src, @NotNull OrderedKeys orderedKeys) Description copied from interface:WritableSourceOur default, inefficient, implementation. Inheritors who care should provide a better implementation.- Specified by:
fillFromChunkin interfaceWritableChunkSink<T>- Specified by:
fillFromChunkin interfaceWritableSource<T>- Parameters:
context- A context containing all mutable/state related data used in writing the Chunk.src- The source of the dataorderedKeysorderedKeys- AnOrderedKeysrepresenting 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 index key never change.- Specified by:
isImmutablein interfaceColumnSource<T>- Returns:
- true if the values at a given index of the column source never change, false otherwise
-
setImmutable
public void setImmutable()
-