parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [parquet-mr] branch master updated: PARQUET-1503: Remove Ints Utility Class (#598)
Date Fri, 25 Jan 2019 08:21:19 GMT
This is an automated email from the ASF dual-hosted git repository.

gabor 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 1e62e2e  PARQUET-1503: Remove Ints Utility Class (#598)
1e62e2e is described below

commit 1e62e2e2ca903d4109480bc87ceec1dc954b6c92
Author: BELUGABEHR <BELUGABEHR@users.noreply.github.com>
AuthorDate: Fri Jan 25 03:21:15 2019 -0500

    PARQUET-1503: Remove Ints Utility Class (#598)
---
 .../main/java/org/apache/parquet/column/impl/ColumnWriterV2.java | 3 +--
 .../src/main/java/org/apache/parquet/column/page/DataPageV1.java | 5 ++---
 .../src/main/java/org/apache/parquet/column/page/DataPageV2.java | 9 ++++-----
 .../main/java/org/apache/parquet/column/page/DictionaryPage.java | 3 +--
 .../column/values/rle/RunLengthBitPackingHybridValuesWriter.java | 3 +--
 parquet-common/src/main/java/org/apache/parquet/Ints.java        | 2 ++
 .../java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java | 7 ++-----
 7 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/parquet-column/src/main/java/org/apache/parquet/column/impl/ColumnWriterV2.java
b/parquet-column/src/main/java/org/apache/parquet/column/impl/ColumnWriterV2.java
index 04076c9..e4e8563 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/impl/ColumnWriterV2.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/impl/ColumnWriterV2.java
@@ -20,7 +20,6 @@ package org.apache.parquet.column.impl;
 
 import java.io.IOException;
 
-import org.apache.parquet.Ints;
 import org.apache.parquet.bytes.BytesInput;
 import org.apache.parquet.column.ColumnDescriptor;
 import org.apache.parquet.column.Encoding;
@@ -78,7 +77,7 @@ final class ColumnWriterV2 extends ColumnWriterBase {
     Encoding encoding = values.getEncoding();
     pageWriter.writePageV2(
         rowCount,
-        Ints.checkedCast(statistics.getNumNulls()),
+        Math.toIntExact(statistics.getNumNulls()),
         valueCount,
         repetitionLevels.getBytes(),
         definitionLevels.getBytes(),
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV1.java b/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV1.java
index b1f68ae..f03ffc0 100755
--- a/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV1.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV1.java
@@ -20,7 +20,6 @@ package org.apache.parquet.column.page;
 
 import java.util.Optional;
 
-import org.apache.parquet.Ints;
 import org.apache.parquet.bytes.BytesInput;
 import org.apache.parquet.column.Encoding;
 import org.apache.parquet.column.statistics.Statistics;
@@ -44,7 +43,7 @@ public class DataPageV1 extends DataPage {
    * @param valuesEncoding the values encoding for this page
    */
   public DataPageV1(BytesInput bytes, int valueCount, int uncompressedSize, Statistics<?>
statistics, Encoding rlEncoding, Encoding dlEncoding, Encoding valuesEncoding) {
-    super(Ints.checkedCast(bytes.size()), uncompressedSize, valueCount);
+    super(Math.toIntExact(bytes.size()), uncompressedSize, valueCount);
     this.bytes = bytes;
     this.statistics = statistics;
     this.rlEncoding = rlEncoding;
@@ -66,7 +65,7 @@ public class DataPageV1 extends DataPage {
    */
   public DataPageV1(BytesInput bytes, int valueCount, int uncompressedSize, long firstRowIndex,
int rowCount,
       Statistics<?> statistics, Encoding rlEncoding, Encoding dlEncoding, Encoding
valuesEncoding) {
-    super(Ints.checkedCast(bytes.size()), uncompressedSize, valueCount, firstRowIndex);
+    super(Math.toIntExact(bytes.size()), uncompressedSize, valueCount, firstRowIndex);
     this.bytes = bytes;
     this.statistics = statistics;
     this.rlEncoding = rlEncoding;
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV2.java b/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV2.java
index a1700ae..706b699 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV2.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/page/DataPageV2.java
@@ -20,7 +20,6 @@ package org.apache.parquet.column.page;
 
 import java.util.Optional;
 
-import org.apache.parquet.Ints;
 import org.apache.parquet.bytes.BytesInput;
 import org.apache.parquet.column.Encoding;
 import org.apache.parquet.column.statistics.Statistics;
@@ -47,7 +46,7 @@ public class DataPageV2 extends DataPage {
         rowCount, nullCount, valueCount,
         repetitionLevels, definitionLevels,
         dataEncoding, data,
-        Ints.checkedCast(repetitionLevels.size() + definitionLevels.size() + data.size()),
+        Math.toIntExact(repetitionLevels.size() + definitionLevels.size() + data.size()),
         statistics,
         false);
   }
@@ -73,7 +72,7 @@ public class DataPageV2 extends DataPage {
         rowCount, nullCount, valueCount, firstRowIndex,
         repetitionLevels, definitionLevels,
         dataEncoding, data,
-        Ints.checkedCast(repetitionLevels.size() + definitionLevels.size() + data.size()),
+        Math.toIntExact(repetitionLevels.size() + definitionLevels.size() + data.size()),
         statistics,
         false);
   }
@@ -121,7 +120,7 @@ public class DataPageV2 extends DataPage {
       int uncompressedSize,
       Statistics<?> statistics,
       boolean isCompressed) {
-    super(Ints.checkedCast(repetitionLevels.size() + definitionLevels.size() + data.size()),
uncompressedSize, valueCount);
+    super(Math.toIntExact(repetitionLevels.size() + definitionLevels.size() + data.size()),
uncompressedSize, valueCount);
     this.rowCount = rowCount;
     this.nullCount = nullCount;
     this.repetitionLevels = repetitionLevels;
@@ -139,7 +138,7 @@ public class DataPageV2 extends DataPage {
       int uncompressedSize,
       Statistics<?> statistics,
       boolean isCompressed) {
-    super(Ints.checkedCast(repetitionLevels.size() + definitionLevels.size() + data.size()),
uncompressedSize,
+    super(Math.toIntExact(repetitionLevels.size() + definitionLevels.size() + data.size()),
uncompressedSize,
         valueCount, firstRowIndex);
     this.rowCount = rowCount;
     this.nullCount = nullCount;
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/page/DictionaryPage.java
b/parquet-column/src/main/java/org/apache/parquet/column/page/DictionaryPage.java
index 2401fef..21e1114 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/page/DictionaryPage.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/page/DictionaryPage.java
@@ -22,7 +22,6 @@ import static org.apache.parquet.Preconditions.checkNotNull;
 
 import java.io.IOException;
 
-import org.apache.parquet.Ints;
 import org.apache.parquet.bytes.BytesInput;
 import org.apache.parquet.column.Encoding;
 
@@ -53,7 +52,7 @@ public class DictionaryPage extends Page {
    * @param encoding the encoding used
    */
   public DictionaryPage(BytesInput bytes, int uncompressedSize, int dictionarySize, Encoding
encoding) {
-    super(Ints.checkedCast(bytes.size()), uncompressedSize);
+    super(Math.toIntExact(bytes.size()), uncompressedSize);
     this.bytes = checkNotNull(bytes, "bytes");
     this.dictionarySize = dictionarySize;
     this.encoding = checkNotNull(encoding, "encoding");
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/values/rle/RunLengthBitPackingHybridValuesWriter.java
b/parquet-column/src/main/java/org/apache/parquet/column/values/rle/RunLengthBitPackingHybridValuesWriter.java
index a51a8c4..8edf308 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/values/rle/RunLengthBitPackingHybridValuesWriter.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/values/rle/RunLengthBitPackingHybridValuesWriter.java
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.util.Objects;
 
 import org.apache.parquet.bytes.ByteBufferAllocator;
-import org.apache.parquet.Ints;
 import org.apache.parquet.bytes.BytesInput;
 import org.apache.parquet.column.Encoding;
 import org.apache.parquet.column.values.ValuesWriter;
@@ -68,7 +67,7 @@ public class RunLengthBitPackingHybridValuesWriter extends ValuesWriter
{
     try {
       // prepend the length of the column
       BytesInput rle = encoder.toBytes();
-      return BytesInput.concat(BytesInput.fromInt(Ints.checkedCast(rle.size())), rle);
+      return BytesInput.concat(BytesInput.fromInt(Math.toIntExact(rle.size())), rle);
     } catch (IOException e) {
       throw new ParquetEncodingException(e);
     }
diff --git a/parquet-common/src/main/java/org/apache/parquet/Ints.java b/parquet-common/src/main/java/org/apache/parquet/Ints.java
index 6137236..4a362f8 100644
--- a/parquet-common/src/main/java/org/apache/parquet/Ints.java
+++ b/parquet-common/src/main/java/org/apache/parquet/Ints.java
@@ -21,6 +21,7 @@ package org.apache.parquet;
 /**
  * Utilities for working with ints
  */
+@Deprecated
 public final class Ints {
   private Ints() { }
 
@@ -31,6 +32,7 @@ public final class Ints {
    * @param value a long to be casted to an int
    * @return an int that is == to value
    * @throws IllegalArgumentException if value can't be casted to an int
+   * @deprecated replaced by {@link java.lang.Math#toIntExact(long)}
    */
   public static int checkedCast(long value) {
     int valueI = (int) value;
diff --git a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
index 0dc71e0..0ca9fe3 100644
--- a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
+++ b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java
@@ -18,8 +18,6 @@
  */
 package org.apache.parquet.hadoop;
 
-import static org.apache.parquet.Ints.checkedCast;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -27,7 +25,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.PrimitiveIterator;
-import org.apache.parquet.Ints;
 import org.apache.parquet.bytes.BytesInput;
 import org.apache.parquet.column.ColumnDescriptor;
 import org.apache.parquet.column.page.DataPage;
@@ -118,7 +115,7 @@ class ColumnChunkPageReadStore implements PageReadStore, DictionaryPageReadStore
                   dataPageV1.getValueCount(),
                   dataPageV1.getUncompressedSize(),
                   firstRowIndex,
-                  checkedCast(offsetIndex.getLastRowIndex(currentPageIndex, rowCount) - firstRowIndex
+ 1),
+                  Math.toIntExact(offsetIndex.getLastRowIndex(currentPageIndex, rowCount)
- firstRowIndex + 1),
                   dataPageV1.getStatistics(),
                   dataPageV1.getRlEncoding(),
                   dataPageV1.getDlEncoding(),
@@ -148,7 +145,7 @@ class ColumnChunkPageReadStore implements PageReadStore, DictionaryPageReadStore
             }
           }
           try {
-            int uncompressedSize = Ints.checkedCast(
+            int uncompressedSize = Math.toIntExact(
                 dataPageV2.getUncompressedSize()
                     - dataPageV2.getDefinitionLevels().size()
                     - dataPageV2.getRepetitionLevels().size());


Mime
View raw message