Class VeniceSchemaProjector

java.lang.Object
com.linkedin.venice.schema.projection.VeniceSchemaProjector

public class VeniceSchemaProjector extends Object
Projects a value record (and its Replication Metadata) that was serialized against a superset schema down to a chosen registered writer (target) schema.

The projection follows the writer schema, which is guaranteed (by an upstream preflight projection-subset check) to be obtainable from the input schema. At every nesting level (records, array elements, map values) the input may wrap a field as a nullable union ([null, X] vs writer X) and may carry extra fields the writer does not declare. Projection rebuilds each record under the writer schema, unwrapping nullable inputs and dropping the input's extra fields at every level. Subtrees that need no projection (the input subschema already equals the writer subschema) are copied by reference rather than rebuilt.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.avro.generic.GenericRecord
    projectRmd(org.apache.avro.generic.GenericRecord srcRmd, org.apache.avro.Schema targetRmdSchema)
    Project a Replication Metadata (RMD) record down to the writer's RMD schema, in lockstep with the value.
    org.apache.avro.generic.GenericRecord
    projectValue(org.apache.avro.generic.GenericRecord src, org.apache.avro.Schema writerValueSchema)
    Project a value record down to the writer value schema.

    Methods inherited from class java.lang.Object

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

    • VeniceSchemaProjector

      public VeniceSchemaProjector()
  • Method Details

    • projectValue

      public org.apache.avro.generic.GenericRecord projectValue(org.apache.avro.generic.GenericRecord src, org.apache.avro.Schema writerValueSchema)
      Project a value record down to the writer value schema.
      Parameters:
      src - the source value record (serialized against the superset schema), or null for a tombstone
      writerValueSchema - the chosen registered writer value schema
      Returns:
      a new record under writerValueSchema, or null if src is null
    • projectRmd

      public org.apache.avro.generic.GenericRecord projectRmd(org.apache.avro.generic.GenericRecord srcRmd, org.apache.avro.Schema targetRmdSchema)
      Project a Replication Metadata (RMD) record down to the writer's RMD schema, in lockstep with the value.

      The replication_checkpoint_vector is value-independent and is copied as-is. The timestamp is a union of a value-level long and (for record values) a per-field timestamp record:

      • a value-level long is structure-independent and copied as-is; while
      • a per-field timestamp record (active-active stores) is projected to the writer's per-field timestamp schema. The per-field RMD record is flat (one entry per top-level value field) and a value field's timestamp metadata is unchanged by nullable wrapping, so projection is a field-by-field copy that drops the timestamp entries for value fields the writer schema does not declare.
      Parameters:
      srcRmd - the source RMD record (generated against the superset value schema), or null if the record carries no RMD (e.g. a batch record in a hybrid store)
      targetRmdSchema - the writer's RMD schema (generated against the writer value schema)
      Returns:
      a new RMD record under targetRmdSchema, or null if srcRmd is null