Class NativeAvroBytesSchema<T>

java.lang.Object
org.apache.pulsar.client.impl.schema.NativeAvroBytesSchema<T>
All Implemented Interfaces:
Cloneable, org.apache.pulsar.client.api.Schema<byte[]>

public class NativeAvroBytesSchema<T> extends Object implements org.apache.pulsar.client.api.Schema<byte[]>
Schema from a native Apache Avro schema. This class is supposed to be used on the producer side for working with existing data serialized in Avro, possibly stored in another system like Kafka. For this reason, it will not perform bytes validation against the schema in encoding and decoding, which are just identify functions. This class also makes it possible for users to bring in their own Avro serialization method.
  • Field Summary

    Fields inherited from interface org.apache.pulsar.client.api.Schema

    BOOL, BYTEBUFFER, BYTES, DATE, DOUBLE, FLOAT, INSTANT, INT16, INT32, INT64, INT8, LOCAL_DATE, LOCAL_DATE_TIME, LOCAL_TIME, STRING, TIME, TIMESTAMP
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    NativeAvroBytesSchema(org.apache.avro.Schema schema)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.pulsar.client.api.Schema<byte[]>
     
    byte[]
    decode(byte[] bytes, byte[] schemaVersion)
     
    byte[]
    encode(byte[] message)
     
     
    org.apache.pulsar.common.schema.SchemaInfo
     
    boolean
     
    void
    setSchema(org.apache.avro.Schema schema)
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.apache.pulsar.client.api.Schema

    configureSchemaInfo, decode, decode, decode, requireFetchingSchemaInfo, setSchemaInfoProvider, supportSchemaVersioning, validate
  • Constructor Details

    • NativeAvroBytesSchema

      public NativeAvroBytesSchema(org.apache.avro.Schema schema)
    • NativeAvroBytesSchema

      public NativeAvroBytesSchema(Object schema)
  • Method Details

    • setSchema

      public void setSchema(org.apache.avro.Schema schema)
    • schemaInitialized

      public boolean schemaInitialized()
    • encode

      public byte[] encode(byte[] message)
      Specified by:
      encode in interface org.apache.pulsar.client.api.Schema<T>
    • decode

      public byte[] decode(byte[] bytes, byte[] schemaVersion)
      Specified by:
      decode in interface org.apache.pulsar.client.api.Schema<T>
    • getSchemaInfo

      public org.apache.pulsar.common.schema.SchemaInfo getSchemaInfo()
      Specified by:
      getSchemaInfo in interface org.apache.pulsar.client.api.Schema<T>
    • getNativeSchema

      public Optional<Object> getNativeSchema()
      Specified by:
      getNativeSchema in interface org.apache.pulsar.client.api.Schema<T>
    • clone

      public org.apache.pulsar.client.api.Schema<byte[]> clone()
      Specified by:
      clone in interface org.apache.pulsar.client.api.Schema<T>
      Overrides:
      clone in class Object