public class OrderedKeyProtoSerde<T extends com.google.protobuf.Message> extends java.lang.Object implements OrderedKeyUberSerde<T>
Modifier and Type | Field and Description |
---|---|
protected static int |
ENUM_FIELD_SIZE |
protected com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> |
fields |
protected T |
instance |
protected static org.slf4j.Logger |
log |
MAGIC_BYTE_ORDERED_KEY, MAGIC_BYTE_PROTOBUF, MAGIC_BYTE_STRING
Constructor and Description |
---|
OrderedKeyProtoSerde(T instance,
com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this deserializer.
|
void |
configure(java.util.Map<java.lang.String,?> configs,
boolean isKey)
Configure this class, which will configure the underlying serializer and deserializer.
|
static <T extends com.google.protobuf.Message> |
create(T instance,
int... fieldNumbers) |
org.apache.kafka.common.utils.Bytes |
deserialize(byte[] bytes) |
org.apache.kafka.common.utils.Bytes |
deserialize(java.lang.String topic,
byte[] data) |
org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes> |
deserializer() |
static void |
encodeEnum(java.nio.ByteBuffer buffer,
int enumVal) |
byte[] |
fromJson(java.lang.String json) |
static int |
getMaxSerializedBytes(com.google.protobuf.Message message,
com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields) |
static <T extends com.google.protobuf.Message> |
jsonToProto(java.lang.String json,
T instance) |
org.apache.kafka.common.utils.Bytes |
key(T message) |
int |
numFields() |
OrderedKeyUberSerde<T> |
prefixKeySerde(int numFields) |
protected byte[] |
protoToBytes(T message,
com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields,
int numFields) |
static <T extends com.google.protobuf.Message> |
protoToJson(T message) |
static void |
readMagicByte(java.nio.ByteBuffer buffer) |
static <T extends com.google.protobuf.Message> |
readProto(java.nio.ByteBuffer buffer,
T instance,
com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields) |
byte[] |
serialize(org.apache.kafka.common.utils.Bytes bytes) |
byte[] |
serialize(java.lang.String topic,
org.apache.kafka.common.utils.Bytes data) |
org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes> |
serializer() |
java.lang.String |
toHexString(org.apache.kafka.common.utils.Bytes key) |
java.lang.String |
toJson(org.apache.kafka.common.utils.Bytes bytes) |
T |
toProto(org.apache.kafka.common.utils.Bytes key) |
java.lang.Class<org.apache.kafka.common.utils.Bytes> |
type() |
static void |
writeMagicByte(java.nio.ByteBuffer buffer) |
static void |
writeProto(java.nio.ByteBuffer buffer,
com.google.protobuf.Message message,
com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields,
int numFields) |
protected static final org.slf4j.Logger log
protected final T extends com.google.protobuf.Message instance
protected final com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields
protected static final int ENUM_FIELD_SIZE
public OrderedKeyProtoSerde(T instance, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
public static <T extends com.google.protobuf.Message> OrderedKeyProtoSerde<T> create(T instance, int... fieldNumbers)
public static void readMagicByte(java.nio.ByteBuffer buffer)
public static <T extends com.google.protobuf.Message> T readProto(java.nio.ByteBuffer buffer, T instance, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
public static void writeMagicByte(java.nio.ByteBuffer buffer)
protected byte[] protoToBytes(T message, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields, int numFields)
public static void writeProto(java.nio.ByteBuffer buffer, com.google.protobuf.Message message, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields, int numFields)
public static void encodeEnum(java.nio.ByteBuffer buffer, int enumVal)
public static int getMaxSerializedBytes(com.google.protobuf.Message message, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
public static <T extends com.google.protobuf.Message> T jsonToProto(java.lang.String json, T instance)
public static <T extends com.google.protobuf.Message> java.lang.String protoToJson(T message)
public java.lang.Class<org.apache.kafka.common.utils.Bytes> type()
public byte[] serialize(org.apache.kafka.common.utils.Bytes bytes)
serialize
in interface SerdeWithJson<org.apache.kafka.common.utils.Bytes>
public byte[] serialize(java.lang.String topic, org.apache.kafka.common.utils.Bytes data)
serialize
in interface org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes>
public org.apache.kafka.common.utils.Bytes deserialize(java.lang.String topic, byte[] data)
deserialize
in interface org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes>
public org.apache.kafka.common.utils.Bytes deserialize(byte[] bytes)
deserialize
in interface SerdeWithJson<org.apache.kafka.common.utils.Bytes>
public void configure(java.util.Map<java.lang.String,?> configs, boolean isKey)
UberSerde
configure
in interface UberSerde<org.apache.kafka.common.utils.Bytes>
configure
in interface org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes>
configure
in interface org.apache.kafka.common.serialization.Serde<org.apache.kafka.common.utils.Bytes>
configure
in interface org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes>
configs
- configs in key/value pairsisKey
- whether is for key or valuepublic void close()
UberSerde
This method must be idempotent as it may be called multiple times.
close
in interface UberSerde<org.apache.kafka.common.utils.Bytes>
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes>
close
in interface org.apache.kafka.common.serialization.Serde<org.apache.kafka.common.utils.Bytes>
close
in interface org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes>
public org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes> serializer()
serializer
in interface org.apache.kafka.common.serialization.Serde<org.apache.kafka.common.utils.Bytes>
public org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes> deserializer()
deserializer
in interface org.apache.kafka.common.serialization.Serde<org.apache.kafka.common.utils.Bytes>
public byte[] fromJson(java.lang.String json)
fromJson
in interface SerdeWithJson<org.apache.kafka.common.utils.Bytes>
public java.lang.String toJson(org.apache.kafka.common.utils.Bytes bytes)
toJson
in interface SerdeWithJson<org.apache.kafka.common.utils.Bytes>
public OrderedKeyUberSerde<T> prefixKeySerde(int numFields)
prefixKeySerde
in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
public int numFields()
numFields
in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
public org.apache.kafka.common.utils.Bytes key(T message)
key
in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
public T toProto(org.apache.kafka.common.utils.Bytes key)
toProto
in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
public java.lang.String toHexString(org.apache.kafka.common.utils.Bytes key)
toHexString
in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>