Encoder instances.
Factory methods that create Encoder instances are thread-safe. Multiple instances with different configurations can be cached by an application.
Encoder, BinaryEncoder, JsonEncoder, ValidatingEncoder, BufferedBinaryEncoder, BlockingBinaryEncoder, DirectBinaryEncoder
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| protected int | |
| protected int | |
| private static final int | |
| private static final int | |
| private static final EncoderFactory | |
| private static final int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public BinaryEncoder | Returns: A BinaryEncoder that uses out as its data output. If reuse is null, this will be a new instance. If reuse is not null, then the returned instance may be a new instance or reuse reconfigured to use out.The OutputStream to write to. Cannot be null. out, BinaryEncoder The BinaryEncoder to attempt to reuse given the factory
configuration. A BinaryEncoder implementation may not be
compatible with reuse, causing a new instance to be returned. If
null, a new instance is returned. reuse)Creates or reinitializes a |
| public BinaryEncoder | Returns: A BinaryEncoder that uses out as its data output. If reuse is null, this will be a new instance. If reuse is not null, then the returned instance may be a new instance or reuse reconfigured to use out.The OutputStream to initialize to. Cannot be null. out, BinaryEncoder The BinaryEncoder to attempt to reuse given the factory
configuration. A BinaryEncoder implementation may not be
compatible with reuse, causing a new instance to be returned. If
null, a new instance is returned. reuse)Creates or reinitializes a |
| public EncoderFactory | Returns: This factory, to enable method chaining:
EncoderFactory factory = new EncoderFactory().configureBlockSize(8000);
The preferred block size for array blocking. Arrays larger than
this size will be segmented into blocks according to the Avro
spec. Valid values are in the range [64, 1024*1024*1024] Values
outside this range are set to the nearest value in the range. The
encoder will require at least this amount of memory. size)Configures this factory to construct blocking BinaryEncoders with the specified block buffer size. |
| public EncoderFactory | Returns: This factory, to enable method chaining:
EncoderFactory factory = new EncoderFactory().configureBufferSize(4096);
The buffer size to configure new instances with. Valid values are
in the range [32, 16*1024*1024]. Values outside this range are
set to the nearest value in the range. Values less than 256 will
limit performance but will consume less memory if the
BinaryEncoder is short-lived, values greater than 8*1024 are not
likely to improve performance but may be useful for the
downstream OutputStream. size)Configures this factory to use the specified buffer size when creating Encoder instances that buffer their output. |
| public BinaryEncoder | Returns: A BinaryEncoder that uses out as its data output. If reuse is null, this will be a new instance. If reuse is not null, then the returned instance may be a new instance or reuse reconfigured to use out.The OutputStream to initialize to. Cannot be null. out, BinaryEncoder The BinaryEncoder to attempt to reuse given the factory
configuration. A BinaryEncoder implementation may not be
compatible with reuse, causing a new instance to be returned. If
null, a new instance is returned. reuse)Creates or reinitializes a |
| public static EncoderFactory | |
| public int | Returns: The preferred block size, in bytes.Returns this factory's configured default block buffer size. |
| public int | Returns: The preferred buffer size, in bytes.Returns this factory's configured default buffer size. |
| public JsonEncoder | Returns: A JsonEncoder configured with out and schemaThe Schema for data written to this JsonEncoder. Cannot be
null. schema, OutputStream The OutputStream to write to. Cannot be null. out)Creates a |
| public JsonEncoder | Returns: A JsonEncoder configured with out, schema and prettyThe Schema for data written to this JsonEncoder. Cannot be
null. schema, OutputStream The OutputStream to write to. Cannot be null. out, boolean Pretty print encoding. pretty)Creates a |
| pack-priv JsonEncoder | Returns: A JsonEncoder configured with gen and schemaThe Schema for data written to this JsonEncoder. Cannot be
null. schema, JsonGenerator The JsonGenerator to write with. Cannot be null. gen)Creates a |
| public ValidatingEncoder | Returns: A ValidatingEncoder configured to wrap encoder and validate against schemaThe Schema to validate operations against. Cannot be null. schema, Encoder The Encoder to wrap. Cannot be be null. encoder)Creates a |
| binaryBlockSize | back to summary |
|---|---|
| protected int binaryBlockSize | |
| binaryBufferSize | back to summary |
|---|---|
| protected int binaryBufferSize | |
| DEFAULT_BLOCK_BUFFER_SIZE | back to summary |
|---|---|
| private static final int DEFAULT_BLOCK_BUFFER_SIZE | |
| DEFAULT_BUFFER_SIZE | back to summary |
|---|---|
| private static final int DEFAULT_BUFFER_SIZE | |
| DEFAULT_FACTORY | back to summary |
|---|---|
| private static final EncoderFactory DEFAULT_FACTORY | |
| MAX_BLOCK_BUFFER_SIZE | back to summary |
|---|---|
| private static final int MAX_BLOCK_BUFFER_SIZE | |
| MIN_BLOCK_BUFFER_SIZE | back to summary |
|---|---|
| private static final int MIN_BLOCK_BUFFER_SIZE | |
| EncoderFactory | back to summary |
|---|---|
| public EncoderFactory() | |
| binaryEncoder | back to summary |
|---|---|
| public BinaryEncoder binaryEncoder(OutputStream out, BinaryEncoder reuse) Creates or reinitializes a
The directBinaryEncoder(OutputStream, BinaryEncoder)
| |
| blockingBinaryEncoder | back to summary |
|---|---|
| public BinaryEncoder blockingBinaryEncoder(OutputStream out, BinaryEncoder reuse) Creates or reinitializes a
The
The returned BinaryEncoder implements the Avro binary encoding using blocks
delimited with byte sizes for Arrays and Maps. This allows for some decoders
to skip over large Arrays or Maps without decoding the contents, but adds
some overhead. The default block size is configured with
| |
| configureBlockSize | back to summary |
|---|---|
| public EncoderFactory configureBlockSize(int size) Configures this factory to construct blocking BinaryEncoders with the specified block buffer size. The default buffer size is 64 * 1024 bytes.
| |
| configureBufferSize | back to summary |
|---|---|
| public EncoderFactory configureBufferSize(int size) Configures this factory to use the specified buffer size when creating Encoder instances that buffer their output. The default buffer size is 2048 bytes.
| |
| directBinaryEncoder | back to summary |
|---|---|
| public BinaryEncoder directBinaryEncoder(OutputStream out, BinaryEncoder reuse) Creates or reinitializes a
The
Performance of unbuffered writes can be significantly slower than buffered
writes.
| |
| get | back to summary |
|---|---|
| public static EncoderFactory get() Returns an immutable static DecoderFactory with default configuration. All configuration methods throw AvroRuntimeExceptions if called. | |
| getBlockSize | back to summary |
|---|---|
| public int getBlockSize() Returns this factory's configured default block buffer size.
| |
| getBufferSize | back to summary |
|---|---|
| public int getBufferSize() Returns this factory's configured default buffer size. Used when creating Encoder instances that buffer writes.
| |
| jsonEncoder | back to summary |
|---|---|
| public JsonEncoder jsonEncoder(Schema schema, OutputStream out) throws IOException Creates a
| |
| jsonEncoder | back to summary |
|---|---|
| public JsonEncoder jsonEncoder(Schema schema, OutputStream out, boolean pretty) throws IOException Creates a
| |
| jsonEncoder | back to summary |
|---|---|
| pack-priv JsonEncoder jsonEncoder(Schema schema, JsonGenerator gen) throws IOException Creates a
| |
| validatingEncoder | back to summary |
|---|---|
| public ValidatingEncoder validatingEncoder(Schema schema, Encoder encoder) throws IOException Creates a
Many
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public EncoderFactory | configureBlockSize(int
The preferred block size for array blocking. Arrays larger than
this size will be segmented into blocks according to the Avro
spec. Valid values are in the range [64, 1024*1024*1024] Values
outside this range are set to the nearest value in the range. The
encoder will require at least this amount of memory. size)Overrides org. |
| public EncoderFactory | configureBufferSize(int
The buffer size to configure new instances with. Valid values are
in the range [32, 16*1024*1024]. Values outside this range are
set to the nearest value in the range. Values less than 256 will
limit performance but will consume less memory if the
BinaryEncoder is short-lived, values greater than 8*1024 are not
likely to improve performance but may be useful for the
downstream OutputStream. size)Overrides org. |
| DefaultEncoderFactory | back to summary |
|---|---|
| private DefaultEncoderFactory() | |
| configureBlockSize | back to summary |
|---|---|
| public EncoderFactory configureBlockSize(int size) Overrides org. Doc from org. Configures this factory to construct blocking BinaryEncoders with the specified block buffer size. The default buffer size is 64 * 1024 bytes.
| |
| configureBufferSize | back to summary |
|---|---|
| public EncoderFactory configureBufferSize(int size) Overrides org. Doc from org. Configures this factory to use the specified buffer size when creating Encoder instances that buffer their output. The default buffer size is 2048 bytes.
| |