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 04076c96ba..e4e8563cb9 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 @@ 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 @@ void writePage(int rowCount, int valueCount, Statistics statistics, ValuesWri 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 b1f68aefba..f03ffc0349 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 @@ 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 DataPageV1(BytesInput bytes, int valueCount, int uncompressedSize, Statis */ 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 a1700aea00..706b699da8 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 @@ 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 static DataPageV2 uncompressed( 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 static DataPageV2 uncompressed( 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 DataPageV2( 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 @@ private DataPageV2( 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 2401fef400..21e1114f67 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 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 DictionaryPage(BytesInput bytes, int dictionarySize, Encoding encoding) { * @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 a51a8c4d82..8edf308227 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.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 BytesInput getBytes() { 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 6137236d9b..4a362f804f 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 @@ /** * Utilities for working with ints */ +@Deprecated public final class Ints { private Ints() { } @@ -31,6 +32,7 @@ private 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 0dc71e0743..0ca9fe3fe4 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.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 @@ public DataPage visit(DataPageV1 dataPageV1) { 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 @@ public DataPage visit(DataPageV2 dataPageV2) { } } try { - int uncompressedSize = Ints.checkedCast( + int uncompressedSize = Math.toIntExact( dataPageV2.getUncompressedSize() - dataPageV2.getDefinitionLevels().size() - dataPageV2.getRepetitionLevels().size());