Skip to content

Commit cabf77e

Browse files
committed
Fix Spotless code formatting violations in parquet-compression
Apply palantir-java-format rules to DirectCodecFactory and TestDefaultCompressionCodecFactory: join short lines that fit within the column limit, and break method chains and long argument lists according to the project style. Assisted-by: GitHub Copilot:claude-opus-4.6
1 parent 5de3272 commit cabf77e

5 files changed

Lines changed: 35 additions & 26 deletions

File tree

parquet-compression/src/main/java/org/apache/parquet/compression/DirectCodecFactory.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ public BytesInput decompress(BytesInput bytes, int decompressedSize) throws IOEx
121121
ByteBuffer output = outputAllocator.allocate(decompressedSize);
122122
int size = decompress(input.slice(), output.slice());
123123
if (size != decompressedSize) {
124-
throw new IOException(
125-
"Unexpected decompressed size: " + size + " != " + decompressedSize);
124+
throw new IOException("Unexpected decompressed size: " + size + " != " + decompressedSize);
126125
}
127126
output.limit(size);
128127
return BytesInput.from(output);
@@ -140,8 +139,7 @@ public void decompress(ByteBuffer input, int compressedSize, ByteBuffer output,
140139
output.limit(output.position() + decompressedSize);
141140
int size = decompress(input.slice(), output.slice());
142141
if (size != decompressedSize) {
143-
throw new IOException(
144-
"Unexpected decompressed size: " + size + " != " + decompressedSize);
142+
throw new IOException("Unexpected decompressed size: " + size + " != " + decompressedSize);
145143
}
146144
input.position(input.limit());
147145
input.limit(origInputLimit);
@@ -293,10 +291,8 @@ private class ZstdCompressor extends BaseCompressor {
293291

294292
ZstdCompressor() {
295293
context = new ZstdCompressCtx();
296-
context.setLevel(conf.getInt(
297-
PARQUET_COMPRESS_ZSTD_LEVEL, DEFAULT_PARQUET_COMPRESS_ZSTD_LEVEL));
298-
context.setWorkers(conf.getInt(
299-
PARQUET_COMPRESS_ZSTD_WORKERS, DEFAULT_PARQUET_COMPRESS_ZSTD_WORKERS));
294+
context.setLevel(conf.getInt(PARQUET_COMPRESS_ZSTD_LEVEL, DEFAULT_PARQUET_COMPRESS_ZSTD_LEVEL));
295+
context.setWorkers(conf.getInt(PARQUET_COMPRESS_ZSTD_WORKERS, DEFAULT_PARQUET_COMPRESS_ZSTD_WORKERS));
300296
}
301297

302298
@Override

parquet-compression/src/test/java/org/apache/parquet/compression/TestDefaultCompressionCodecFactory.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,18 @@ public void zstdLevelAffectsCompression() throws IOException {
107107
DefaultCompressionCodecFactory factoryLow = new DefaultCompressionCodecFactory(confLow, PAGE_SIZE);
108108
DefaultCompressionCodecFactory factoryHigh = new DefaultCompressionCodecFactory(confHigh, PAGE_SIZE);
109109

110-
long sizeLow = factoryLow.getCompressor(CompressionCodecName.ZSTD)
111-
.compress(BytesInput.from(data)).size();
112-
long sizeHigh = factoryHigh.getCompressor(CompressionCodecName.ZSTD)
113-
.compress(BytesInput.from(data)).size();
110+
long sizeLow = factoryLow
111+
.getCompressor(CompressionCodecName.ZSTD)
112+
.compress(BytesInput.from(data))
113+
.size();
114+
long sizeHigh = factoryHigh
115+
.getCompressor(CompressionCodecName.ZSTD)
116+
.compress(BytesInput.from(data))
117+
.size();
114118

115119
// Higher level should produce smaller output
116-
assertTrue("ZSTD level=19 should compress better than level=1, got " + sizeHigh + " >= " + sizeLow,
120+
assertTrue(
121+
"ZSTD level=19 should compress better than level=1, got " + sizeHigh + " >= " + sizeLow,
117122
sizeHigh < sizeLow);
118123

119124
factoryLow.release();
@@ -129,7 +134,8 @@ public void zstdWorkersConfigRoundTrip() throws IOException {
129134
byte[] data = compressibleData(64 * 1024);
130135

131136
CompressionCodecFactory.BytesInputCompressor compressor = factory.getCompressor(CompressionCodecName.ZSTD);
132-
CompressionCodecFactory.BytesInputDecompressor decompressor = factory.getDecompressor(CompressionCodecName.ZSTD);
137+
CompressionCodecFactory.BytesInputDecompressor decompressor =
138+
factory.getDecompressor(CompressionCodecName.ZSTD);
133139

134140
BytesInput compressed = compressor.compress(BytesInput.from(data));
135141
BytesInput decompressed = decompressor.decompress(compressed, data.length);
@@ -153,12 +159,17 @@ public void gzipLevelAffectsCompression() throws IOException {
153159
DefaultCompressionCodecFactory factoryFast = new DefaultCompressionCodecFactory(confFast, PAGE_SIZE);
154160
DefaultCompressionCodecFactory factoryBest = new DefaultCompressionCodecFactory(confBest, PAGE_SIZE);
155161

156-
long sizeFast = factoryFast.getCompressor(CompressionCodecName.GZIP)
157-
.compress(BytesInput.from(data)).size();
158-
long sizeBest = factoryBest.getCompressor(CompressionCodecName.GZIP)
159-
.compress(BytesInput.from(data)).size();
160-
161-
assertTrue("GZIP level=9 should compress better than level=1, got " + sizeBest + " >= " + sizeFast,
162+
long sizeFast = factoryFast
163+
.getCompressor(CompressionCodecName.GZIP)
164+
.compress(BytesInput.from(data))
165+
.size();
166+
long sizeBest = factoryBest
167+
.getCompressor(CompressionCodecName.GZIP)
168+
.compress(BytesInput.from(data))
169+
.size();
170+
171+
assertTrue(
172+
"GZIP level=9 should compress better than level=1, got " + sizeBest + " >= " + sizeFast,
162173
sizeBest < sizeFast);
163174

164175
factoryFast.release();
@@ -193,7 +204,8 @@ public void uncompressedPassThrough() throws IOException {
193204
DefaultCompressionCodecFactory factory = createFactory();
194205
byte[] data = compressibleData(1024);
195206

196-
CompressionCodecFactory.BytesInputCompressor compressor = factory.getCompressor(CompressionCodecName.UNCOMPRESSED);
207+
CompressionCodecFactory.BytesInputCompressor compressor =
208+
factory.getCompressor(CompressionCodecName.UNCOMPRESSED);
197209
CompressionCodecFactory.BytesInputDecompressor decompressor =
198210
factory.getDecompressor(CompressionCodecName.UNCOMPRESSED);
199211

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/CodecFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
@Deprecated
3636
public class CodecFactory extends DefaultCompressionCodecFactory {
3737

38-
public static final String PARQUET_COMPRESS_ZSTD_LEVEL =
39-
DefaultCompressionCodecFactory.PARQUET_COMPRESS_ZSTD_LEVEL;
38+
public static final String PARQUET_COMPRESS_ZSTD_LEVEL = DefaultCompressionCodecFactory.PARQUET_COMPRESS_ZSTD_LEVEL;
4039
public static final int DEFAULT_PARQUET_COMPRESS_ZSTD_LEVEL =
4140
DefaultCompressionCodecFactory.DEFAULT_PARQUET_COMPRESS_ZSTD_LEVEL;
4241
public static final String PARQUET_COMPRESS_ZSTD_WORKERS =

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageWriteStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
import org.apache.parquet.column.values.bloomfilter.BloomFilterWriteStore;
4646
import org.apache.parquet.column.values.bloomfilter.BloomFilterWriter;
4747
import org.apache.parquet.compression.CompressionCodecFactory.BytesInputCompressor;
48+
import org.apache.parquet.compression.DefaultCompressionCodecFactory.BytesCompressor;
4849
import org.apache.parquet.crypto.AesCipher;
4950
import org.apache.parquet.crypto.InternalColumnEncryptionSetup;
5051
import org.apache.parquet.crypto.InternalFileEncryptor;
5152
import org.apache.parquet.crypto.ModuleCipherFactory.ModuleType;
5253
import org.apache.parquet.format.BlockCipher;
5354
import org.apache.parquet.format.converter.ParquetMetadataConverter;
54-
import org.apache.parquet.compression.DefaultCompressionCodecFactory.BytesCompressor;
5555
import org.apache.parquet.hadoop.metadata.ColumnPath;
5656
import org.apache.parquet.internal.column.columnindex.ColumnIndexBuilder;
5757
import org.apache.parquet.internal.column.columnindex.OffsetIndexBuilder;

parquet-hadoop/src/test/java/org/apache/parquet/hadoop/TestDirectCodecFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ public void gzipLevelConfigThroughDirectPath() throws IOException {
501501
public void brotliDirectFactoryRoundTrip() throws IOException {
502502
// Test through the DirectCodecFactory path where BROTLI bypass lives
503503
try (TrackingByteBufferAllocator alloc = TrackingByteBufferAllocator.wrap(new DirectByteBufferAllocator())) {
504-
DefaultCompressionCodecFactory directFactory = CodecFactory.createDirectCodecFactory(new Configuration(), alloc, pageSize);
504+
DefaultCompressionCodecFactory directFactory =
505+
CodecFactory.createDirectCodecFactory(new Configuration(), alloc, pageSize);
505506
BytesInputCompressor compressor = directFactory.getCompressor(BROTLI);
506507
BytesInputDecompressor decompressor = directFactory.getDecompressor(BROTLI);
507508

@@ -544,7 +545,8 @@ public void crossFactoryInteropAllDirectCodecs() throws IOException {
544545

545546
CodecFactory heapFactory = new CodecFactory(new Configuration(), pageSize);
546547
try (TrackingByteBufferAllocator alloc = TrackingByteBufferAllocator.wrap(new DirectByteBufferAllocator())) {
547-
DefaultCompressionCodecFactory directFactory = CodecFactory.createDirectCodecFactory(new Configuration(), alloc, pageSize);
548+
DefaultCompressionCodecFactory directFactory =
549+
CodecFactory.createDirectCodecFactory(new Configuration(), alloc, pageSize);
548550

549551
for (CompressionCodecName codec : codecs) {
550552
// heap compress -> direct decompress

0 commit comments

Comments
 (0)