java.lang.Object
com.activeviam.tech.records.internal.impl.ARecordReader
com.activeviam.tech.records.internal.impl.Record
All Implemented Interfaces:
IArray, IArrayReader, IArrayWriter, IPositionalReader, IWritableArray, IRecord, IRecordReader, IWritableRecord, IByteRecord, IWritableByteRecord, Serializable

public class Record extends ARecordReader implements IWritableByteRecord, Serializable
Standard record implementation. Field values that have a natural, fixed length representation are stored in a byte array, the other field values are stored as java objects.

Example: A Record stores :

 | int  | Date          | long          | long          |
 |----- |------------   |-------- |--------     |
 | 0    | 12/24/2020    | null    | 1L          |
 

It is stored as: primitive data: [0 encoded over 4 bytes, 1L encoded over 8 bytes, 1L encoded over 8 bytes] (length: 20) nulls: [00000100] (length 1) is a bitmap raising a null flag using little-endian bit order. objectData [12/24/2020] (length 1)

Null values for not primitive types are stored in objectData, not in the nulls array.

Author:
ActiveViam
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDouble(int position, double addedValue)
    Adds a double primitive value to an element of the array.
    void
    addFloat(int position, float addedValue)
    Adds a float primitive value to an element of the array.
    void
    addInt(int position, int addedValue)
    Adds a long primitive value to an element of the array.
    void
    addLong(int position, long addedValue)
    Adds a int primitive value to an element of the array.
    Creates a new read-only cursor that can be moved up and down the array.
    boolean
    equals(Object other)
     
    Gets the format of the record.
    byte[]
    Get the primitive data null flags (as a bitmap).
    int
    Get the offset at which the null flags are stored in the global null flag offset.
    Returns the array containing the objects of this record at the position IByteRecord.getObjectDataOffset().
    int
    Returns the position where reading for objects of this IRecord should start.
    byte[]
    Returns the byte array including the primitive data of this record at the position IByteRecord.getPrimitiveDataOffset().
    int
    Returns the index in IByteRecord.getPrimitiveData() where the data related to this instance is stored.
    int
     
    boolean
    isNull(int fieldIndex)
    Gets whether null is stored in a given row at a given position.
    static int
    nullFlagsSize(int primitiveFieldsCount)
    Gets the size of the array required to store all bit flags for null values for primitiveFieldsCount primitive fields.
    read(int fieldIndex)
    Reads a value at some index in an array.
    boolean
    readBoolean(int fieldIndex)
    Reads a boolean primitive value from the array.
    double
    readDouble(int fieldIndex)
    Reads a double primitive value from the array.
    float
    readFloat(int fieldIndex)
    Reads a float primitive value from the array.
    int
    readHashCode(int fieldIndex)
    Reads the hash code of the value stored at that index.
    int
    readInt(int fieldIndex)
    Reads an int primitive value from the array.
    long
    readLong(int fieldIndex)
    Reads a long primitive value from the array.
    void
    Transfers the content of this record into a record acceptor.
    void
    transfer(Object[] tuple)
    Writes the data from this record into an existing tuple.
    void
    transferFromTable(ITable sourceTable, int sourceRowIndex, int[] columnIds)
    Transfers into this IWritableRecord the values that can be found in the given table, at the given row, and at the given columns.
    void
    write(int fieldIndex, Object value)
    Writes a piece of data at a position in the array.
    void
    writeBoolean(int fieldIndex, boolean value)
    Writes a boolean primitive value in the array.
    void
    writeDouble(int fieldIndex, double value)
    Writes a double primitive value in the array.
    void
    writeFloat(int fieldIndex, float value)
    Writes a float primitive value in the array.
    void
    writeInt(int fieldIndex, int value)
    Writes an int primitive value in the array.
    void
    writeLong(int fieldIndex, long value)
    Writes a long primitive value in the array.

    Methods inherited from class com.activeviam.tech.records.internal.impl.ARecordReader

    read, toString

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.activeviam.tech.chunks.api.arrays.IPositionalReader

    readVector

    Methods inherited from interface com.activeviam.tech.records.api.IRecordReader

    copy, read, size, toList, toTuple
  • Method Details

    • transfer

      public void transfer(IRecordAcceptor acceptor)
      Description copied from interface: IRecordReader
      Transfers the content of this record into a record acceptor.
      Specified by:
      transfer in interface IRecordReader
      Parameters:
      acceptor - the record acceptor
    • transfer

      public void transfer(Object[] tuple)
      Description copied from interface: IRecordReader
      Writes the data from this record into an existing tuple.
      Specified by:
      transfer in interface IRecordReader
      Parameters:
      tuple - the receiving tuple
    • transferFromTable

      public void transferFromTable(ITable sourceTable, int sourceRowIndex, int[] columnIds)
      Description copied from interface: IWritableRecord
      Transfers into this IWritableRecord the values that can be found in the given table, at the given row, and at the given columns.

      For each given index i in this IWritableRecord, the table's value at the column columnIds[i] and row sourceRowIndex is written into the record, at the index i.

      It is the caller's responsibility to ensure that the types won't conflict.

      Specified by:
      transferFromTable in interface IWritableRecord
      Parameters:
      sourceTable - the table from which the record's data will be retrieved
      sourceRowIndex - the row at which the data is retrieved from the table
      columnIds - the indexes of the column
    • getFormat

      public IRecordFormat getFormat()
      Description copied from interface: IRecordReader
      Gets the format of the record.
      Specified by:
      getFormat in interface IRecordReader
      Returns:
      the format of the record
    • read

      public Object read(int fieldIndex)
      Description copied from interface: IPositionalReader
      Reads a value at some index in an array.
      Specified by:
      read in interface IPositionalReader
      Parameters:
      fieldIndex - 0-based index in an array
      Returns:
      the data stored at that position in the array
    • readBoolean

      public boolean readBoolean(int fieldIndex)
      Description copied from interface: IPositionalReader
      Reads a boolean primitive value from the array.

      An exception is thrown if the value is not of the right type.

      Specified by:
      readBoolean in interface IPositionalReader
      Parameters:
      fieldIndex - 0-based index in an array
      Returns:
      boolean value
    • readInt

      public int readInt(int fieldIndex)
      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 IPositionalReader
      Parameters:
      fieldIndex - 0-based index in an array
      Returns:
      int value
    • readLong

      public long readLong(int fieldIndex)
      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 IPositionalReader
      Parameters:
      fieldIndex - 0-based index in an array
      Returns:
      long value
    • readFloat

      public float readFloat(int fieldIndex)
      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 IPositionalReader
      Parameters:
      fieldIndex - 0-based index in an array
      Returns:
      float value
    • readDouble

      public double readDouble(int fieldIndex)
      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 IPositionalReader
      Parameters:
      fieldIndex - 0-based index in an array
      Returns:
      double value
    • isNull

      public boolean isNull(int fieldIndex)
      Description copied from interface: IPositionalReader
      Gets whether null is stored in a given row at a given position.
      Specified by:
      isNull in interface IPositionalReader
      Parameters:
      fieldIndex - 0-based index in an array
      Returns:
      true if the element stored at that position is null, false otherwise
    • write

      public void write(int fieldIndex, 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
      Parameters:
      fieldIndex - 0-based index in the array
      value - the value to write
    • writeInt

      public void writeInt(int fieldIndex, int value)
      Description copied from interface: IArrayWriter
      Writes an int primitive value in the array.
      Specified by:
      writeInt in interface IArrayWriter
      Parameters:
      fieldIndex - 0-based index in the array
      value - the value to write
    • writeDouble

      public void writeDouble(int fieldIndex, double value)
      Description copied from interface: IArrayWriter
      Writes a double primitive value in the array.
      Specified by:
      writeDouble in interface IArrayWriter
      Parameters:
      fieldIndex - 0-based index in the array
      value - the value to write
    • writeBoolean

      public void writeBoolean(int fieldIndex, boolean value)
      Description copied from interface: IArrayWriter
      Writes a boolean primitive value in the array.
      Specified by:
      writeBoolean in interface IArrayWriter
      Parameters:
      fieldIndex - 0-based index in the array
      value - the value to write
    • writeFloat

      public void writeFloat(int fieldIndex, float value)
      Description copied from interface: IArrayWriter
      Writes a float primitive value in the array.
      Specified by:
      writeFloat in interface IArrayWriter
      Parameters:
      fieldIndex - 0-based index in the array
      value - the value to write
    • writeLong

      public void writeLong(int fieldIndex, long value)
      Description copied from interface: IArrayWriter
      Writes a long primitive value in the array.
      Specified by:
      writeLong in interface IArrayWriter
      Parameters:
      fieldIndex - 0-based index in the array
      value - the value to write
    • readHashCode

      public int readHashCode(int fieldIndex)
      Description copied from interface: IRecordReader
      Reads the hash code of the value stored at that index.
      Specified by:
      readHashCode in interface IRecordReader
      Parameters:
      fieldIndex - index of a field to read
      Returns:
      hash code
    • addLong

      public void addLong(int position, long addedValue)
      Description copied from interface: IArrayWriter
      Adds a int primitive value to an element of the array.
      Specified by:
      addLong in interface IArrayWriter
      Parameters:
      position - 0-based index in the array
      addedValue - the value to add
    • addInt

      public void addInt(int position, int addedValue)
      Description copied from interface: IArrayWriter
      Adds a long primitive value to an element of the array.
      Specified by:
      addInt in interface IArrayWriter
      Parameters:
      position - 0-based index in the array
      addedValue - the value to add
    • addDouble

      public void addDouble(int position, double addedValue)
      Description copied from interface: IArrayWriter
      Adds a double primitive value to an element of the array.
      Specified by:
      addDouble in interface IArrayWriter
      Parameters:
      position - 0-based index in the array
      addedValue - the value to add
    • addFloat

      public void addFloat(int position, float addedValue)
      Description copied from interface: IArrayWriter
      Adds a float primitive value to an element of the array.
      Specified by:
      addFloat in interface IArrayWriter
      Parameters:
      position - 0-based index in the array
      addedValue - the value to add
    • nullFlagsSize

      public static int nullFlagsSize(int primitiveFieldsCount)
      Gets the size of the array required to store all bit flags for null values for primitiveFieldsCount primitive fields.
      Parameters:
      primitiveFieldsCount - the number of primitive fields
      Returns:
      the size of the array
    • getPrimitiveData

      public byte[] getPrimitiveData()
      Description copied from interface: IByteRecord
      Returns the byte array including the primitive data of this record at the position IByteRecord.getPrimitiveDataOffset().
      Specified by:
      getPrimitiveData in interface IByteRecord
    • getPrimitiveDataOffset

      public int getPrimitiveDataOffset()
      Description copied from interface: IByteRecord
      Returns the index in IByteRecord.getPrimitiveData() where the data related to this instance is stored.
      Specified by:
      getPrimitiveDataOffset in interface IByteRecord
    • getNullFlags

      public byte[] getNullFlags()
      Description copied from interface: IByteRecord
      Get the primitive data null flags (as a bitmap).
      Specified by:
      getNullFlags in interface IByteRecord
    • getNullFlagsOffset

      public int getNullFlagsOffset()
      Description copied from interface: IByteRecord
      Get the offset at which the null flags are stored in the global null flag offset.
      Specified by:
      getNullFlagsOffset in interface IByteRecord
    • getObjectData

      public Object[] getObjectData()
      Description copied from interface: IByteRecord
      Returns the array containing the objects of this record at the position IByteRecord.getObjectDataOffset().
      Specified by:
      getObjectData in interface IByteRecord
    • getObjectDataOffset

      public int getObjectDataOffset()
      Description copied from interface: IByteRecord
      Returns the position where reading for objects of this IRecord should start.
      Specified by:
      getObjectDataOffset in interface IByteRecord
    • createArrayCursor

      public IArrayCursor createArrayCursor()
      Description copied from interface: IArray
      Creates a new read-only cursor that can be moved up and down the array. This cursor delegates all reading calls to the underlying array.
      Specified by:
      createArrayCursor in interface IArray
      Specified by:
      createArrayCursor in interface IWritableArray
      Returns:
      the cursor, stationed at index 0 of the array
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class ARecordReader
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ARecordReader