You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2022/03/04 17:21:48 UTC

[orc] branch main updated: ORC-1123: Add estimationMemory method for writer

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/main by this push:
     new 1d3f677  ORC-1123: Add estimationMemory method for writer
1d3f677 is described below

commit 1d3f6775397ae132347474427a2a66fc027b1c48
Author: Yiqun Zhang <gu...@gmail.com>
AuthorDate: Sat Mar 5 01:19:20 2022 +0800

    ORC-1123: Add estimationMemory method for writer
    
    ### What changes were proposed in this pull request?
    
    Add `estimationMemory` method for writer. It exposes the internal treeWriter to estimate the memory used for the buffer.
    
    ### Why are the changes needed?
    
    This method help the write engine to better control the refresh policy of the ORC.
    
    The source of this issue comes from Iceberg's discussion.
    https://lists.apache.org/thread/g6yo7m46mr86ov1vkm9wnmshgw7hcl6b
    
    ### How was this patch tested?
    
    Pass the CIs
---
 java/core/src/java/org/apache/orc/Writer.java          | 7 +++++++
 java/core/src/java/org/apache/orc/impl/WriterImpl.java | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/java/core/src/java/org/apache/orc/Writer.java b/java/core/src/java/org/apache/orc/Writer.java
index 0f8e76e..b63c9c8 100644
--- a/java/core/src/java/org/apache/orc/Writer.java
+++ b/java/core/src/java/org/apache/orc/Writer.java
@@ -165,4 +165,11 @@ public interface Writer extends Closeable {
    * @since 1.6.8
    */
   List<StripeInformation> getStripes() throws IOException;
+
+  /**
+   * Estimate the memory currently used by the writer to buffer the stripe.
+   * `This method help write engine to control the refresh policy of the ORC.`
+   * @return the number of bytes
+   */
+  long estimateMemory();
 }
diff --git a/java/core/src/java/org/apache/orc/impl/WriterImpl.java b/java/core/src/java/org/apache/orc/impl/WriterImpl.java
index b6f5b56..0724605 100644
--- a/java/core/src/java/org/apache/orc/impl/WriterImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/WriterImpl.java
@@ -1008,4 +1008,9 @@ public class WriterImpl implements WriterInternal, MemoryManager.Callback {
     }
     return result;
   }
+
+  @Override
+  public long estimateMemory() {
+    return this.treeWriter.estimateMemory();
+  }
 }