Class BaseTable

java.lang.Object
org.apache.arrow.vector.table.BaseTable
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
Table

public abstract class BaseTable extends Object implements AutoCloseable
Abstract base class for Table.

This API is EXPERIMENTAL.

  • Field Details

    • fieldVectors

      protected final List<FieldVector> fieldVectors
      The field vectors holding the data in this table.
    • dictionaryProvider

      protected DictionaryProvider dictionaryProvider
      An optional DictionaryProvider. One must be present if any vector in the table is dictionary encoded.
    • fieldVectorsMap

      protected final Map<Field,FieldVector> fieldVectorsMap
      A map of Fields to FieldVectors used to select Fields.
    • schema

      protected Schema schema
      The schema for the table.
    • rowCount

      protected int rowCount
      The number of rows of data in the table; not necessarily the same as the table row capacity.
  • Constructor Details

    • BaseTable

      public BaseTable(List<FieldVector> fieldVectors, int rowCount, DictionaryProvider provider)
      Constructs new instance with the given rowCount, and containing the schema and each of the given vectors.
      Parameters:
      fieldVectors - the FieldVectors containing the table's data
      rowCount - the number of rows in the table
      provider - a dictionary provider, may be null if none of the vectors in the table are encoded
  • Method Details

    • getReader

      public FieldReader getReader(String name)
      Returns a FieldReader for the vector with the given name.
      Parameters:
      name - The name of a vector in this Table (case-sensitive)
      Returns:
      A FieldReader for the named FieldVector
    • getReader

      public FieldReader getReader(Field field)
      Returns a FieldReader for the given field.
      Parameters:
      field - The field to be read
      Returns:
      A FieldReader for the given field
    • getReader

      public FieldReader getReader(int index)
      Returns a FieldReader for the field at the given vector index.
      Parameters:
      index - The 0-based index of the field desired.
      Returns:
      A FieldReader for the requested field
    • getSchema

      public Schema getSchema()
      Returns the schema for this Table.
    • getField

      public Field getField(String fieldName)
      Returns the Field with the given name if one exists in this table.
      Parameters:
      fieldName - the name of the field to return
      Returns:
      a field with the given name if one is present
      Throws:
      IllegalArgumentException - – if the field was not found
    • getVectorCount

      public int getVectorCount()
      Returns the number of vectors (columns) in this table.
    • close

      public void close()
      Closes all the vectors holding data for this table.
      Specified by:
      close in interface AutoCloseable
    • getRowCount

      public long getRowCount()
      Returns the number of rows in this table.
    • toVectorSchemaRoot

      public VectorSchemaRoot toVectorSchemaRoot()
      Returns a new VectorSchemaRoot with the data and schema from this table. Data is transferred to the new VectorSchemaRoot, so this table is cleared and the rowCount is set to 0;
      Returns:
      a new VectorSchemaRoot
    • getVectorCopy

      public FieldVector getVectorCopy(String columnName)
      Returns a copy of the vector with the given name, or throws IllegalArgumentException if the name is not found. Names are case-sensitive.
      Parameters:
      columnName - The name of the vector to copy
      Returns:
      A copy of the Vector with the given name
      Throws:
      IllegalArgumentException - if the name is not the name of a vector in the table.
    • getVectorCopy

      public FieldVector getVectorCopy(int columnIndex)
      Returns a copy of the vector at the given position.
      Parameters:
      columnIndex - The 0-based position of the vector to be copied
    • immutableRow

      public Row immutableRow()
      Returns an immutable Row object holding a reference to this table. The default character encoding used by the cursor to decode Strings will be StandardCharsets.UTF_8 as this is the only charset supported in Arrow format.
    • contentToTSVString

      public String contentToTSVString()
      Returns a tab separated value of vectors (based on their java object representation).
    • isRowDeleted

      public boolean isRowDeleted(int rowNumber)
      Returns true if the row at the given index has been deleted and false otherwise.

      If the index is larger than the number of rows, the method returns true.

      Parameters:
      rowNumber - The 0-based index of the possibly deleted row
      Returns:
      true if the row at the index was deleted; false otherwise
    • getDictionaryProvider

      public DictionaryProvider getDictionaryProvider()
      Returns the DictionaryProvider for this table. It can be used to decode an encoded values
    • decode

      public ValueVector decode(String vectorName, long dictionaryId)
      Returns a ValueVector containing the decoded version of the vector with the given name.
      Parameters:
      vectorName - The name of the vector to decode
      dictionaryId - The identifier for the dictionary to use when decoding. Must match the id returned by the dictionary's getId() method.
      Returns:
      A ValueVector
    • encode

      public ValueVector encode(String vectorName, long dictionaryId)
      Returns a ValueVector containing the encoded version of the vector with the given name.
      Parameters:
      vectorName - The name of the vector to encode
      dictionaryId - The identifier for the dictionary to use when encoding. Must match the id returned by the dictionary's getId() method.
      Returns:
      A ValueVector