Skip to content

Commit

Permalink
[core] use paimon checkArgument instead of parquet's (apache#3515)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannByron authored Jun 13, 2024
1 parent 705c959 commit 8b4f3df
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.paimon.data.columnar.writable.WritableColumnVector;
import org.apache.paimon.data.columnar.writable.WritableIntVector;

import org.apache.parquet.Preconditions;
import org.apache.parquet.bytes.ByteBufferInputStream;
import org.apache.parquet.bytes.BytesInput;
import org.apache.parquet.bytes.BytesUtils;
Expand All @@ -44,6 +43,7 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import static org.apache.paimon.utils.Preconditions.checkArgument;
import static org.apache.parquet.column.ValuesType.REPETITION_LEVEL;

/**
Expand Down Expand Up @@ -132,7 +132,7 @@ public AbstractColumnReader(ColumnDescriptor descriptor, PageReader pageReader)
protected void checkTypeName(PrimitiveType.PrimitiveTypeName expectedName) {
PrimitiveType.PrimitiveTypeName actualName =
descriptor.getPrimitiveType().getPrimitiveTypeName();
Preconditions.checkArgument(
checkArgument(
actualName == expectedName,
"Expected type name: %s, actual type name: %s",
expectedName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.paimon.data.columnar.LongColumnVector;
import org.apache.paimon.format.parquet.ParquetSchemaConverter;

import org.apache.parquet.Preconditions;
import static org.apache.paimon.utils.Preconditions.checkArgument;

/**
* Parquet write decimal as int32 and int64 and binary, this class wrap the real vector to provide
Expand All @@ -49,7 +49,7 @@ public Decimal getDecimal(int i, int precision, int scale) {
return Decimal.fromUnscaledLong(
((LongColumnVector) vector).getLong(i), precision, scale);
} else {
Preconditions.checkArgument(
checkArgument(
vector instanceof BytesColumnVector,
"Reading decimal type occur unsupported vector type: %s",
vector.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.parquet.Preconditions.checkArgument;
import static org.apache.paimon.utils.Preconditions.checkArgument;

/** Util for generating {@link ColumnReader}. */
public class ParquetSplitReaderUtil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.paimon.data.columnar.LongColumnVector;
import org.apache.paimon.data.columnar.TimestampColumnVector;

import org.apache.parquet.Preconditions;
import static org.apache.paimon.utils.Preconditions.checkArgument;

/**
* Parquet write timestamp precision 0-3 as int64 mills, 4-6 as int64 micros, 7-9 as int96, this
Expand All @@ -44,7 +44,7 @@ public Timestamp getTimestamp(int i, int precision) {
} else if (precision <= 6 && vector instanceof LongColumnVector) {
return Timestamp.fromMicros(((LongColumnVector) vector).getLong(i));
} else {
Preconditions.checkArgument(
checkArgument(
vector instanceof TimestampColumnVector,
"Reading timestamp type occur unsupported vector type: %s",
vector.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.paimon.data.columnar.writable.WritableColumnVector;
import org.apache.paimon.data.columnar.writable.WritableIntVector;

import org.apache.parquet.Preconditions;
import org.apache.parquet.bytes.ByteBufferInputStream;
import org.apache.parquet.bytes.BytesUtils;
import org.apache.parquet.column.values.bitpacking.BytePacker;
Expand All @@ -32,6 +31,8 @@
import java.io.IOException;
import java.nio.ByteBuffer;

import static org.apache.paimon.utils.Preconditions.checkArgument;

/**
* Run length decoder for data and dictionary ids. See <a
* href="https://github.com/apache/parquet-format/blob/master/Encodings.md">Parquet Format
Expand Down Expand Up @@ -108,8 +109,7 @@ void initFromStream(int valueCount, ByteBufferInputStream in) throws IOException

/** Initializes the internal state for decoding ints of `bitWidth`. */
private void initWidthAndPacker(int bitWidth) {
Preconditions.checkArgument(
bitWidth >= 0 && bitWidth <= 32, "bitWidth must be >= 0 and <= 32");
checkArgument(bitWidth >= 0 && bitWidth <= 32, "bitWidth must be >= 0 and <= 32");
this.bitWidth = bitWidth;
this.bytesWidth = BytesUtils.paddedByteCountFromBits(bitWidth);
this.packer = Packer.LITTLE_ENDIAN.newBytePacker(bitWidth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.paimon.data.columnar.writable.WritableIntVector;
import org.apache.paimon.data.columnar.writable.WritableTimestampVector;

import org.apache.parquet.Preconditions;
import org.apache.parquet.column.ColumnDescriptor;
import org.apache.parquet.column.page.PageReader;
import org.apache.parquet.io.api.Binary;
Expand All @@ -33,6 +32,8 @@
import java.nio.ByteOrder;
import java.util.concurrent.TimeUnit;

import static org.apache.paimon.utils.Preconditions.checkArgument;

/**
* Timestamp {@link ColumnReader}. We only support INT96 bytes now, julianDay(4) + nanosOfDay(8).
* See https://github.com/apache/parquet-format/blob/master/DataTypes.md#timestamp TIMESTAMP_MILLIS
Expand Down Expand Up @@ -89,8 +90,7 @@ protected void readBatchFromDictionaryIds(
public static Timestamp decodeInt96ToTimestamp(
boolean utcTimestamp, org.apache.parquet.column.Dictionary dictionary, int id) {
Binary binary = dictionary.decodeToBinary(id);
Preconditions.checkArgument(
binary.length() == 12, "Timestamp with int96 should be 12 bytes.");
checkArgument(binary.length() == 12, "Timestamp with int96 should be 12 bytes.");
ByteBuffer buffer = binary.toByteBuffer().order(ByteOrder.LITTLE_ENDIAN);
return int96ToTimestamp(utcTimestamp, buffer.getLong(), buffer.getInt());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.apache.hadoop.fs.Path;
import org.apache.parquet.ParquetReadOptions;
import org.apache.parquet.Preconditions;
import org.apache.parquet.bytes.ByteBufferInputStream;
import org.apache.parquet.bytes.BytesInput;
import org.apache.parquet.column.ColumnDescriptor;
Expand Down Expand Up @@ -95,6 +94,7 @@
import java.util.concurrent.ExecutionException;
import java.util.zip.CRC32;

import static org.apache.paimon.utils.Preconditions.checkArgument;
import static org.apache.parquet.bytes.BytesUtils.readIntLittleEndian;
import static org.apache.parquet.filter2.compat.RowGroupFilter.FilterLevel.BLOOMFILTER;
import static org.apache.parquet.filter2.compat.RowGroupFilter.FilterLevel.DICTIONARY;
Expand Down Expand Up @@ -565,7 +565,7 @@ private void readVectored(List<ConsecutivePartList> allParts, ChunkListBuilder b
long totalSize = 0;
for (ConsecutivePartList consecutiveChunks : allParts) {
final long len = consecutiveChunks.length;
Preconditions.checkArgument(
checkArgument(
len < Integer.MAX_VALUE,
"Invalid length %s for vectored read operation. It must be less than max integer value.",
len);
Expand Down

0 comments on commit 8b4f3df

Please sign in to comment.