Class ChunkOffsetInteger
- All Implemented Interfaces:
IArray
,IArrayWriter
,IPositionalReader
,IWritableArray
,IChunk<Integer>
,IChunkInteger
,IMemoryMonitored
,IInternalMemoryMonitored
- Author:
- ActiveViam
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.activeviam.tech.observability.internal.memory.IInternalMemoryMonitored
IInternalMemoryMonitored.IMemoryCollector
-
Field Summary
Fields inherited from interface com.activeviam.tech.chunks.internal.IChunk
NO_SIZE_LIMIT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompress
(IRowMapping mapping, int[] arrayMapping, int newChunkSize, IChunkFactory<Integer> defaultChunkCreator) Creates a compressed chunk from this chunk, using only the rows given in the mapping.boolean
equals
(int position, int value) Tests if the record stored at that position is equal to a value.void
fill
(int value) Fills all slots in the chunk with the same value.int
getOrder()
Gets this chunk order, i.e.read
(int position) Returns the data stored at that position in the chunk.double
readDouble
(int position) Reads a double primitive value from the array.float
readFloat
(int position) Reads a float primitive value from the array.int
readInt
(int position) Reads an int primitive value from the array.long
readLong
(int position) Reads a long primitive value from the array.void
transfer
(IWritableTable destination, int destinationColumn, int[] rowsMapping, int numRows) Transfers a given number of rows from this chunk to target rows in the given column of the destinationtable
.void
Writes a piece of data at a position in the array.void
writeInt
(int position, int value) Writes an int primitive value in the array.Methods inherited from class com.activeviam.tech.chunks.internal.impl.AChunkOffset
capacity, destroy, findRowsEqualTo, findRowsEqualTo, findRowsEqualTo, findRowsInSet, findRowsInSet, findRowsInSet, findRowsInTransactionEqualTo, findRowsInTransactionEqualTo, findRowsInTransactionEqualTo, findRowsInTransactionInSet, findRowsInTransactionInSet, findRowsInTransactionInSet, getChunkType, getMemoryStatistic, isDead, isNull, isPrimitive, reset
Methods inherited from class com.activeviam.tech.chunks.internal.impl.AChunk
getChunkId
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.activeviam.tech.chunks.api.arrays.IArrayWriter
addDouble, addFloat, addInt, addLong, writeBoolean, writeDouble, writeFloat, writeLong
Methods inherited from interface com.activeviam.tech.chunks.internal.IChunk
capacity, createArrayCursor, destroy, findRowsEqualTo, findRowsEqualTo, findRowsEqualTo, findRowsInSet, findRowsInSet, findRowsInSet, findRowsInTransactionEqualTo, findRowsInTransactionEqualTo, findRowsInTransactionEqualTo, findRowsInTransactionInSet, findRowsInTransactionInSet, findRowsInTransactionInSet, freeRow, getChunkCreatorForSparse, getChunkId, getChunkType, getPhysicalSize, isDead, localRow, replaceBy, reset, sparseChunkCompression
Methods inherited from interface com.activeviam.tech.chunks.internal.IChunkInteger
copyInto, createFrequentValueChunk, getBindingType, isPrimitive, writeFromCell
Methods inherited from interface com.activeviam.tech.observability.internal.memory.IInternalMemoryMonitored
getMemoryStatistic, getMemoryStatistic
Methods inherited from interface com.activeviam.tech.chunks.api.arrays.IPositionalReader
isNull, readBoolean, readVector
-
Constructor Details
-
ChunkOffsetInteger
Constructor.- Parameters:
underlying
- the underlying chunk storing the actual dataoffset
- the offset of the data
-
-
Method Details
-
read
Description copied from interface:IChunk
Returns the data stored at that position in the chunk.- Specified by:
read
in interfaceIChunk<Integer>
- Specified by:
read
in interfaceIChunkInteger
- Specified by:
read
in interfaceIPositionalReader
- Parameters:
position
- the position in the chunk at which to read- Returns:
- the data stored at that position in the chunk
-
readInt
public int readInt(int position) Description copied from interface:IPositionalReader
Reads an int primitive value from the array.An exception is thrown if the value is not of the right type.
- Specified by:
readInt
in interfaceIChunkInteger
- Specified by:
readInt
in interfaceIPositionalReader
- Parameters:
position
- 0-based index in an array- Returns:
- int value
-
readLong
public long readLong(int position) Description copied from interface:IPositionalReader
Reads a long primitive value from the array.An exception is thrown if the value is not of the right type.
- Specified by:
readLong
in interfaceIChunkInteger
- Specified by:
readLong
in interfaceIPositionalReader
- Parameters:
position
- 0-based index in an array- Returns:
- long value
-
readFloat
public float readFloat(int position) Description copied from interface:IPositionalReader
Reads a float primitive value from the array.An exception is thrown if the value is not of the right type.
- Specified by:
readFloat
in interfaceIChunkInteger
- Specified by:
readFloat
in interfaceIPositionalReader
- Parameters:
position
- 0-based index in an array- Returns:
- float value
-
readDouble
public double readDouble(int position) Description copied from interface:IPositionalReader
Reads a double primitive value from the array.An exception is thrown if the value is not of the right type.
- Specified by:
readDouble
in interfaceIChunkInteger
- Specified by:
readDouble
in interfaceIPositionalReader
- Parameters:
position
- 0-based index in an array- Returns:
- double value
-
write
Description copied from interface:IArrayWriter
Writes a piece of data at a position in the array.For better performance, use the primitive type operations.
- Specified by:
write
in interfaceIArrayWriter
- Specified by:
write
in interfaceIChunkInteger
- Overrides:
write
in classAChunkOffset<Integer,
IChunkInteger> - Parameters:
position
- 0-based index in the arrayvalue
- the value to write
-
writeInt
public void writeInt(int position, int value) Description copied from interface:IArrayWriter
Writes an int primitive value in the array.- Specified by:
writeInt
in interfaceIArrayWriter
- Specified by:
writeInt
in interfaceIChunkInteger
- Parameters:
position
- 0-based index in the arrayvalue
- the value to write
-
transfer
public void transfer(IWritableTable destination, int destinationColumn, int[] rowsMapping, int numRows) Description copied from interface:IChunk
Transfers a given number of rows from this chunk to target rows in the given column of the destinationtable
.The mapping from the source rows to the target rows is described with an array of
2*n
slots. Each even slot contains the index of the row to be copied from the source chunk and the following odd slot contains the index of the row into which the source data will be transferred.- Specified by:
transfer
in interfaceIChunk<Integer>
- Specified by:
transfer
in interfaceIChunkInteger
- Parameters:
destination
- the destination tabledestinationColumn
- the column to transfer the data to in the destination tablerowsMapping
- the mapping from source rows to target rows, as explained abovenumRows
- the number of rows to transfer
-
equals
public boolean equals(int position, int value) Description copied from interface:IChunkInteger
Tests if the record stored at that position is equal to a value.- Specified by:
equals
in interfaceIChunkInteger
- Parameters:
position
- the position to readvalue
- the value to compare- Returns:
true
if the read value is the same as the given value,false
otherwise
-
compress
public IChunk<Integer> compress(IRowMapping mapping, int[] arrayMapping, int newChunkSize, IChunkFactory<Integer> defaultChunkCreator) Description copied from interface:IChunk
Creates a compressed chunk from this chunk, using only the rows given in the mapping. The mapping is given in different representations :- The mapping as an
IRowMapping
from the rows of the externally visible chunk to those of the compressed chunk. This representation corresponds to the mapping used inSparseChunk
- The arrayMapping as an array of
2*n
slots. This representation corresponds to the mapping used inIChunkBinding.transfer(int[], int)
. Each even slot contains the index of the row to be copied from this chunk and the following odd slot contains the index of the row into which the data will be in the compressed chunk.
Note that the two representations of the mapping can seem inconsistent, in case we are recompressing the underlying chunk of a sparse chunk (the
IRowMapping
maps the externally visible rows to the rows of the future underlying of the future re-compressed chunk, while the arrayMapping maps the rows of current underlying chunk to the future underlying of re-compressed chunk).- Specified by:
compress
in interfaceIChunk<Integer>
- Parameters:
mapping
- the mapping from the rows of the externally visible chunk to those of the compressed chunkarrayMapping
- the array representation of the mappingnewChunkSize
- the size of the chunk we want to createdefaultChunkCreator
- the chunk creator for a "normal" chunk (if this chunks knows of a better way to sparse itself, it can use it)- Returns:
- a compressed chunk containing the copied data from this chunk
- The mapping as an
-
getOrder
public int getOrder()Description copied from interface:IChunkInteger
Gets this chunk order, i.e. the number of bits used to represent this chunk data.If the actual data can be represented with fewer bits, the compression will create a chunk with a lower order.
- Specified by:
getOrder
in interfaceIChunkInteger
- Returns:
- the current chunk order
-
fill
public void fill(int value) Description copied from interface:IChunkInteger
Fills all slots in the chunk with the same value.- Specified by:
fill
in interfaceIChunkInteger
- Parameters:
value
- the value to fill the chunk with
-