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 is a pure structural drop. The writer schema is guaranteed (by an upstream preflight subset check) to be a strict subset of the input schema: every field the writer declares exists in the input and is deeply, exactly equal; the input may only carry extra top-level fields. Projection therefore reduces to: build a record under the writer schema, copy each writer field's value from the input by exact name, and let the input's extra top-level fields fall away.

  • 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.

      Projection only runs when write compute is not enabled. In that mode the RMD timestamp is always a whole-record (value-level) long, so projection reduces to copying the long timestamp and the value-independent replication_checkpoint_vector onto a record under the target RMD schema. A per-field timestamp only arises with write compute (partial updates), where the corresponding superset schema is used and no projection is needed; encountering one here therefore indicates a misuse and is rejected.

      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