public class TransformableSchema<T extends TransformContext> extends java.lang.Object implements TransformableType<T>
TransformableSchema
provides a way to embed field transformations into an existing
Schema
. By using buildSchema(Schema, FieldSelector)
, you can derive
a TransformableSchema
which selectively embeds transformations that are applied
automatically during serialization through read(ByteBuffer, TransformContext)
and write(ByteBuffer, Object, TransformContext)
. Note that the transformations must be
compatible with the original schema (transformations cannot change types).Modifier and Type | Class and Description |
---|---|
static interface |
TransformableSchema.FieldSelector<T extends TransformContext>
This interface is used to select the fields for transformation and to install the
transformer itself into the
TransformableSchema . |
static class |
TransformableSchema.TransformableTaggedFields<T extends TransformContext> |
Constructor and Description |
---|
TransformableSchema(org.apache.kafka.common.protocol.types.Schema origin,
io.confluent.kafka.multitenant.schema.TransformableSchema.TransformableField<T>[] fields) |
Modifier and Type | Method and Description |
---|---|
org.apache.kafka.common.protocol.types.Struct |
read(java.nio.ByteBuffer buffer,
T ctx)
Read a schema from a buffer, applying transformations given the passed context.
|
int |
sizeOf(java.lang.Object o,
T ctx)
Get the serialized size in bytes of an object after transformations have been applied
given the passed context.
|
static <T extends TransformContext> |
transformSchema(org.apache.kafka.common.protocol.types.Schema schema,
TransformableSchema.FieldSelector<T> selector) |
void |
write(java.nio.ByteBuffer buffer,
java.lang.Object o,
T ctx)
Transform and serialize an object to a buffer given the passed context.
|
public TransformableSchema(org.apache.kafka.common.protocol.types.Schema origin, io.confluent.kafka.multitenant.schema.TransformableSchema.TransformableField<T>[] fields)
public void write(java.nio.ByteBuffer buffer, java.lang.Object o, T ctx)
write
in interface TransformableType<T extends TransformContext>
public org.apache.kafka.common.protocol.types.Struct read(java.nio.ByteBuffer buffer, T ctx)
Struct
which references the original Schema
that this
TransformableSchema
instance was built from.read
in interface TransformableType<T extends TransformContext>
public int sizeOf(java.lang.Object o, T ctx)
sizeOf
in interface TransformableType<T extends TransformContext>
public static <T extends TransformContext> TransformableType<T> transformSchema(org.apache.kafka.common.protocol.types.Schema schema, TransformableSchema.FieldSelector<T> selector)