-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ORC/Parquet tests are using hadoop code to verify compatibility Iceberg puffin format uses Zstd compressor/decompressor but cannot be upgraded to aircompressor as it requires JDK 22
- Loading branch information
Showing
35 changed files
with
1,112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
plugin/trino-iceberg/src/main/java/io/airlift/compress/Compressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.airlift.compress; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
public interface Compressor | ||
{ | ||
int maxCompressedLength(int uncompressedSize); | ||
|
||
/** | ||
* @return number of bytes written to the output | ||
*/ | ||
int compress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength); | ||
|
||
void compress(ByteBuffer input, ByteBuffer output); | ||
} |
28 changes: 28 additions & 0 deletions
28
plugin/trino-iceberg/src/main/java/io/airlift/compress/Decompressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.airlift.compress; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
public interface Decompressor | ||
{ | ||
/** | ||
* @return number of bytes written to the output | ||
*/ | ||
int decompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) | ||
throws MalformedInputException; | ||
|
||
void decompress(ByteBuffer input, ByteBuffer output) | ||
throws MalformedInputException; | ||
} |
36 changes: 36 additions & 0 deletions
36
plugin/trino-iceberg/src/main/java/io/airlift/compress/MalformedInputException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.airlift.compress; | ||
|
||
public class MalformedInputException | ||
extends RuntimeException | ||
{ | ||
private final long offset; | ||
|
||
public MalformedInputException(long offset) | ||
{ | ||
this(offset, "Malformed input"); | ||
} | ||
|
||
public MalformedInputException(long offset, String reason) | ||
{ | ||
super(reason + ": offset=" + offset); | ||
this.offset = offset; | ||
} | ||
|
||
public long getOffset() | ||
{ | ||
return offset; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
plugin/trino-iceberg/src/main/java/io/airlift/compress/zstd/ZstdCompressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.airlift.compress.zstd; | ||
|
||
import io.airlift.compress.Compressor; | ||
|
||
import java.lang.foreign.MemorySegment; | ||
import java.nio.ByteBuffer; | ||
|
||
import static java.lang.Math.toIntExact; | ||
|
||
public class ZstdCompressor | ||
implements Compressor | ||
{ | ||
private final io.airlift.compress.v2.zstd.ZstdCompressor compressor; | ||
|
||
public ZstdCompressor() | ||
{ | ||
this.compressor = io.airlift.compress.v2.zstd.ZstdCompressor.create(); | ||
} | ||
|
||
@Override | ||
public int maxCompressedLength(int uncompressedSize) | ||
{ | ||
return compressor.maxCompressedLength(uncompressedSize); | ||
} | ||
|
||
@Override | ||
public int compress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) | ||
{ | ||
MemorySegment inputSegment = MemorySegment.ofArray(input).asSlice(inputOffset, inputLength); | ||
MemorySegment outputSegment = MemorySegment.ofArray(output).asSlice(outputOffset, maxOutputLength); | ||
|
||
return toIntExact(compressor.compress(inputSegment, outputSegment)); | ||
} | ||
|
||
@Override | ||
public void compress(ByteBuffer input, ByteBuffer output) | ||
{ | ||
MemorySegment inputSegment = MemorySegment.ofBuffer(input); | ||
MemorySegment outputSegment = MemorySegment.ofBuffer(output); | ||
|
||
int written = compressor.compress(inputSegment, outputSegment); | ||
output.position(output.position() + written); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
plugin/trino-iceberg/src/main/java/io/airlift/compress/zstd/ZstdDecompressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.airlift.compress.zstd; | ||
|
||
import io.airlift.compress.Decompressor; | ||
import io.airlift.compress.MalformedInputException; | ||
|
||
import java.lang.foreign.MemorySegment; | ||
import java.nio.ByteBuffer; | ||
|
||
import static java.lang.Math.toIntExact; | ||
|
||
public class ZstdDecompressor | ||
implements Decompressor | ||
{ | ||
private final io.airlift.compress.v2.zstd.ZstdDecompressor decompressor; | ||
|
||
public ZstdDecompressor() | ||
{ | ||
this.decompressor = io.airlift.compress.v2.zstd.ZstdDecompressor.create(); | ||
} | ||
|
||
@Override | ||
public int decompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) | ||
throws MalformedInputException | ||
{ | ||
MemorySegment inputSegment = MemorySegment.ofArray(input).asSlice(inputOffset, inputLength); | ||
MemorySegment outputSegment = MemorySegment.ofArray(output).asSlice(outputOffset, maxOutputLength); | ||
|
||
return toIntExact(decompressor.decompress(inputSegment, outputSegment)); | ||
} | ||
|
||
@Override | ||
public void decompress(ByteBuffer input, ByteBuffer output) | ||
throws MalformedInputException | ||
{ | ||
MemorySegment inputSegment = MemorySegment.ofBuffer(input); | ||
MemorySegment outputSegment = MemorySegment.ofBuffer(output); | ||
|
||
int written = decompressor.decompress(inputSegment, outputSegment); | ||
output.position(output.position() + written); | ||
} | ||
|
||
public static long getDecompressedSize(byte[] input, int offset, int length) | ||
{ | ||
return io.airlift.compress.v2.zstd.ZstdDecompressor.create().getDecompressedSize(input, offset, length); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.trino</groupId> | ||
<artifactId>trino-root</artifactId> | ||
<version>454-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>trino-aircompressor-bridge</artifactId> | ||
<description>Trino - Aircompressor v1 to v2 bridge</description> | ||
|
||
<properties> | ||
<air.compiler.fail-warnings>true</air.compiler.fail-warnings> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>aircompressor</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.trino.hadoop</groupId> | ||
<artifactId>hadoop-apache</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>junit-extensions</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
28 changes: 28 additions & 0 deletions
28
testing/trino-aircompressor-bridge/src/main/java/io/airlift/compress/Compressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.airlift.compress; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
public interface Compressor | ||
{ | ||
int maxCompressedLength(int uncompressedSize); | ||
|
||
/** | ||
* @return number of bytes written to the output | ||
*/ | ||
int compress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength); | ||
|
||
void compress(ByteBuffer input, ByteBuffer output); | ||
} |
28 changes: 28 additions & 0 deletions
28
testing/trino-aircompressor-bridge/src/main/java/io/airlift/compress/Decompressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.airlift.compress; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
public interface Decompressor | ||
{ | ||
/** | ||
* @return number of bytes written to the output | ||
*/ | ||
int decompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) | ||
throws MalformedInputException; | ||
|
||
void decompress(ByteBuffer input, ByteBuffer output) | ||
throws MalformedInputException; | ||
} |
Oops, something went wrong.