Package org.apache.avro.message
Class RawMessageEncoder<D>
java.lang.Object
org.apache.avro.message.RawMessageEncoder<D>
- All Implemented Interfaces:
MessageEncoder<D>
A
MessageEncoder that encodes only a datum's bytes, without
additional information (such as a schema fingerprint).
This class is thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionRawMessageEncoder(GenericData model, Schema schema) Creates a newRawMessageEncoderthat uses the givendata modelto deconstruct datum instances described by theschema.RawMessageEncoder(GenericData model, Schema schema, boolean shouldCopy) Creates a newRawMessageEncoderthat uses the givendata modelto deconstruct datum instances described by theschema. -
Method Summary
Modifier and TypeMethodDescriptionSerialize a single datum to a ByteBuffer.voidencode(D datum, OutputStream stream) Serialize a single datum to an OutputStream.
-
Constructor Details
-
RawMessageEncoder
Creates a newRawMessageEncoderthat uses the givendata modelto deconstruct datum instances described by theschema.Buffers returned by
encode(D)are copied and will not be modified by future calls toencode.- Parameters:
model- thedata modelfor datum instancesschema- theSchemafor datum instances
-
RawMessageEncoder
Creates a newRawMessageEncoderthat uses the givendata modelto deconstruct datum instances described by theschema.If
shouldCopyis true, then buffers returned byencode(D)are copied and will not be modified by future calls toencode.If
shouldCopyis false, then buffers returned byencodewrap a thread-local buffer that can be reused by future calls toencode, but may not be. Callers should only setshouldCopyto false if the buffer will be copied before the current thread's next call toencode.- Parameters:
model- thedata modelfor datum instancesschema- theSchemafor datum instancesshouldCopy- whether to copy buffers before returning encoded results
-
-
Method Details
-
encode
Description copied from interface:MessageEncoderSerialize a single datum to a ByteBuffer.- Specified by:
encodein interfaceMessageEncoder<D>- Parameters:
datum- a datum- Returns:
- a ByteBuffer containing the serialized datum
- Throws:
IOException
-
encode
Description copied from interface:MessageEncoderSerialize a single datum to an OutputStream.- Specified by:
encodein interfaceMessageEncoder<D>- Parameters:
datum- a datumstream- an OutputStream to serialize the datum to- Throws:
IOException
-