Class GenericRecordUtil

java.lang.Object
io.deephaven.kafka.ingest.GenericRecordUtil

public class GenericRecordUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String[]
    getFieldPath(String fieldName, Pattern separator)
    Given a composite (by nesting) field name, composed of individual names separate with the given separator, obtain a String[] path with the individual field names.
    static int[]
    getFieldPath(String fieldName, Pattern separator, org.apache.avro.Schema schema)
    Given a composite (by nesting) field name, composed of individual names separate with the given separator, obtain a String[] path with the individual field names.
    static org.apache.avro.Schema
    getFieldSchema(org.apache.avro.Schema schema, String[] fieldPath)
    Get the schema for a particular field path (including nesting).
    static Object
    getPath(org.apache.avro.generic.GenericRecord record, int[] fieldPath)
    Get the value out of a Generic Record for a given field path (including nesting).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GenericRecordUtil

      public GenericRecordUtil()
  • Method Details

    • getFieldPath

      public static int[] getFieldPath(String fieldName, Pattern separator, org.apache.avro.Schema schema)
      Given a composite (by nesting) field name, composed of individual names separate with the given separator, obtain a String[] path with the individual field names.
      Parameters:
      fieldName - A composite (by nesting) field name.
      separator - The separator pattern used for composing fieldName
      schema - An avro schema.
      Returns:
      A String[] path with the individual field names for fieldName
    • getFieldPath

      public static String[] getFieldPath(String fieldName, Pattern separator)
      Given a composite (by nesting) field name, composed of individual names separate with the given separator, obtain a String[] path with the individual field names.
      Parameters:
      fieldName - A composite (by nesting) field name.
      separator - The separator pattern used for composing fieldName
      Returns:
      A String[] path with the individual field names for fieldName
    • getPath

      public static Object getPath(org.apache.avro.generic.GenericRecord record, int[] fieldPath)
      Get the value out of a Generic Record for a given field path (including nesting).
      Parameters:
      record - A GenericRecord from which to extract a value.
      fieldPath - An array of individual field position indices, in order according to nesting from the root representing a path to an individual desired field
      Returns:
      The value in record for the given fieldPath
    • getFieldSchema

      public static org.apache.avro.Schema getFieldSchema(org.apache.avro.Schema schema, String[] fieldPath)
      Get the schema for a particular field path (including nesting).
      Parameters:
      schema - A Schema to start nested field navigation from
      fieldPath - An array of individual field names, in order according to nesting from the root representing a path to an individual desired field
      Returns:
      The schema for the given fieldPath