java.lang.Object
org.odpi.openmetadata.adapters.connectors.datastore.parquetfile.footer.ThriftCompactReader

public class ThriftCompactReader extends Object
ThriftCompactReader decodes a structure that has been serialized using the Apache Thrift compact protocol. This is the encoding used for all the metadata structures in an Apache Parquet file.

The reader is deliberately generic. It does not know the definition of the structure it is decoding, and so it returns each structure as a map from the field's identifier to its value. The value is one of:
  • Boolean - for a boolean field;
  • Long - for any of the integer fields (i8, i16, i32, i64);
  • Double - for a double field;
  • byte[] - for a binary or string field;
  • List - for a list or set field;
  • Map - for either a nested structure (keyed by field identifier) or a map field.
Working this way means that fields added by newer versions of the Parquet format are read, and then ignored by the caller, rather than causing a failure. It also means that there is no need for the Thrift libraries, or code generated from the Parquet thrift definition.
  • Constructor Details

    • ThriftCompactReader

      public ThriftCompactReader(byte[] buffer)
      Create a reader over a buffer of bytes.
      Parameters:
      buffer - bytes to decode
    • ThriftCompactReader

      public ThriftCompactReader(byte[] buffer, int offset, int length)
      Create a reader over part of a buffer of bytes.
      Parameters:
      buffer - bytes to decode
      offset - position of the first byte to decode
      length - number of bytes available to decode
  • Method Details

    • getPosition

      public int getPosition()
      Return the position of the next byte to read. After a call to readStruct, this is the first byte after the structure.
      Returns:
      offset into the buffer
    • readStruct

      public Map<Integer,Object> readStruct() throws IOException
      Decode a structure.
      Returns:
      map of field identifier to field value
      Throws:
      IOException - the buffer does not contain a valid structure