Package com.illumon.iris.db.v2.sources
Class LongArraySource
java.lang.Object
com.illumon.iris.db.v2.sources.AbstractColumnSource<T>
com.illumon.iris.db.v2.sources.ArrayBackedColumnSource<T>
com.illumon.iris.db.v2.sources.LongArraySource
- All Implemented Interfaces:
ChunkSource<Attributes.Values>
,ChunkSource.WithPrev<Attributes.Values>
,DefaultChunkSource<Attributes.Values>
,DefaultChunkSource.WithPrev<Attributes.Values>
,FillContextMaker
,GetContextMaker
,ColumnSource<Long>
,ColumnSourceGetDefaults.ForLong
,ColumnSourceGetDefaults.LongBacked<Long>
,ConvertableTimeSource
,ElementSource<Long>
,FillUnordered
,MutableColumnSource<Long>
,MutableColumnSourceGetDefaults.ForLong
,MutableColumnSourceGetDefaults.LongBacked<Long>
,Releasable
,WritableChunkSink<Attributes.Values>
,WritableSource<Long>
,TupleExporter<Long>
,TupleSource<Long>
,ShiftData.ShiftCallback
,Serializable
public class LongArraySource extends ArrayBackedColumnSource<T> implements MutableColumnSourceGetDefaults.ForLong, ConvertableTimeSource
Simple array source for Long.
- See Also:
- Serialized Form
-
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.ConvertableTimeSource
ConvertableTimeSource.Zoned
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
Fields Modifier and Type Field Description protected UpdateCommitter<com.illumon.iris.db.v2.sources.ArraySourceHelper<T,UArray>>
prevFlusher
The presence of a prevFlusher means that this ArraySource wants to track previous values.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
-
Constructor Summary
Constructors Constructor Description LongArraySource()
-
Method Summary
Modifier and Type Method Description <ALTERNATE_DATA_TYPE>
booleanallowsReinterpret(Class<ALTERNATE_DATA_TYPE> alternateDataType)
Test if a reinterpret call will succeed.void
copy(ColumnSource<Long> sourceColumn, long sourceKey, long destKey)
void
copyFromChunk(long firstKey, long totalLength, Chunk<? extends Attributes.Values> src, int offset)
protected <ALTERNATE_DATA_TYPE>
ColumnSource<ALTERNATE_DATA_TYPE>doReinterpret(Class<ALTERNATE_DATA_TYPE> alternateDataType)
Supply allowed reinterpret results.void
ensureCapacity(long capacity)
void
ensureCapacity(long capacity, boolean nullFill)
void
fillFromChunk(WritableChunkSink.FillFromContext context, Chunk<? extends Attributes.Values> src, OrderedKeys orderedKeys)
Our default, inefficient, implementation.void
fillFromChunkUnordered(WritableChunkSink.FillFromContext context, Chunk<? extends Attributes.Values> src, LongChunk<Attributes.KeyIndices> keys)
Fills the ChunkSink with data from the source, with data corresponding to the keys from the given key chunk.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
.protected void
fillSparseChunk(WritableChunk<? super Attributes.Values> destGeneric, OrderedKeys indices)
protected <R> void
fillSparseChunk(WritableChunk<? super Attributes.Values> destGeneric, OrderedKeys indices, LongFunction<R> mapper)
protected void
fillSparseChunkUnordered(WritableChunk<? super Attributes.Values> destGeneric, LongChunk<? extends Attributes.KeyIndices> indices)
protected <R> void
fillSparseChunkUnordered(WritableChunk<? super Attributes.Values> destGeneric, LongChunk<? extends Attributes.KeyIndices> indices, LongFunction<R> mapper)
protected void
fillSparseLongChunk(WritableChunk<? super Attributes.Values> destGeneric, OrderedKeys indices)
protected void
fillSparseLongChunkUnordered(WritableChunk<? super Attributes.Values> destGeneric, LongChunk<? extends Attributes.KeyIndices> indices)
protected void
fillSparsePrevChunk(WritableChunk<? super Attributes.Values> destGeneric, OrderedKeys indices)
protected <R> void
fillSparsePrevChunk(WritableChunk<? super Attributes.Values> destGeneric, OrderedKeys indices, LongFunction<R> mapper)
protected void
fillSparsePrevChunkUnordered(WritableChunk<? super Attributes.Values> destGeneric, LongChunk<? extends Attributes.KeyIndices> indices)
protected <R> void
fillSparsePrevChunkUnordered(WritableChunk<? super Attributes.Values> destGeneric, LongChunk<? extends Attributes.KeyIndices> indices, LongFunction<R> mapper)
protected void
fillSparsePrevLongChunk(WritableChunk<? super Attributes.Values> destGeneric, OrderedKeys indices)
protected void
fillSparsePrevLongChunkUnordered(WritableChunk<? super Attributes.Values> destGeneric, LongChunk<? extends Attributes.KeyIndices> indices)
long
getAndSetUnsafe(long index, long newValue)
long
getCapacity()
Get the capacity of this column source.long
getLong(long index)
Get the value at the index as a long.long
getPrevLong(long index)
Get the previous value at the index as a long.long
getUnsafe(long index)
ChunkSource.FillContext
makeFillContext(int chunkCapacity, SharedContext sharedContext)
Allocate a newChunkSource.FillContext
for filling chunks from thisFillContextMaker
, typically aChunkSource
.WritableChunkSink.FillFromContext
makeFillFromContext(int chunkCapacity)
Provide a default, emptyWritableChunkSink.FillFromContext
for 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)
.void
move(long source, long dest, long length)
long
resetWritableChunkToBackingStore(ResettableWritableChunk chunk, long position)
Resets the given chunk to provide a write-through reference to our backing array.void
set(long key, long value)
void
set(long key, Long value)
void
setNull(long key)
void
shift(long start, long end, long offset)
void
startTrackingPrevValues()
Force my inheritors to implement this method, rather than taking the interface default.boolean
supportsTimeConversion()
Check if this class supports time conversion.ColumnSource<DBDateTime>
toDBDateTime()
Convert this source to aDBDateTime
source.LongArraySource
toEpochNano()
Convert this source to along
source of nanoseconds of epoch.ColumnSource<Instant>
toInstant()
Convert this source to anInstant
source.ColumnSource<LocalDate>
toLocalDate(ZoneId zone)
ColumnSource<LocalTime>
toLocalTime(ZoneId zone)
ColumnSource<ZonedDateTime>
toZonedDateTime(ZoneId zone)
Convert this source to aZonedDateTime
source at the specifiedzone
.Methods inherited from class com.illumon.iris.db.v2.sources.ArrayBackedColumnSource
fillChunk, fillChunkUnordered, fillPrevChunkUnordered, getChunk, getDateTimeMemoryColumnSource, getDateTimeMemoryColumnSource, getImmutableMemoryColumnSource, getImmutableMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, getMemoryColumnSource, isImmutable, set, set, set, set, set, set
Methods inherited from class com.illumon.iris.db.v2.sources.AbstractColumnSource
defaultFillChunk, getComponentType, getGroupingBuilder, getGroupingProvider, getNativeType, getType, hasGrouping, isSerializable, match, 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
fillChunk, 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
cast, createPreviousTuple, createTuple, createTupleFromValues, exportElement, exportElement, exportToExternalKey, getColumnSources, getComponentType, getGroupingBuilder, getGroupingProvider, getNativeType, getPrevSource, getType, hasGrouping, match, reinterpret, releaseCachedResources, setGroupingProvider
Methods inherited from interface com.illumon.iris.db.v2.sources.ColumnSourceGetDefaults.LongBacked
getBoolean, getByte, getChar, getDouble, getFloat, getInt, getShort
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.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.sources.MutableColumnSourceGetDefaults.ForLong
getPrev
Methods inherited from interface com.illumon.iris.db.v2.sources.MutableColumnSourceGetDefaults.LongBacked
getPrevBoolean, getPrevByte, getPrevChar, getPrevDouble, getPrevFloat, getPrevInt, getPrevShort
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
-
prevFlusher
protected transient UpdateCommitter<com.illumon.iris.db.v2.sources.ArraySourceHelper<T,UArray>> prevFlusherThe presence of a prevFlusher means that this ArraySource wants to track previous values. If prevFlusher is null, the ArraySource does not want (or does not yet want) to track previous values. Deserialized ArraySources never track previous values.
-
-
Constructor Details
-
LongArraySource
public LongArraySource()
-
-
Method Details
-
set
- Specified by:
set
in interfaceWritableSource<Long>
-
set
public final void set(long key, long value)- Specified by:
set
in interfaceWritableSource<Long>
- Overrides:
set
in classArrayBackedColumnSource<Long>
-
setNull
public void setNull(long key)- Specified by:
setNull
in interfaceWritableSource<Long>
-
getLong
public final long getLong(long index)Description copied from interface:ElementSource
Get the value at the index as a long.- Specified by:
getLong
in interfaceElementSource<Long>
- Parameters:
index
- the location in index space to get the value from.- Returns:
- the long at the index, null values are represented by
QueryConstants.NULL_LONG
-
getUnsafe
public final long getUnsafe(long index) -
getAndSetUnsafe
public final long getAndSetUnsafe(long index, long newValue) -
getPrevLong
public final long getPrevLong(long index)Description copied from interface:ElementSource
Get the previous value at the index as a long. SeeElementSource.getPrev(long)
for more details.- Specified by:
getPrevLong
in interfaceElementSource<Long>
- Parameters:
index
- the location in index space to get the previous value from.- Returns:
- the previous long at the index, null values are represented by
QueryConstants.NULL_LONG
-
copy
- Specified by:
copy
in interfaceWritableSource<Long>
-
startTrackingPrevValues
public void startTrackingPrevValues()Force my inheritors to implement this method, rather than taking the interface default.- Specified by:
startTrackingPrevValues
in interfaceColumnSource<Long>
-
ensureCapacity
public void ensureCapacity(long capacity)- Specified by:
ensureCapacity
in interfaceWritableSource<Long>
-
ensureCapacity
public void ensureCapacity(long capacity, boolean nullFill)- Specified by:
ensureCapacity
in classArrayBackedColumnSource<Long>
-
shift
public void shift(long start, long end, long offset)- Specified by:
shift
in interfaceShiftData.ShiftCallback
- Overrides:
shift
in classArrayBackedColumnSource<Long>
-
move
public void move(long source, long dest, long length) -
fillSparseChunk
protected void fillSparseChunk(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull OrderedKeys indices)- Specified by:
fillSparseChunk
in classArrayBackedColumnSource<Long>
-
fillSparseLongChunk
protected final void fillSparseLongChunk(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull OrderedKeys indices) -
fillSparsePrevChunk
protected void fillSparsePrevChunk(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull OrderedKeys indices)- Specified by:
fillSparsePrevChunk
in classArrayBackedColumnSource<Long>
-
fillSparsePrevLongChunk
protected final void fillSparsePrevLongChunk(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull OrderedKeys indices) -
fillSparseChunkUnordered
protected void fillSparseChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull LongChunk<? extends Attributes.KeyIndices> indices)- Specified by:
fillSparseChunkUnordered
in classArrayBackedColumnSource<Long>
-
fillSparseLongChunkUnordered
protected final void fillSparseLongChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull LongChunk<? extends Attributes.KeyIndices> indices) -
fillSparsePrevChunkUnordered
protected void fillSparsePrevChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull LongChunk<? extends Attributes.KeyIndices> indices)- Specified by:
fillSparsePrevChunkUnordered
in classArrayBackedColumnSource<Long>
-
fillSparsePrevLongChunkUnordered
protected final void fillSparsePrevLongChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull LongChunk<? extends Attributes.KeyIndices> indices) -
fillSparseChunk
protected <R> void fillSparseChunk(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull OrderedKeys indices, LongFunction<R> mapper) -
fillSparsePrevChunk
protected <R> void fillSparsePrevChunk(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull OrderedKeys indices, LongFunction<R> mapper) -
fillSparseChunkUnordered
protected <R> void fillSparseChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull LongChunk<? extends Attributes.KeyIndices> indices, LongFunction<R> mapper) -
fillSparsePrevChunkUnordered
protected <R> void fillSparsePrevChunkUnordered(@NotNull WritableChunk<? super Attributes.Values> destGeneric, @NotNull LongChunk<? extends Attributes.KeyIndices> indices, LongFunction<R> mapper) -
resetWritableChunkToBackingStore
public long resetWritableChunkToBackingStore(@NotNull ResettableWritableChunk chunk, long position)Description copied from class:ArrayBackedColumnSource
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!- Specified by:
resetWritableChunkToBackingStore
in classArrayBackedColumnSource<Long>
- Parameters:
chunk
- the writable chunk to reset to our backing array.position
- position that we require- Returns:
- the first position addressable by the chunk
-
copyFromChunk
public void copyFromChunk(long firstKey, long totalLength, Chunk<? extends Attributes.Values> src, int offset) -
fillFromChunkUnordered
public void fillFromChunkUnordered(@NotNull WritableChunkSink.FillFromContext context, @NotNull Chunk<? extends Attributes.Values> src, @NotNull LongChunk<Attributes.KeyIndices> keys)Description copied from interface:WritableChunkSink
Fills the ChunkSink with data from the source, with data corresponding to the keys from the given key chunk.- Specified by:
fillFromChunkUnordered
in interfaceWritableChunkSink<Attributes.Values>
- Specified by:
fillFromChunkUnordered
in interfaceWritableSource<Long>
- Parameters:
context
- A context containing all mutable/state related data used in writing the Chunk.src
- The source of the dataorderedKeys
keys
- ALongChunk
representing the keys to be written
-
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<Long>
- Overrides:
allowsReinterpret
in classAbstractColumnSource<Long>
- Type Parameters:
ALTERNATE_DATA_TYPE
- the dataType to inquire about- Parameters:
alternateDataType
- The alternative type to consider- Returns:
- If a reinterpret on this column source with the supplied alternateDataType will succeed.
-
doReinterpret
protected <ALTERNATE_DATA_TYPE> ColumnSource<ALTERNATE_DATA_TYPE> doReinterpret(@NotNull Class<ALTERNATE_DATA_TYPE> alternateDataType)Description copied from class:AbstractColumnSource
Supply allowed reinterpret results. The default implementation handles the most common case to avoid code duplication.- Overrides:
doReinterpret
in classAbstractColumnSource<Long>
- Type Parameters:
ALTERNATE_DATA_TYPE
- the dataType to reinterpret to- Parameters:
alternateDataType
- The alternate data type- Returns:
- The resulting
ColumnSource
-
supportsTimeConversion
public boolean supportsTimeConversion()Description copied from interface:ConvertableTimeSource
Check if this class supports time conversion. If false, all other methods will fail.- Specified by:
supportsTimeConversion
in interfaceConvertableTimeSource
- Returns:
- true if time conversion is supported.
-
toZonedDateTime
Description copied from interface:ConvertableTimeSource
Convert this source to aZonedDateTime
source at the specifiedzone
.- Specified by:
toZonedDateTime
in interfaceConvertableTimeSource
- Parameters:
zone
- the time zone- Returns:
- a view of this source as a
ZonedDateTime
-
toLocalDate
Description copied from interface:ConvertableTimeSource
- Specified by:
toLocalDate
in interfaceConvertableTimeSource
- Parameters:
zone
- the time zone- Returns:
- a view of this source as a
LocalDate
-
toLocalTime
Description copied from interface:ConvertableTimeSource
- Specified by:
toLocalTime
in interfaceConvertableTimeSource
- Parameters:
zone
- the time zone- Returns:
- a view of this source as a
LocalTime
-
toDBDateTime
Description copied from interface:ConvertableTimeSource
Convert this source to aDBDateTime
source.- Specified by:
toDBDateTime
in interfaceConvertableTimeSource
- Returns:
- a view of this source as a
DBDateTime
-
toInstant
Description copied from interface:ConvertableTimeSource
Convert this source to anInstant
source.- Specified by:
toInstant
in interfaceConvertableTimeSource
- Returns:
- a view of this source as a
Instant
-
toEpochNano
Description copied from interface:ConvertableTimeSource
Convert this source to along
source of nanoseconds of epoch.- Specified by:
toEpochNano
in interfaceConvertableTimeSource
- Returns:
- a view of this source as a
ZonedDateTime
-
makeFillContext
Description copied from interface:FillContextMaker
Allocate a newChunkSource.FillContext
for filling chunks from thisFillContextMaker
, typically aChunkSource
.- Parameters:
chunkCapacity
- The maximum size of anyWritableChunk
that will be filled with this contextsharedContext
- Shared store of intermediate results.- Returns:
- A context for use with fill operations
-
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>
- Overrides:
fillPrevChunk
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
-
getCapacity
public final long getCapacity()Get the capacity of this column source. This number is one higher than the highest key that may be accessed (read or written).- Returns:
- The capacity of this column source
-
makeFillFromContext
Description copied from interface:WritableSource
Provide a default, emptyWritableChunkSink.FillFromContext
for 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)
. -
fillFromChunk
public void fillFromChunk(@NotNull WritableChunkSink.FillFromContext context, @NotNull Chunk<? extends Attributes.Values> src, @NotNull OrderedKeys orderedKeys)Description copied from interface:WritableSource
Our default, inefficient, implementation. Inheritors who care should provide a better implementation.- Parameters:
context
- A context containing all mutable/state related data used in writing the Chunk.src
- The source of the dataorderedKeys
orderedKeys
- AnOrderedKeys
representing the keys to be written
-