MessageDecoder that reads a binary-encoded datum. This checks for
the datum header and decodes the payload with the schema that corresponds to
the 8-byte schema fingerprint.
Instances can decode message payloads for known schemas, which
are schemas added using addSchema(Schema), schemas resolved by the
SchemaStore passed to the constructor, or the expected schema passed
to the constructor. Messages encoded using an unknown schema will cause
instances to throw a MissingSchemaException.
It is safe to continue using instances of this class after decode
throws BadHeaderException or MissingSchemaException.
This class is thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private static final ThreadLocal | |
| private static final ThreadLocal | |
| private final GenericData | |
| private final Schema | |
| private final SchemaStore |
| Access | Constructor and Description |
|---|---|
| public | BinaryMessageDecoder(GenericData
the model, Schema data model for datum instancesthe readSchema)Schema used to construct datum instancesCreates a new |
| public | BinaryMessageDecoder(GenericData
the model, Schema data model for datum instancesthe readSchema, SchemaStore Schema used to construct datum instancesa resolver)SchemaStore used to find schemas by fingerprintCreates a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public D | decode(InputStream
stream to read from stream, D a datum instance to reuse, avoiding instantiation if possible reuse)Implements org. |
| private RawMessageDecoder | |
| private boolean | Returns: true if the buffer is complete, false otherwise (stream ended)an InputStream to read from stream, byte[] a buffer bytes)Reads a buffer from a stream, making multiple read calls if necessary. |
| codecByFingerprint | back to summary |
|---|---|
| private final Map<Long, RawMessageDecoder<D>> codecByFingerprint | |
| FP_BUFFER | back to summary |
|---|---|
| private static final ThreadLocal<ByteBuffer> FP_BUFFER | |
| HEADER_BUFFER | back to summary |
|---|---|
| private static final ThreadLocal<byte[]> HEADER_BUFFER | |
| model | back to summary |
|---|---|
| private final GenericData model | |
| readSchema | back to summary |
|---|---|
| private final Schema readSchema | |
| resolver | back to summary |
|---|---|
| private final SchemaStore resolver | |
| BinaryMessageDecoder | back to summary |
|---|---|
| public BinaryMessageDecoder(GenericData model, Schema readSchema) Creates a new
The
If
The schema used to decode incoming buffers is determined by the schema
fingerprint encoded in the message header. This class can decode messages
that were encoded using the
| |
| BinaryMessageDecoder | back to summary |
|---|---|
| public BinaryMessageDecoder(GenericData model, Schema readSchema, SchemaStore resolver) Creates a new
The
If
The schema used to decode incoming buffers is determined by the schema
fingerprint encoded in the message header. This class can decode messages
that were encoded using the
| |
| addSchema | back to summary |
|---|---|
| public void addSchema(Schema writeSchema) Adds a | |
| decode | back to summary |
|---|---|
| public D decode(InputStream stream, D reuse) throws IOException Implements org. Doc from org. Deserialize a single datum from an InputStream.
| |
| getDecoder | back to summary |
|---|---|
| private RawMessageDecoder | |
| readFully | back to summary |
|---|---|
| private boolean readFully(InputStream stream, byte[] bytes) throws IOException Reads a buffer from a stream, making multiple read calls if necessary.
| |