Class KeyValueSchemaImpl<K,V>
java.lang.Object
org.apache.pulsar.client.impl.schema.AbstractSchema<KeyValue<K,V>>
org.apache.pulsar.client.impl.schema.KeyValueSchemaImpl<K,V>
- All Implemented Interfaces:
Cloneable,Schema<KeyValue<K,,V>> KeyValueSchema<K,V>
public class KeyValueSchemaImpl<K,V>
extends AbstractSchema<KeyValue<K,V>>
implements KeyValueSchema<K,V>
[Key, Value] pair schema definition.
-
Field Summary
FieldsFields 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 TypeMethodDescriptionSchema<?>atSchemaVersion(byte[] schemaVersion) Return an instance of this schema at the given version.clone()voidconfigureSchemaInfo(String topicName, String componentName, 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, 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.Get the Schema of the Key.Get the KeyValueEncodingType.Get the Schema of the Value.kvBytes()of(Class<K> key, Class<V> value, SchemaType type) Key Value Schema using passed in schema type, support JSON and AVRO currently.of(Schema<K> keySchema, Schema<V> valueSchema, KeyValueEncodingType keyValueEncodingType) booleanvoidsetSchemaInfoProvider(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
-
-
Method Details
-
of
Key Value Schema using passed in schema type, support JSON and AVRO currently. -
of
-
of
public static <K,V> Schema<KeyValue<K,V>> of(Schema<K> keySchema, Schema<V> valueSchema, KeyValueEncodingType keyValueEncodingType) -
kvBytes
-
supportSchemaVersioning
public boolean supportSchemaVersioning()- Specified by:
supportSchemaVersioningin interfaceSchema<K>
-
encode
-
decode
-
decode
-
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<KeyValue<K,V>> - Parameters:
byteBuf- the byte buffer to decode- Returns:
- the deserialized object
-
decode
Description copied from class:AbstractSchemaDecode a byteBuf into an object using a given version.- Overrides:
decodein classAbstractSchema<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
- Specified by:
getSchemaInfoin interfaceSchema<K>
-
setSchemaInfoProvider
- Specified by:
setSchemaInfoProviderin interfaceSchema<K>
-
requireFetchingSchemaInfo
public boolean requireFetchingSchemaInfo()- Specified by:
requireFetchingSchemaInfoin interfaceSchema<K>
-
configureSchemaInfo
- Specified by:
configureSchemaInfoin interfaceSchema<K>
-
clone
-
toString
-
atSchemaVersion
Description copied from class:AbstractSchemaReturn an instance of this schema at the given version.- Overrides:
atSchemaVersionin classAbstractSchema<KeyValue<K,V>> - Parameters:
schemaVersion- the version- Returns:
- the schema at that specific version
- Throws:
SchemaSerializationException- in case of unknown schema version
-
getKeySchema
Get the Schema of the Key.- Specified by:
getKeySchemain interfaceKeyValueSchema<K,V> - Returns:
- the Schema of the Key
-
getValueSchema
Get the Schema of the Value.- Specified by:
getValueSchemain interfaceKeyValueSchema<K,V> - Returns:
- the Schema of the Value
-
getKeyValueEncodingType
Get the KeyValueEncodingType.- Specified by:
getKeyValueEncodingTypein interfaceKeyValueSchema<K,V> - Returns:
- the KeyValueEncodingType
- See Also:
-
fetchSchemaIfNeeded
public void fetchSchemaIfNeeded(String topicName, SchemaVersion schemaVersion) throws 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.
-