Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ public int hashCode() {
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof ColumnDescriptor)) return false;
ColumnDescriptor descriptor = (ColumnDescriptor) other;
if (!(other instanceof ColumnDescriptor descriptor)) return false;
return Arrays.equals(path, descriptor.path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,44 +251,33 @@ public boolean isByteStreamSplitEnabled() {
}

public boolean isByteStreamSplitEnabled(ColumnDescriptor column) {
switch (column.getPrimitiveType().getPrimitiveTypeName()) {
case FLOAT:
case DOUBLE:
return byteStreamSplitEnabled.getValue(column) != ByteStreamSplitMode.NONE;
case INT32:
case INT64:
case FIXED_LEN_BYTE_ARRAY:
return byteStreamSplitEnabled.getValue(column) == ByteStreamSplitMode.EXTENDED;
default:
return false;
}
return switch (column.getPrimitiveType().getPrimitiveTypeName()) {
case FLOAT, DOUBLE -> byteStreamSplitEnabled.getValue(column) != ByteStreamSplitMode.NONE;
case INT32, INT64, FIXED_LEN_BYTE_ARRAY ->
byteStreamSplitEnabled.getValue(column) == ByteStreamSplitMode.EXTENDED;
default -> false;
};
}

public ByteBufferAllocator getAllocator() {
return allocator;
}

public ColumnWriteStore newColumnWriteStore(MessageType schema, PageWriteStore pageStore) {
switch (writerVersion) {
case PARQUET_1_0:
return new ColumnWriteStoreV1(schema, pageStore, this);
case PARQUET_2_0:
return new ColumnWriteStoreV2(schema, pageStore, this);
default:
throw new IllegalArgumentException("unknown version " + writerVersion);
}
return switch (writerVersion) {
case PARQUET_1_0 -> new ColumnWriteStoreV1(schema, pageStore, this);
case PARQUET_2_0 -> new ColumnWriteStoreV2(schema, pageStore, this);
default -> throw new IllegalArgumentException("unknown version " + writerVersion);
};
}

public ColumnWriteStore newColumnWriteStore(
MessageType schema, PageWriteStore pageStore, BloomFilterWriteStore bloomFilterWriteStore) {
switch (writerVersion) {
case PARQUET_1_0:
return new ColumnWriteStoreV1(schema, pageStore, bloomFilterWriteStore, this);
case PARQUET_2_0:
return new ColumnWriteStoreV2(schema, pageStore, bloomFilterWriteStore, this);
default:
throw new IllegalArgumentException("unknown version " + writerVersion);
}
return switch (writerVersion) {
case PARQUET_1_0 -> new ColumnWriteStoreV1(schema, pageStore, bloomFilterWriteStore, this);
case PARQUET_2_0 -> new ColumnWriteStoreV2(schema, pageStore, bloomFilterWriteStore, this);
default -> throw new IllegalArgumentException("unknown version " + writerVersion);
};
}

public int getMinRowCountForPageSizeCheck() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,9 @@ protected String typeParametersAsString() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof DecimalLogicalTypeAnnotation)) {
if (!(obj instanceof DecimalLogicalTypeAnnotation other)) {
return false;
}
DecimalLogicalTypeAnnotation other = (DecimalLogicalTypeAnnotation) obj;
return scale == other.scale && precision == other.precision;
}

Expand Down Expand Up @@ -713,10 +712,9 @@ public boolean isAdjustedToUTC() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof TimeLogicalTypeAnnotation)) {
if (!(obj instanceof TimeLogicalTypeAnnotation other)) {
return false;
}
TimeLogicalTypeAnnotation other = (TimeLogicalTypeAnnotation) obj;
return isAdjustedToUTC == other.isAdjustedToUTC && unit == other.unit;
}

Expand Down Expand Up @@ -792,10 +790,9 @@ public boolean isAdjustedToUTC() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof TimestampLogicalTypeAnnotation)) {
if (!(obj instanceof TimestampLogicalTypeAnnotation other)) {
return false;
}
TimestampLogicalTypeAnnotation other = (TimestampLogicalTypeAnnotation) obj;
return (isAdjustedToUTC == other.isAdjustedToUTC) && (unit == other.unit);
}

Expand Down Expand Up @@ -881,10 +878,9 @@ public boolean isSigned() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof IntLogicalTypeAnnotation)) {
if (!(obj instanceof IntLogicalTypeAnnotation other)) {
return false;
}
IntLogicalTypeAnnotation other = (IntLogicalTypeAnnotation) obj;
return (bitWidth == other.bitWidth) && (isSigned == other.isSigned);
}

Expand Down Expand Up @@ -1220,11 +1216,10 @@ protected String typeParametersAsString() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof VariantLogicalTypeAnnotation)) {
if (!(obj instanceof VariantLogicalTypeAnnotation other)) {
return false;
}

VariantLogicalTypeAnnotation other = (VariantLogicalTypeAnnotation) obj;
return specVersion == other.specVersion;
}
}
Expand Down Expand Up @@ -1266,10 +1261,9 @@ public String getCrs() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof GeometryLogicalTypeAnnotation)) {
if (!(obj instanceof GeometryLogicalTypeAnnotation other)) {
return false;
}
GeometryLogicalTypeAnnotation other = (GeometryLogicalTypeAnnotation) obj;
return Objects.equals(crs, other.crs);
}

Expand Down Expand Up @@ -1329,10 +1323,9 @@ public EdgeInterpolationAlgorithm getAlgorithm() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof GeographyLogicalTypeAnnotation)) {
if (!(obj instanceof GeographyLogicalTypeAnnotation other)) {
return false;
}
GeographyLogicalTypeAnnotation other = (GeographyLogicalTypeAnnotation) obj;
return Objects.equals(crs, other.crs) && Objects.equals(algorithm, other.algorithm);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,16 @@ public static int readIntLittleEndianOnThreeBytes(InputStream in) throws IOExcep
public static int readIntLittleEndianPaddedOnBitWidth(InputStream in, int bitWidth) throws IOException {

int bytesWidth = paddedByteCountFromBits(bitWidth);
switch (bytesWidth) {
case 0:
return 0;
case 1:
return BytesUtils.readIntLittleEndianOnOneByte(in);
case 2:
return BytesUtils.readIntLittleEndianOnTwoBytes(in);
case 3:
return BytesUtils.readIntLittleEndianOnThreeBytes(in);
case 4:
return BytesUtils.readIntLittleEndian(in);
default:
return switch (bytesWidth) {
case 0 -> 0;
case 1 -> BytesUtils.readIntLittleEndianOnOneByte(in);
case 2 -> BytesUtils.readIntLittleEndianOnTwoBytes(in);
case 3 -> BytesUtils.readIntLittleEndianOnThreeBytes(in);
case 4 -> BytesUtils.readIntLittleEndian(in);
default ->
throw new IOException(
String.format("Encountered bitWidth (%d) that requires more than 4 bytes", bitWidth));
}
};
}

public static void writeIntLittleEndianOnOneByte(OutputStream out, int v) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,18 @@ private BitPacking() {}
* @return the correct implementation for the width
*/
public static BitPackingWriter getBitPackingWriter(int bitLength, OutputStream out) {
switch (bitLength) {
case 0:
return new ZeroBitPackingWriter();
case 1:
return new OneBitPackingWriter(out);
case 2:
return new TwoBitPackingWriter(out);
case 3:
return new ThreeBitPackingWriter(out);
case 4:
return new FourBitPackingWriter(out);
case 5:
return new FiveBitPackingWriter(out);
case 6:
return new SixBitPackingWriter(out);
case 7:
return new SevenBitPackingWriter(out);
case 8:
return new EightBitPackingWriter(out);
default:
throw new UnsupportedOperationException("only support up to 8 for now");
}
return switch (bitLength) {
case 0 -> new ZeroBitPackingWriter();
case 1 -> new OneBitPackingWriter(out);
case 2 -> new TwoBitPackingWriter(out);
case 3 -> new ThreeBitPackingWriter(out);
case 4 -> new FourBitPackingWriter(out);
case 5 -> new FiveBitPackingWriter(out);
case 6 -> new SixBitPackingWriter(out);
case 7 -> new SevenBitPackingWriter(out);
case 8 -> new EightBitPackingWriter(out);
default -> throw new UnsupportedOperationException("only support up to 8 for now");
};
}

/**
Expand All @@ -104,28 +94,18 @@ public static BitPackingWriter getBitPackingWriter(int bitLength, OutputStream o
* @return the correct implementation for the width
*/
public static BitPackingReader createBitPackingReader(int bitLength, InputStream in, long valueCount) {
switch (bitLength) {
case 0:
return new ZeroBitPackingReader();
case 1:
return new OneBitPackingReader(in);
case 2:
return new TwoBitPackingReader(in);
case 3:
return new ThreeBitPackingReader(in, valueCount);
case 4:
return new FourBitPackingReader(in);
case 5:
return new FiveBitPackingReader(in, valueCount);
case 6:
return new SixBitPackingReader(in, valueCount);
case 7:
return new SevenBitPackingReader(in, valueCount);
case 8:
return new EightBitPackingReader(in);
default:
throw new UnsupportedOperationException("only support up to 8 for now");
}
return switch (bitLength) {
case 0 -> new ZeroBitPackingReader();
case 1 -> new OneBitPackingReader(in);
case 2 -> new TwoBitPackingReader(in);
case 3 -> new ThreeBitPackingReader(in, valueCount);
case 4 -> new FourBitPackingReader(in);
case 5 -> new FiveBitPackingReader(in, valueCount);
case 6 -> new SixBitPackingReader(in, valueCount);
case 7 -> new SevenBitPackingReader(in, valueCount);
case 8 -> new EightBitPackingReader(in);
default -> throw new UnsupportedOperationException("only support up to 8 for now");
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ private static boolean isNaNLiteral(ColumnChunkMetaData meta, Object value) {
PrimitiveTypeName type = meta.getPrimitiveType().getPrimitiveTypeName();
switch (type) {
case FLOAT:
return value instanceof Float && Float.isNaN((Float) value);
return value instanceof Float floatValue && Float.isNaN(floatValue);
case DOUBLE:
return value instanceof Double && Double.isNaN((Double) value);
return value instanceof Double doubleValue && Double.isNaN(doubleValue);
case FIXED_LEN_BYTE_ARRAY:
return isFloat16(meta)
&& value instanceof Binary
&& ((Binary) value).length() == 2
&& Float16.isNaN(((Binary) value).get2BytesLittleEndian());
&& value instanceof Binary binaryValue
&& binaryValue.length() == 2
&& Float16.isNaN(binaryValue.get2BytesLittleEndian());
default:
return false;
}
Expand Down
Loading
Loading