Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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,7 @@ 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);
BinaryEncoder encoder = EncoderFactory.get().blockingDirectBinaryEncoder(out, null);
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 @@ -25,6 +25,7 @@
import org.apache.avro.file.CodecFactory;
import org.apache.avro.file.DataFileWriter;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.io.EncoderFactory;
import org.apache.iceberg.Metrics;
import org.apache.iceberg.MetricsConfig;
import org.apache.iceberg.exceptions.RuntimeIOException;
Expand Down Expand Up @@ -113,6 +114,8 @@ private static <D> DataFileWriter<D> newAvroWriter(
writer.setMeta(entry.getKey(), entry.getValue());
}

writer.setEncoder(b -> EncoderFactory.get().blockingDirectBinaryEncoder(b, null));
Copy link
Contributor

@namrathamyske namrathamyske Oct 30, 2024

Choose a reason for hiding this comment

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

Should we also do it here:

BinaryEncoder encoder = EncoderFactory.get().directBinaryEncoder(stream, ENCODER.get());
and
BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(out, null);


return writer.create(schema, stream);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ 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 = EncoderFactory.get().blockingDirectBinaryEncoder(stream, ENCODER.get());
ENCODER.set(encoder);
writer.write(datum, encoder);
encoder.flush();
Expand Down
Loading