Class OrderedKeyProtoSerde<T extends com.google.protobuf.Message>

java.lang.Object
io.confluent.serializers.OrderedKeyProtoSerde<T>
All Implemented Interfaces:
OrderedKeyUberSerde<T>, SerdeWithJson<org.apache.kafka.common.utils.Bytes>, UberSerde<org.apache.kafka.common.utils.Bytes>, Closeable, AutoCloseable, org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes>, org.apache.kafka.common.serialization.Serde<org.apache.kafka.common.utils.Bytes>, org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes>
Direct Known Subclasses:
OrderedKeyPrefixedProtoSerde

public class OrderedKeyProtoSerde<T extends com.google.protobuf.Message> extends Object implements OrderedKeyUberSerde<T>
Serde to convert generated Profobuf messages into lexographically sortable byte-arrays suitable for range scans in RocksDB
  • Field Summary

    Fields inherited from interface io.confluent.serializers.UberSerde

    MAGIC_BYTE_ORDERED_KEY, MAGIC_BYTE_PROTOBUF, MAGIC_BYTE_STRING
  • Constructor Summary

    Constructors
    Constructor
    Description
    OrderedKeyProtoSerde(T instance, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close this deserializer.
    void
    configure(Map<String,?> configs, boolean isKey)
    Configure this class, which will configure the underlying serializer and deserializer.
    static <T extends com.google.protobuf.Message>
    OrderedKeyProtoSerde<T>
    create(T instance, int... fieldNumbers)
     
    org.apache.kafka.common.utils.Bytes
    deserialize(byte[] bytes)
     
    org.apache.kafka.common.utils.Bytes
    deserialize(String topic, byte[] data)
     
    org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes>
     
    static void
    encodeEnum(ByteBuffer buffer, int enumVal)
     
    byte[]
     
    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>
    T
    jsonToProto(String json, T instance)
     
    org.apache.kafka.common.utils.Bytes
    key(T message)
     
    int
     
    prefixKeySerde(int numFields)
     
    static <T extends com.google.protobuf.Message>
    String
    protoToJson(T message)
     
    static void
     
    static <T extends com.google.protobuf.Message>
    T
    readProto(ByteBuffer buffer, T instance, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
     
    byte[]
    serialize(String topic, org.apache.kafka.common.utils.Bytes data)
     
    byte[]
    serialize(org.apache.kafka.common.utils.Bytes bytes)
     
    org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes>
     
    toHexString(org.apache.kafka.common.utils.Bytes key)
     
    toJson(org.apache.kafka.common.utils.Bytes bytes)
     
    toProto(org.apache.kafka.common.utils.Bytes key)
     
    Class<org.apache.kafka.common.utils.Bytes>
     
    static void
     
    static void
    writeProto(ByteBuffer buffer, com.google.protobuf.Message message, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields, int numFields)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.kafka.common.serialization.Deserializer

    deserialize, deserialize

    Methods inherited from interface org.apache.kafka.common.serialization.Serializer

    serialize
  • Constructor Details

    • OrderedKeyProtoSerde

      public OrderedKeyProtoSerde(T instance, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
  • Method Details

    • create

      public static <T extends com.google.protobuf.Message> OrderedKeyProtoSerde<T> create(T instance, int... fieldNumbers)
    • readMagicByte

      public static void readMagicByte(ByteBuffer buffer)
    • readProto

      public static <T extends com.google.protobuf.Message> T readProto(ByteBuffer buffer, T instance, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
    • writeMagicByte

      public static void writeMagicByte(ByteBuffer buffer)
    • writeProto

      public static void writeProto(ByteBuffer buffer, com.google.protobuf.Message message, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields, int numFields)
    • encodeEnum

      public static void encodeEnum(ByteBuffer buffer, int enumVal)
    • getMaxSerializedBytes

      public static int getMaxSerializedBytes(com.google.protobuf.Message message, com.google.common.collect.ImmutableList<com.google.protobuf.Descriptors.FieldDescriptor> fields)
    • jsonToProto

      public static <T extends com.google.protobuf.Message> T jsonToProto(String json, T instance)
    • protoToJson

      public static <T extends com.google.protobuf.Message> String protoToJson(T message)
    • type

      public Class<org.apache.kafka.common.utils.Bytes> type()
      Specified by:
      type in interface UberSerde<T extends com.google.protobuf.Message>
    • serialize

      public byte[] serialize(org.apache.kafka.common.utils.Bytes bytes)
      Specified by:
      serialize in interface SerdeWithJson<T extends com.google.protobuf.Message>
    • serialize

      public byte[] serialize(String topic, org.apache.kafka.common.utils.Bytes data)
      Specified by:
      serialize in interface org.apache.kafka.common.serialization.Serializer<T extends com.google.protobuf.Message>
    • deserialize

      public org.apache.kafka.common.utils.Bytes deserialize(String topic, byte[] data)
      Specified by:
      deserialize in interface org.apache.kafka.common.serialization.Deserializer<T extends com.google.protobuf.Message>
    • deserialize

      public org.apache.kafka.common.utils.Bytes deserialize(byte[] bytes)
      Specified by:
      deserialize in interface SerdeWithJson<T extends com.google.protobuf.Message>
    • configure

      public void configure(Map<String,?> configs, boolean isKey)
      Description copied from interface: UberSerde
      Configure this class, which will configure the underlying serializer and deserializer.
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Deserializer<T extends com.google.protobuf.Message>
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Serde<T extends com.google.protobuf.Message>
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Serializer<T extends com.google.protobuf.Message>
      Specified by:
      configure in interface UberSerde<T extends com.google.protobuf.Message>
      Parameters:
      configs - configs in key/value pairs
      isKey - whether is for key or value
    • close

      public void close()
      Description copied from interface: UberSerde
      Close this deserializer.

      This method must be idempotent as it may be called multiple times.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.common.serialization.Deserializer<T extends com.google.protobuf.Message>
      Specified by:
      close in interface org.apache.kafka.common.serialization.Serde<T extends com.google.protobuf.Message>
      Specified by:
      close in interface org.apache.kafka.common.serialization.Serializer<T extends com.google.protobuf.Message>
      Specified by:
      close in interface UberSerde<T extends com.google.protobuf.Message>
    • serializer

      public org.apache.kafka.common.serialization.Serializer<org.apache.kafka.common.utils.Bytes> serializer()
      Specified by:
      serializer in interface org.apache.kafka.common.serialization.Serde<T extends com.google.protobuf.Message>
    • deserializer

      public org.apache.kafka.common.serialization.Deserializer<org.apache.kafka.common.utils.Bytes> deserializer()
      Specified by:
      deserializer in interface org.apache.kafka.common.serialization.Serde<T extends com.google.protobuf.Message>
    • fromJson

      public byte[] fromJson(String json)
      Specified by:
      fromJson in interface SerdeWithJson<T extends com.google.protobuf.Message>
    • toJson

      public String toJson(org.apache.kafka.common.utils.Bytes bytes)
      Specified by:
      toJson in interface SerdeWithJson<T extends com.google.protobuf.Message>
    • prefixKeySerde

      public OrderedKeyUberSerde<T> prefixKeySerde(int numFields)
      Specified by:
      prefixKeySerde in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
    • numFields

      public int numFields()
      Specified by:
      numFields in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
    • key

      public org.apache.kafka.common.utils.Bytes key(T message)
      Specified by:
      key in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
    • toProto

      public T toProto(org.apache.kafka.common.utils.Bytes key)
      Specified by:
      toProto in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>
    • toHexString

      public String toHexString(org.apache.kafka.common.utils.Bytes key)
      Specified by:
      toHexString in interface OrderedKeyUberSerde<T extends com.google.protobuf.Message>