Package com.linkedin.davinci.schema
Class SchemaUtils
- java.lang.Object
-
- com.linkedin.davinci.schema.SchemaUtils
-
public class SchemaUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.avro.Schema
annotateRmdSchema(org.apache.avro.Schema schema)
Annotate all the top-level map and string array's deleted elements field of the RMD schema to use Java String as key.static org.apache.avro.Schema
annotateUpdateSchema(org.apache.avro.Schema schema)
Annotate all the top-level map field and string array of the update schema to use Java String as key.static org.apache.avro.Schema
annotateValueSchema(org.apache.avro.Schema schema)
Annotate all the top-level map field and string array field of the input schema to use Java String as key.static DerivedSchemaEntry
getAnnotatedDerivedSchemaEntry(DerivedSchemaEntry schemaEntry)
Create a newDerivedSchemaEntry
for partial update schema annotation.static RmdSchemaEntry
getAnnotatedRmdSchemaEntry(RmdSchemaEntry schemaEntry)
static SchemaEntry
getAnnotatedValueSchemaEntry(SchemaEntry schemaEntry)
Create a newSchemaEntry
for value schema annotation.static org.apache.avro.Schema.Type
unwrapOptionalUnion(org.apache.avro.Schema fieldSchema)
This function returns the type of the field if and only if it has a single non-null type.static void
validateFieldSchemaType(java.lang.String fieldName, org.apache.avro.Schema fieldSchema, org.apache.avro.Schema.Type expectedType)
This method checks if the field contains expected type.
-
-
-
Method Detail
-
annotateValueSchema
public static org.apache.avro.Schema annotateValueSchema(org.apache.avro.Schema schema)
Annotate all the top-level map field and string array field of the input schema to use Java String as key.- Parameters:
schema
- the input value schema to be annotated.- Returns:
- Annotated value schema.
-
annotateUpdateSchema
public static org.apache.avro.Schema annotateUpdateSchema(org.apache.avro.Schema schema)
Annotate all the top-level map field and string array of the update schema to use Java String as key. This method will make sure field update and collection merging operations of these fields are annotated.- Parameters:
schema
- the input update schema to be annotated.- Returns:
- Annotated update schema.
-
annotateRmdSchema
public static org.apache.avro.Schema annotateRmdSchema(org.apache.avro.Schema schema)
Annotate all the top-level map and string array's deleted elements field of the RMD schema to use Java String as key. This method will make sure deleted elements field of these fields are annotated.- Parameters:
schema
- the input update schema to be annotated.- Returns:
- Annotated update schema.
-
getAnnotatedValueSchemaEntry
public static SchemaEntry getAnnotatedValueSchemaEntry(SchemaEntry schemaEntry)
Create a newSchemaEntry
for value schema annotation.- Parameters:
schemaEntry
- InputSchemaEntry
, containing the value schema to be annotated.- Returns:
- Annotated value schema in a newly created
SchemaEntry
-
getAnnotatedDerivedSchemaEntry
public static DerivedSchemaEntry getAnnotatedDerivedSchemaEntry(DerivedSchemaEntry schemaEntry)
Create a newDerivedSchemaEntry
for partial update schema annotation.- Parameters:
schemaEntry
- InputDerivedSchemaEntry
, containing the partial update schema to be annotated.- Returns:
- Annotated partial update schema in a newly created
DerivedSchemaEntry
-
getAnnotatedRmdSchemaEntry
public static RmdSchemaEntry getAnnotatedRmdSchemaEntry(RmdSchemaEntry schemaEntry)
-
unwrapOptionalUnion
public static org.apache.avro.Schema.Type unwrapOptionalUnion(org.apache.avro.Schema fieldSchema)
This function returns the type of the field if and only if it has a single non-null type. In cases where the field is a union, it will return the type of the non-null branch as long as there is at most one such branch, otherwise it will returnSchema.Type.UNION
.
-
validateFieldSchemaType
public static void validateFieldSchemaType(java.lang.String fieldName, org.apache.avro.Schema fieldSchema, org.apache.avro.Schema.Type expectedType)
This method checks if the field contains expected type. It relies onunwrapOptionalUnion(Schema)
to retrieve the type from the field if incoming field is union. If it could not find expected type, or the incoming union is not valid for processing, it will throwIllegalStateException
-
-