openinx commented on a change in pull request #3784:
URL: https://github.com/apache/iceberg/pull/3784#discussion_r830944876
##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcFileAppender.java
##########
@@ -99,9 +110,27 @@ public Metrics metrics() {
@Override
public long length() {
- Preconditions.checkState(isClosed,
- "Cannot return length while appending to an open file.");
- return file.toInputFile().getLength();
+ if (isClosed) {
+ return file.toInputFile().getLength();
+ }
+ if (this.treeWriter == null) {
+ throw new RuntimeException("Can't get the length!");
+ }
+ long estimateMemory = this.treeWriter.estimateMemory();
+
+ long dataLength = 0;
+ try {
+ List<StripeInformation> stripes = writer.getStripes();
+ if (!stripes.isEmpty()) {
+ StripeInformation stripeInformation = stripes.get(stripes.size() - 1);
+ dataLength = stripeInformation != null ? stripeInformation.getOffset()
+ stripeInformation.getLength() : 0;
+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException(String.format("Can't get stripes from
file %s", file.location()), e);
+ }
+
+ // This value is estimated, not actual.
+ return dataLength + estimateMemory + (long) batch.size * estimateLength;
Review comment:
Do we need to multiple the `batch.size * avgRowByteSize` with an
experience compress ratio ? according to the mail list discussion..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]