Class Parquet


public class Parquet extends StreamMarshaller
A pairing of ParquetSerializer and ParquetParser for Apache Parquet binary format.
Examples:

// Serialize a list of beans to Parquet bytes List<MyBean> beans = List.of(new MyBean(...), new MyBean(...)); byte[] bytes = Parquet.of(beans); // Parse Parquet bytes back into a list of beans List<MyBean> parsed = Parquet.to(bytes, MyBean.class);

// Using instance methods Parquet m = Parquet.DEFAULT; bytes = m.write(beans); parsed = m.read(bytes, MyBean.class);

Output is binary (byte[]), Apache Parquet columnar format.

Note: Parquet is collection-oriented. The serializer accepts a Collection or array of beans (each bean is one row). A single bean is automatically wrapped in a one-element list. The parser always returns a List<T>, never a bare T.

// Using static shortcuts. MyPojo myPojo = Parquet.to(bytes, MyPojo.class); byte[] bytes = Parquet.of(myPojo);

See Also:
  • Field Details

    • DEFAULT

      public static final Parquet DEFAULT
      Default reusable instance.
  • Constructor Details

  • Method Details

    • of

      public static byte[] of(Object object) throws SerializeException
      Serializes a POJO to a byte[] using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.write(object).

      Parameters:
      object - The object to serialize.
      Returns:
      The serialized object.
      Throws:
      SerializeException - If a problem occurred trying to convert the output.
    • to

      public static <T> T to(byte[] input, Class<T> type) throws ParseException
      Parses an input into the specified object type using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.read(input, type).

      Type Parameters:
      T - The class type of the object being created.
      Parameters:
      input - The input.
      type - The object type to create.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
    • to

      public static <T> T to(byte[] input, Type type, Type... args) throws ParseException
      Parses an input into the specified parameterized object type using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.read(input, type, args).

      Type Parameters:
      T - The class type of the object to create.
      Parameters:
      input - The input.
      type - The object type to create.
      args - The type arguments of the class if it's a collection or map.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
    • to

      public static <T> T to(InputStream input, Class<T> type) throws ParseException
      Parses the contents of an InputStream into the specified object type using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.read(input, type) that catches any IOException from the underlying stream and rethrows it as an unchecked ParseException, so the caller is not burdened with a checked exception.

      Type Parameters:
      T - The class type of the object being created.
      Parameters:
      input - The input stream.
      type - The object type to create.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered or an I/O error occurred on the underlying stream.
    • to

      public static <T> T to(InputStream input, Type type, Type... args) throws ParseException
      Parses the contents of an InputStream into the specified parameterized object type using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.read(input, type, args) that catches any IOException from the underlying stream and rethrows it as an unchecked ParseException, so the caller is not burdened with a checked exception.

      Type Parameters:
      T - The class type of the object to create.
      Parameters:
      input - The input stream.
      type - The object type to create.
      args - The type arguments of the class if it's a collection or map.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered or an I/O error occurred on the underlying stream.
    • of

      public static void of(Object object, OutputStream output) throws SerializeException
      Serializes a POJO to the specified OutputStream using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.write(object, output) that catches any IOException from the underlying stream and rethrows it as an unchecked SerializeException, so the caller is not burdened with a checked exception.

      Parameters:
      object - The object to serialize.
      output - The output stream to serialize to.
      Throws:
      SerializeException - If a problem occurred trying to convert the output or an I/O error occurred on the underlying stream.
    • toRecords

      public static RecordReader toRecords(Object input) throws IOException
      Opens a low-level RecordReader cursor over the specified input using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.readRecords(input).

      Parameters:
      input - The input.
      Returns:
      A new RecordReader.
      Throws:
      IOException - If a problem occurred opening the underlying input.
    • ofRecords

      public static RecordWriter ofRecords(Object output) throws IOException
      Opens a low-level RecordWriter cursor over the specified output using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.writeRecords(output).

      Parameters:
      output - The output.
      Returns:
      A new RecordWriter.
      Throws:
      IOException - If a problem occurred opening the underlying output.
    • toArrayRecords

      public static RecordReader toArrayRecords(Object input) throws IOException
      Opens a RecordReader that yields each element of a top-level wire array using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.readArrayRecords(input).

      Parameters:
      input - The input.
      Returns:
      A new RecordReader.
      Throws:
      IOException - If a problem occurred opening the underlying input.
    • ofArrayRecords

      public static RecordWriter ofArrayRecords(Object output) throws IOException
      Opens a RecordWriter that wraps each written value as one element of a top-level wire array using the DEFAULT marshaller.

      A shortcut for calling DEFAULT.writeArrayRecords(output).

      Parameters:
      output - The output.
      Returns:
      A new RecordWriter.
      Throws:
      IOException - If a problem occurred opening the underlying output.