Class AutoConsumeSchema
java.lang.Object
org.apache.pulsar.client.impl.schema.AutoConsumeSchema
- All Implemented Interfaces:
Cloneable,Schema<GenericRecord>
Auto detect schema, returns only GenericRecord instances.
-
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected GenericRecordSchema<?>atSchemaVersion(byte[] schemaVersion) clone()voidconfigureSchemaInfo(String topicName, String componentName, SchemaInfo schemaInfo) decode(byte[] bytes, byte[] schemaVersion) decode(ByteBuffer buffer, byte[] schemaVersion) byte[]encode(GenericRecord message) voidfetchSchemaIfNeeded(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, because getSchemaInfo is called in many places and we will introduce lots of deadlocks.Schema<?>Schema<?>getInternalSchema(byte[] schemaVersion) static Schema<?>getSchema(SchemaInfo schemaInfo) getSchemaInfo(byte[] schemaVersion) booleanvoidvoidsetSchema(SchemaVersion schemaVersion, Schema<?> schema) voidsetSchemaInfoProvider(SchemaInfoProvider schemaInfoProvider) booleantoString()Schema<?>unwrapInternalSchema(byte[] schemaVersion) Get a specific schema version, fetching from the Registry if it is not loaded yet.voidvalidate(byte[] message) voidvalidate(byte[] message, byte[] schemaVersion) static GenericRecordwrapPrimitiveObject(Object value, SchemaType type, byte[] schemaVersion)
-
Field Details
-
SCHEMA_INFO
-
-
Constructor Details
-
AutoConsumeSchema
public AutoConsumeSchema()
-
-
Method Details
-
setSchema
-
setSchema
-
validate
public void validate(byte[] message) - Specified by:
validatein interfaceSchema<GenericRecord>
-
validate
public void validate(byte[] message, byte[] schemaVersion) -
encode
- Specified by:
encodein interfaceSchema<GenericRecord>
-
supportSchemaVersioning
public boolean supportSchemaVersioning()- Specified by:
supportSchemaVersioningin interfaceSchema<GenericRecord>
-
atSchemaVersion
-
decode
- Specified by:
decodein interfaceSchema<GenericRecord>
-
decode
- Specified by:
decodein interfaceSchema<GenericRecord>
-
setSchemaInfoProvider
- Specified by:
setSchemaInfoProviderin interfaceSchema<GenericRecord>
-
getSchemaInfo
- Specified by:
getSchemaInfoin interfaceSchema<GenericRecord>
-
getSchemaInfo
-
configureSchemaInfo
- Specified by:
configureSchemaInfoin interfaceSchema<GenericRecord>
-
getNativeSchema
- Specified by:
getNativeSchemain interfaceSchema<GenericRecord>
-
getSchema
-
clone
- Specified by:
clonein interfaceSchema<GenericRecord>- Overrides:
clonein classObject
-
requireFetchingSchemaInfo
public boolean requireFetchingSchemaInfo()- Specified by:
requireFetchingSchemaInfoin interfaceSchema<GenericRecord>
-
adapt
-
wrapPrimitiveObject
public static GenericRecord wrapPrimitiveObject(Object value, SchemaType type, byte[] schemaVersion) -
getInternalSchema
-
getInternalSchema
-
unwrapInternalSchema
Get a specific schema version, fetching from the Registry if it is not loaded yet. This method is not intended to be used by applications.- Parameters:
schemaVersion- the version- Returns:
- the Schema at the specific version
- See Also:
-
fetchSchemaIfNeeded
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, because getSchemaInfo is called in many places and we will introduce lots of deadlocks.- Throws:
SchemaSerializationException
-
toString
-