Class ChunkOffsetInteger

All Implemented Interfaces:
IArray, IArrayWriter, IPositionalReader, IWritableArray, IChunk<Integer>, IChunkInteger, IMemoryMonitored, IInternalMemoryMonitored

public class ChunkOffsetInteger extends AChunkOffset<Integer,IChunkInteger> implements IChunkInteger
A chunk of integers that offset all the values of the underlying chunk.
Author:
ActiveViam
  • Constructor Details

    • ChunkOffsetInteger

      public ChunkOffsetInteger(IChunkInteger underlying, int offset)
      Constructor.
      Parameters:
      underlying - the underlying chunk storing the actual data
      offset - the offset of the data
  • Method Details

    • read

      public Integer read(int position)
      Description copied from interface: IChunk
      Returns the data stored at that position in the chunk.
      Specified by:
      read in interface IChunk<Integer>
      Specified by:
      read in interface IChunkInteger
      Specified by:
      read in interface IPositionalReader
      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 interface IChunkInteger
      Specified by:
      readInt in interface IPositionalReader
      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 interface IChunkInteger
      Specified by:
      readLong in interface IPositionalReader
      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 interface IChunkInteger
      Specified by:
      readFloat in interface IPositionalReader
      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 interface IChunkInteger
      Specified by:
      readDouble in interface IPositionalReader
      Parameters:
      position - 0-based index in an array
      Returns:
      double value
    • write

      public void write(int position, Object value)
      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 interface IArrayWriter
      Specified by:
      write in interface IChunkInteger
      Overrides:
      write in class AChunkOffset<Integer,IChunkInteger>
      Parameters:
      position - 0-based index in the array
      value - 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 interface IArrayWriter
      Specified by:
      writeInt in interface IChunkInteger
      Parameters:
      position - 0-based index in the array
      value - 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 destination table.

      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 interface IChunk<Integer>
      Specified by:
      transfer in interface IChunkInteger
      Parameters:
      destination - the destination table
      destinationColumn - the column to transfer the data to in the destination table
      rowsMapping - the mapping from source rows to target rows, as explained above
      numRows - 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 interface IChunkInteger
      Parameters:
      position - the position to read
      value - 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 in SparseChunk
      • The arrayMapping as an array of 2*n slots. This representation corresponds to the mapping used in IChunkBinding.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 interface IChunk<Integer>
      Parameters:
      mapping - the mapping from the rows of the externally visible chunk to those of the compressed chunk
      arrayMapping - the array representation of the mapping
      newChunkSize - the size of the chunk we want to create
      defaultChunkCreator - 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
    • 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 interface IChunkInteger
      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 interface IChunkInteger
      Parameters:
      value - the value to fill the chunk with