Class AbstractStructSchema<T>

java.lang.Object
org.apache.pulsar.client.impl.schema.AbstractSchema<T>
org.apache.pulsar.client.impl.schema.AbstractStructSchema<T>
All Implemented Interfaces:
Cloneable, org.apache.pulsar.client.api.Schema<T>
Direct Known Subclasses:
AvroBaseStructSchema, GenericProtobufNativeSchema, ProtobufNativeSchema, StructSchema

public abstract class AbstractStructSchema<T> extends AbstractSchema<T>
minimal abstract StructSchema.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final org.slf4j.Logger
     
    protected org.apache.pulsar.client.api.schema.SchemaReader<T>
     
    protected final org.apache.pulsar.common.schema.SchemaInfo
     
    protected org.apache.pulsar.client.api.schema.SchemaInfoProvider
     
    protected org.apache.pulsar.client.api.schema.SchemaWriter<T>
     

    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
    AbstractStructSchema(org.apache.pulsar.common.schema.SchemaInfo schemaInfo)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.pulsar.client.api.Schema<T>
    atSchemaVersion(byte[] schemaVersion)
    Return an instance of this schema at the given version.
    decode(byte[] bytes)
     
    decode(byte[] bytes, byte[] schemaVersion)
     
    decode(io.netty.buffer.ByteBuf byteBuf)
    Decode a byteBuf into an object using the schema definition and deserializer implementation
    decode(io.netty.buffer.ByteBuf byteBuf, byte[] schemaVersion)
    Decode a byteBuf into an object using a given version.
     
    decode(ByteBuffer buffer, byte[] schemaVersion)
     
    byte[]
    encode(T message)
     
    protected org.apache.pulsar.client.api.schema.SchemaReader<T>
     
    org.apache.pulsar.common.schema.SchemaInfo
     
    protected void
    setReader(org.apache.pulsar.client.api.schema.SchemaReader<T> reader)
     
    void
    setSchemaInfoProvider(org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider)
     
    protected void
    setWriter(org.apache.pulsar.client.api.schema.SchemaWriter<T> writer)
     

    Methods inherited from class org.apache.pulsar.client.impl.schema.AbstractSchema

    clone

    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, getNativeSchema, requireFetchingSchemaInfo, supportSchemaVersioning, validate
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
    • schemaInfo

      protected final org.apache.pulsar.common.schema.SchemaInfo schemaInfo
    • reader

      protected org.apache.pulsar.client.api.schema.SchemaReader<T> reader
    • writer

      protected org.apache.pulsar.client.api.schema.SchemaWriter<T> writer
    • schemaInfoProvider

      protected org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider
  • Constructor Details

    • AbstractStructSchema

      public AbstractStructSchema(org.apache.pulsar.common.schema.SchemaInfo schemaInfo)
  • Method Details

    • encode

      public byte[] encode(T message)
    • decode

      public T decode(byte[] bytes)
    • decode

      public T decode(byte[] bytes, byte[] schemaVersion)
    • decode

      public T decode(ByteBuffer buffer)
    • decode

      public T decode(ByteBuffer buffer, byte[] schemaVersion)
    • decode

      public T decode(io.netty.buffer.ByteBuf byteBuf)
      Description copied from class: AbstractSchema
      Decode a byteBuf into an object using the schema definition and deserializer implementation

      Do not modify reader/writer index of ByteBuf so, it can be reused to access correct data.

      Specified by:
      decode in class AbstractSchema<T>
      Parameters:
      byteBuf - the byte buffer to decode
      Returns:
      the deserialized object
    • decode

      public T decode(io.netty.buffer.ByteBuf byteBuf, byte[] schemaVersion)
      Description copied from class: AbstractSchema
      Decode a byteBuf into an object using a given version.
      Overrides:
      decode in class AbstractSchema<T>
      Parameters:
      byteBuf - the byte array to decode
      schemaVersion - the schema version to decode the object. null indicates using latest version.
      Returns:
      the deserialized object
    • getSchemaInfo

      public org.apache.pulsar.common.schema.SchemaInfo getSchemaInfo()
    • setSchemaInfoProvider

      public void setSchemaInfoProvider(org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider)
    • atSchemaVersion

      public org.apache.pulsar.client.api.Schema<T> atSchemaVersion(byte[] schemaVersion) throws org.apache.pulsar.client.api.SchemaSerializationException
      Description copied from class: AbstractSchema
      Return an instance of this schema at the given version.
      Overrides:
      atSchemaVersion in class AbstractSchema<T>
      Parameters:
      schemaVersion - the version
      Returns:
      the schema at that specific version
      Throws:
      org.apache.pulsar.client.api.SchemaSerializationException - in case of unknown schema version
    • setWriter

      protected void setWriter(org.apache.pulsar.client.api.schema.SchemaWriter<T> writer)
    • setReader

      protected void setReader(org.apache.pulsar.client.api.schema.SchemaReader<T> reader)
    • getReader

      protected org.apache.pulsar.client.api.schema.SchemaReader<T> getReader()