Skip to content
Closed
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
2 changes: 1 addition & 1 deletion java/core/src/java/org/apache/orc/CompressionKind.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
* can be applied to ORC files.
*/
public enum CompressionKind {
NONE, ZLIB, SNAPPY, LZO, LZ4
NONE, ZLIB, SNAPPY, LZO, LZ4, ZSTD
}
1 change: 1 addition & 0 deletions java/core/src/java/org/apache/orc/impl/ReaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ private static OrcProto.PostScript extractPostScript(ByteBuffer bb, Path path,
case SNAPPY:
case LZO:
case LZ4:
case ZSTD:
break;
default:
throw new IllegalArgumentException("Unknown compression");
Expand Down
6 changes: 6 additions & 0 deletions java/core/src/java/org/apache/orc/impl/WriterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import io.airlift.compress.lz4.Lz4Decompressor;
import io.airlift.compress.lzo.LzoCompressor;
import io.airlift.compress.lzo.LzoDecompressor;
import io.airlift.compress.zstd.ZstdCompressor;
import io.airlift.compress.zstd.ZstdDecompressor;
import org.apache.orc.ColumnStatistics;
import org.apache.orc.CompressionCodec;
import org.apache.orc.CompressionKind;
Expand Down Expand Up @@ -275,6 +277,9 @@ public static CompressionCodec createCodec(CompressionKind kind) {
case LZ4:
return new AircompressorCodec(kind, new Lz4Compressor(),
new Lz4Decompressor());
case ZSTD:
return new AircompressorCodec(kind, new ZstdCompressor(),
new ZstdDecompressor());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a similar fix in WriterImpl (line 537).

default:
throw new IllegalArgumentException("Unknown compression codec: " +
kind);
Expand Down Expand Up @@ -532,6 +537,7 @@ private OrcProto.CompressionKind writeCompressionKind(CompressionKind kind) {
case SNAPPY: return OrcProto.CompressionKind.SNAPPY;
case LZO: return OrcProto.CompressionKind.LZO;
case LZ4: return OrcProto.CompressionKind.LZ4;
case ZSTD: return OrcProto.CompressionKind.ZSTD;
default:
throw new IllegalArgumentException("Unknown compression " + kind);
}
Expand Down
45 changes: 45 additions & 0 deletions java/core/src/test/org/apache/orc/impl/TestZstd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.orc.impl;

import io.airlift.compress.zstd.ZstdCompressor;
import io.airlift.compress.zstd.ZstdDecompressor;
import org.apache.orc.CompressionCodec;
import org.apache.orc.CompressionKind;
import org.junit.Test;

import java.nio.ByteBuffer;

import static org.junit.Assert.assertEquals;

public class TestZstd {

@Test
public void testNoOverflow() throws Exception {
ByteBuffer in = ByteBuffer.allocate(10);
ByteBuffer out = ByteBuffer.allocate(10);
in.put(new byte[]{1,2,3,4,5,6,7,10});
in.flip();
CompressionCodec codec = new AircompressorCodec(
CompressionKind.ZSTD, new ZstdCompressor(), new ZstdDecompressor());
assertEquals(false, codec.compress(in, out, null,
codec.getDefaultOptions()));
}

}
8 changes: 1 addition & 7 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,7 @@
<dependency>
<groupId>io.airlift</groupId>
<artifactId>aircompressor</artifactId>
<version>0.10</version>
<exclusions>
<exclusion>
<groupId>io.airlift</groupId>
<artifactId>slice</artifactId>
</exclusion>
</exclusions>
<version>0.15</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Expand Down