Package io.deephaven.kafka.ingest
Class GenericRecordUtil
java.lang.Object
io.deephaven.kafka.ingest.GenericRecordUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
getFieldPath
(String fieldName, Pattern separator) Given a composite (by nesting) field name, composed of individual names separate with the given separator, obtain aString[]
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 aString[]
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).
-
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 aString[]
path with the individual field names.- Parameters:
fieldName
- A composite (by nesting) field name.separator
- The separator pattern used for composingfieldName
schema
- An avro schema.- Returns:
- A
String[]
path with the individual field names forfieldName
-
getFieldPath
Given a composite (by nesting) field name, composed of individual names separate with the given separator, obtain aString[]
path with the individual field names.- Parameters:
fieldName
- A composite (by nesting) field name.separator
- The separator pattern used for composingfieldName
- Returns:
- A
String[]
path with the individual field names forfieldName
-
getPath
Get the value out of a Generic Record for a given field path (including nesting).- Parameters:
record
- AGenericRecord
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 givenfieldPath
-
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
- ASchema
to start nested field navigation fromfieldPath
- 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
-