You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@parquet.apache.org by fo...@apache.org on 2020/05/07 15:55:46 UTC

[parquet-mr] branch master updated: PARQUET-1750: Reduce Memory Usage of RowRanges Class (#735)

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

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-mr.git


The following commit(s) were added to refs/heads/master by this push:
     new 94f89aa  PARQUET-1750: Reduce Memory Usage of RowRanges Class (#735)
94f89aa is described below

commit 94f89aad513521d4f15df034ec054dbde49c5ede
Author: belugabehr <12...@users.noreply.github.com>
AuthorDate: Thu May 7 11:55:40 2020 -0400

    PARQUET-1750: Reduce Memory Usage of RowRanges Class (#735)
    
    * PARQUET-1750: Reduce Memory Usage of RowRanges Class
    
    * Remove pre-initialized size constructor and add List constructor
    
    Co-authored-by: David Mollitor <dm...@apache.org>
---
 .../internal/filter2/columnindex/RowRanges.java    | 44 +++++++++++++++-------
 1 file changed, 31 insertions(+), 13 deletions(-)

diff --git a/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/RowRanges.java b/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/RowRanges.java
index 7753507..cf6a1ca 100644
--- a/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/RowRanges.java
+++ b/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/RowRanges.java
@@ -91,27 +91,50 @@ public class RowRanges {
     }
   }
 
-  static final RowRanges EMPTY = new RowRanges();
+  static final RowRanges EMPTY = new RowRanges(Collections.emptyList());
 
-  /*
-   * Creates a new RowRanges object with the single range [0, rowCount - 1].
+  private final List<Range> ranges;
+
+  private RowRanges() {
+    this(new ArrayList<>());
+  }
+
+  private RowRanges(Range range) {
+    this(Collections.singletonList(range));
+  }
+
+  private RowRanges(List<Range> ranges) {
+    this.ranges = ranges;
+  }
+
+  /**
+   * Creates an immutable RowRanges object with the single range [0, rowCount -
+   * 1].
+   *
+   * @param rowCount a single row count
+   * @return an immutable RowRanges
    */
   static RowRanges createSingle(long rowCount) {
-    RowRanges ranges = new RowRanges();
-    ranges.add(new Range(0, rowCount - 1));
-    return ranges;
+    return new RowRanges(new Range(0L, rowCount - 1L));
   }
 
-  /*
-   * Creates a new RowRanges object with the following ranges.
+  /**
+   * Creates a mutable RowRanges object with the following ranges:
+   * <pre>
    * [firstRowIndex[0], lastRowIndex[0]],
    * [firstRowIndex[1], lastRowIndex[1]],
    * ...,
    * [firstRowIndex[n], lastRowIndex[n]]
+   * </pre>
    * (See OffsetIndex.getFirstRowIndex and OffsetIndex.getLastRowIndex for details.)
    *
    * The union of the ranges are calculated so the result ranges always contain the disjunct ranges. See union for
    * details.
+   *
+   * @param rowCount row count
+   * @param pageIndexes pageIndexes
+   * @param offsetIndex offsetIndex
+   * @return a mutable RowRanges
    */
   static RowRanges create(long rowCount, PrimitiveIterator.OfInt pageIndexes, OffsetIndex offsetIndex) {
     RowRanges ranges = new RowRanges();
@@ -192,11 +215,6 @@ public class RowRanges {
     return result;
   }
 
-  private final List<Range> ranges = new ArrayList<>();
-
-  private RowRanges() {
-  }
-
   /*
    * Adds a range to the end of the list of ranges. It maintains the disjunct ascending order(*) of the ranges by
    * trying to union the specified range to the last ranges in the list. The specified range shall be larger(*) than