diff --git a/paimon-format/src/main/java/org/apache/paimon/format/orc/writer/OrcBulkWriter.java b/paimon-format/src/main/java/org/apache/paimon/format/orc/writer/OrcBulkWriter.java index 34278638fd40..478751fa1339 100644 --- a/paimon-format/src/main/java/org/apache/paimon/format/orc/writer/OrcBulkWriter.java +++ b/paimon-format/src/main/java/org/apache/paimon/format/orc/writer/OrcBulkWriter.java @@ -25,12 +25,8 @@ import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch; import org.apache.orc.Writer; -import org.apache.orc.impl.writer.TreeWriter; import java.io.IOException; -import java.lang.reflect.Field; -import java.security.AccessController; -import java.security.PrivilegedAction; import static org.apache.paimon.utils.Preconditions.checkNotNull; @@ -41,7 +37,6 @@ public class OrcBulkWriter implements FormatWriter { private final Vectorizer vectorizer; private final VectorizedRowBatch rowBatch; private final PositionOutputStream underlyingStream; - private final TreeWriter treeWriter; public OrcBulkWriter( Vectorizer vectorizer, @@ -56,8 +51,6 @@ public OrcBulkWriter( // metadata on the fly through the Vectorizer#vectorize(...) method. this.vectorizer.setWriter(this.writer); this.underlyingStream = underlyingStream; - // TODO: Turn to access these hidden field directly after upgrade to ORC 1.7.4 - this.treeWriter = getHiddenFieldInORC("treeWriter"); } @Override @@ -89,30 +82,13 @@ public boolean reachTargetSize(boolean suggestedCheck, long targetSize) throws I } private long length() throws IOException { - long estimateMemory = treeWriter.estimateMemory(); + long estimateMemory = writer.estimateMemory(); long fileLength = underlyingStream.getPos(); // This value is estimated, not actual. return (long) Math.ceil(fileLength + estimateMemory * 0.2); } - @SuppressWarnings("unchecked") - private T getHiddenFieldInORC(String fieldName) { - try { - Field treeWriterField = writer.getClass().getDeclaredField(fieldName); - AccessController.doPrivileged( - (PrivilegedAction) - () -> { - treeWriterField.setAccessible(true); - return null; - }); - return (T) treeWriterField.get(writer); - } catch (Exception e) { - throw new RuntimeException( - "Cannot get " + fieldName + " from " + writer.getClass().getName(), e); - } - } - @VisibleForTesting VectorizedRowBatch getRowBatch() { return rowBatch;