diff --git a/core/src/main/java/org/apache/iceberg/avro/AvroEncoderUtil.java b/core/src/main/java/org/apache/iceberg/avro/AvroEncoderUtil.java index ba3c6fece7f9..1a0ff564757d 100644 --- a/core/src/main/java/org/apache/iceberg/avro/AvroEncoderUtil.java +++ b/core/src/main/java/org/apache/iceberg/avro/AvroEncoderUtil.java @@ -54,7 +54,8 @@ public static 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().configureBlockSize(1024 * 1024).blockingBinaryEncoder(out, null); DatumWriter writer = new GenericAvroWriter<>(avroSchema); writer.write(datum, encoder); encoder.flush(); diff --git a/core/src/main/java/org/apache/iceberg/data/avro/IcebergEncoder.java b/core/src/main/java/org/apache/iceberg/data/avro/IcebergEncoder.java index a70e79aac2c5..5943257fbf69 100644 --- a/core/src/main/java/org/apache/iceberg/data/avro/IcebergEncoder.java +++ b/core/src/main/java/org/apache/iceberg/data/avro/IcebergEncoder.java @@ -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 = + EncoderFactory.get() + .configureBlockSize(1024 * 1024) + .blockingBinaryEncoder(stream, ENCODER.get()); ENCODER.set(encoder); writer.write(datum, encoder); encoder.flush(); diff --git a/core/src/main/java/org/apache/iceberg/encryption/KeyMetadataEncoder.java b/core/src/main/java/org/apache/iceberg/encryption/KeyMetadataEncoder.java index faab6a47c814..1298612e9882 100644 --- a/core/src/main/java/org/apache/iceberg/encryption/KeyMetadataEncoder.java +++ b/core/src/main/java/org/apache/iceberg/encryption/KeyMetadataEncoder.java @@ -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 = + EncoderFactory.get() + .configureBlockSize(1024 * 1024) + .blockingBinaryEncoder(stream, ENCODER.get()); ENCODER.set(encoder); writer.write(datum, encoder); encoder.flush();