Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Avro writers use BlockingBinaryEncoder to enable array/map size calculations. #8625

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public static <T> byte[] encode(T datum, Schema avroSchema) throws IOException {
dataOut.writeUTF(avroSchema.toString());

// Encode the datum with avro schema.
BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(out, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be a directBinaryEncoder since we directly write to memory.

BinaryEncoder encoder =
new EncoderFactory().configureBlockSize(1024 * 1024).blockingBinaryEncoder(out, null);
Fokko marked this conversation as resolved.
Show resolved Hide resolved
DatumWriter<T> writer = new GenericAvroWriter<>(avroSchema);
writer.write(datum, encoder);
encoder.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ public ByteBuffer encode(D datum) throws IOException {

@Override
public void encode(D datum, OutputStream stream) throws IOException {
BinaryEncoder encoder = EncoderFactory.get().directBinaryEncoder(stream, ENCODER.get());
BinaryEncoder encoder =
new EncoderFactory()
.configureBlockSize(1024 * 1024)
.blockingBinaryEncoder(stream, ENCODER.get());
ENCODER.set(encoder);
writer.write(datum, encoder);
encoder.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public ByteBuffer encode(KeyMetadata datum) throws IOException {

@Override
public void encode(KeyMetadata datum, OutputStream stream) throws IOException {
BinaryEncoder encoder = EncoderFactory.get().directBinaryEncoder(stream, ENCODER.get());
BinaryEncoder encoder =
new EncoderFactory()
.configureBlockSize(1024 * 1024)
.blockingBinaryEncoder(stream, ENCODER.get());
ENCODER.set(encoder);
writer.write(datum, encoder);
encoder.flush();
Expand Down