Class KeyValueSchemaImpl<K,V>
java.lang.Object
org.apache.pulsar.client.impl.schema.AbstractSchema<org.apache.pulsar.common.schema.KeyValue<K,V>>
org.apache.pulsar.client.impl.schema.KeyValueSchemaImpl<K,V>
- All Implemented Interfaces:
Cloneable,org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<K,,V>> org.apache.pulsar.client.api.schema.KeyValueSchema<K,V>
public class KeyValueSchemaImpl<K,V>
extends AbstractSchema<org.apache.pulsar.common.schema.KeyValue<K,V>>
implements org.apache.pulsar.client.api.schema.KeyValueSchema<K,V>
[Key, Value] pair schema definition.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.pulsar.client.api.schema.SchemaInfoProviderFields 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 -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pulsar.client.api.Schema<?>atSchemaVersion(byte[] schemaVersion) Return an instance of this schema at the given version.clone()voidconfigureSchemaInfo(String topicName, String componentName, org.apache.pulsar.common.schema.SchemaInfo schemaInfo) decode(byte[] bytes) decode(byte[] bytes, byte[] schemaVersion) decode(byte[] keyBytes, byte[] valueBytes, byte[] schemaVersion) decode(io.netty.buffer.ByteBuf byteBuf) Decode a byteBuf into an object using the schema definition and deserializer implementationdecode(io.netty.buffer.ByteBuf byteBuf, byte[] schemaVersion) Decode a byteBuf into an object using a given version.byte[]voidfetchSchemaIfNeeded(String topicName, org.apache.pulsar.common.protocol.schema.SchemaVersion schemaVersion) It may happen that the schema is not loaded but we need it, for instance in order to call getSchemaInfo() We cannot call this method in getSchemaInfo.org.apache.pulsar.client.api.Schema<K>Get the Schema of the Key.org.apache.pulsar.common.schema.KeyValueEncodingTypeGet the KeyValueEncodingType.org.apache.pulsar.common.schema.SchemaInfoorg.apache.pulsar.client.api.Schema<V>Get the Schema of the Value.static org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<byte[],byte[]>> kvBytes()static <K,V> org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<K, V>> Key Value Schema using passed in schema type, support JSON and AVRO currently.static <K,V> org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<K, V>> of(org.apache.pulsar.client.api.Schema<K> keySchema, org.apache.pulsar.client.api.Schema<V> valueSchema) static <K,V> org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<K, V>> of(org.apache.pulsar.client.api.Schema<K> keySchema, org.apache.pulsar.client.api.Schema<V> valueSchema, org.apache.pulsar.common.schema.KeyValueEncodingType keyValueEncodingType) booleanvoidsetSchemaInfoProvider(org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider) booleantoString()Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.pulsar.client.api.Schema
decode, decode, getNativeSchema, validate
-
Field Details
-
schemaInfoProvider
protected org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider
-
-
Method Details
-
of
public static <K,V> org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<K,V>> of(Class<K> key, Class<V> value, org.apache.pulsar.common.schema.SchemaType type) Key Value Schema using passed in schema type, support JSON and AVRO currently. -
of
public static <K,V> org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<K,V>> of(org.apache.pulsar.client.api.Schema<K> keySchema, org.apache.pulsar.client.api.Schema<V> valueSchema) -
of
public static <K,V> org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<K,V>> of(org.apache.pulsar.client.api.Schema<K> keySchema, org.apache.pulsar.client.api.Schema<V> valueSchema, org.apache.pulsar.common.schema.KeyValueEncodingType keyValueEncodingType) -
kvBytes
public static org.apache.pulsar.client.api.Schema<org.apache.pulsar.common.schema.KeyValue<byte[],byte[]>> kvBytes() -
supportSchemaVersioning
public boolean supportSchemaVersioning()- Specified by:
supportSchemaVersioningin interfaceorg.apache.pulsar.client.api.Schema<K>
-
encode
- Specified by:
encodein interfaceorg.apache.pulsar.client.api.Schema<K>
-
decode
- Specified by:
decodein interfaceorg.apache.pulsar.client.api.Schema<K>
-
decode
- Specified by:
decodein interfaceorg.apache.pulsar.client.api.Schema<K>
-
decode
Description copied from class:AbstractSchemaDecode a byteBuf into an object using the schema definition and deserializer implementationDo not modify reader/writer index of ByteBuf so, it can be reused to access correct data.
- Specified by:
decodein classAbstractSchema<org.apache.pulsar.common.schema.KeyValue<K,V>> - Parameters:
byteBuf- the byte buffer to decode- Returns:
- the deserialized object
-
decode
public org.apache.pulsar.common.schema.KeyValue<K,V> decode(io.netty.buffer.ByteBuf byteBuf, byte[] schemaVersion) Description copied from class:AbstractSchemaDecode a byteBuf into an object using a given version.- Overrides:
decodein classAbstractSchema<org.apache.pulsar.common.schema.KeyValue<K,V>> - Parameters:
byteBuf- the byte array to decodeschemaVersion- the schema version to decode the object. null indicates using latest version.- Returns:
- the deserialized object
-
decode
-
getSchemaInfo
public org.apache.pulsar.common.schema.SchemaInfo getSchemaInfo()- Specified by:
getSchemaInfoin interfaceorg.apache.pulsar.client.api.Schema<K>
-
setSchemaInfoProvider
public void setSchemaInfoProvider(org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider) - Specified by:
setSchemaInfoProviderin interfaceorg.apache.pulsar.client.api.Schema<K>
-
requireFetchingSchemaInfo
public boolean requireFetchingSchemaInfo()- Specified by:
requireFetchingSchemaInfoin interfaceorg.apache.pulsar.client.api.Schema<K>
-
configureSchemaInfo
public void configureSchemaInfo(String topicName, String componentName, org.apache.pulsar.common.schema.SchemaInfo schemaInfo) - Specified by:
configureSchemaInfoin interfaceorg.apache.pulsar.client.api.Schema<K>
-
clone
- Specified by:
clonein interfaceorg.apache.pulsar.client.api.Schema<K>- Overrides:
clonein classAbstractSchema<org.apache.pulsar.common.schema.KeyValue<K,V>>
-
toString
-
atSchemaVersion
public org.apache.pulsar.client.api.Schema<?> atSchemaVersion(byte[] schemaVersion) throws org.apache.pulsar.client.api.SchemaSerializationException Description copied from class:AbstractSchemaReturn an instance of this schema at the given version.- Overrides:
atSchemaVersionin classAbstractSchema<org.apache.pulsar.common.schema.KeyValue<K,V>> - Parameters:
schemaVersion- the version- Returns:
- the schema at that specific version
- Throws:
org.apache.pulsar.client.api.SchemaSerializationException- in case of unknown schema version
-
getKeySchema
Get the Schema of the Key. -
getValueSchema
Get the Schema of the Value. -
getKeyValueEncodingType
public org.apache.pulsar.common.schema.KeyValueEncodingType getKeyValueEncodingType()Get the KeyValueEncodingType. -
fetchSchemaIfNeeded
public void fetchSchemaIfNeeded(String topicName, org.apache.pulsar.common.protocol.schema.SchemaVersion schemaVersion) throws org.apache.pulsar.client.api.SchemaSerializationException It may happen that the schema is not loaded but we need it, for instance in order to call getSchemaInfo() We cannot call this method in getSchemaInfo.- Throws:
org.apache.pulsar.client.api.SchemaSerializationException- See Also:
-