Skip to content

Commit c009aab

Browse files
committed
PHOENIX-7482 Replace uses of org.iq80.snappy:snappy with org.xerial.snappy:snappy-java
1 parent 095617f commit c009aab

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

phoenix-core-client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@
359359
<artifactId>jsr305</artifactId>
360360
</dependency>
361361
<dependency>
362-
<groupId>org.iq80.snappy</groupId>
363-
<artifactId>snappy</artifactId>
362+
<groupId>org.xerial.snappy</groupId>
363+
<artifactId>snappy-java</artifactId>
364364
</dependency>
365365
<dependency>
366366
<groupId>com.fasterxml.jackson.core</groupId>

phoenix-core-client/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountClientAggregator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
3434
import org.apache.phoenix.schema.types.PDataType;
3535
import org.apache.phoenix.schema.types.PVarbinary;
36+
import org.xerial.snappy.Snappy;
3637
import org.apache.phoenix.schema.SortOrder;
3738
import org.apache.phoenix.schema.tuple.SingleKeyValueTuple;
3839
import org.apache.phoenix.schema.tuple.Tuple;
39-
import org.iq80.snappy.Snappy;
4040

4141
/**
4242
* Client side Aggregator which will aggregate data and find distinct values with number of occurrences for each.
@@ -66,7 +66,7 @@ public void aggregate(Tuple tuple, ImmutableBytesWritable ptr) {
6666
if (Bytes.equals(ptr.get(), ptr.getOffset(), 1, DistinctValueWithCountServerAggregator.COMPRESS_MARKER,
6767
0, 1)) {
6868
// This reads the uncompressed length from the front of the compressed input
69-
int uncompressedLength = Snappy.getUncompressedLength(ptr.get(), ptr.getOffset() + 1);
69+
int uncompressedLength = Snappy.uncompressedLength(ptr.get(), ptr.getOffset() + 1, ptr.getLength() - 1);
7070
byte[] uncompressed = new byte[uncompressedLength];
7171
// This will throw CorruptionException, a RuntimeException if the snappy data is invalid.
7272
// We're making a RuntimeException out of a checked IOException below so assume it's ok

phoenix-core-client/src/main/java/org/apache/phoenix/expression/aggregator/DistinctValueWithCountServerAggregator.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.apache.phoenix.expression.aggregator;
1919

20+
import java.io.IOException;
2021
import java.util.HashMap;
2122
import java.util.Map;
2223
import java.util.Map.Entry;
@@ -33,7 +34,7 @@
3334
import org.apache.phoenix.schema.types.PVarbinary;
3435
import org.apache.phoenix.util.ByteUtil;
3536
import org.apache.phoenix.util.SizedUtil;
36-
import org.iq80.snappy.Snappy;
37+
import org.xerial.snappy.Snappy;
3738

3839
/**
3940
* Server side Aggregator which will aggregate data and find distinct values with number of occurrences for each.
@@ -108,8 +109,12 @@ public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
108109
// The size for the map serialization is above the threshold. We will do the Snappy compression here.
109110
byte[] compressed = new byte[COMPRESS_MARKER.length + Snappy.maxCompressedLength(buffer.length)];
110111
System.arraycopy(COMPRESS_MARKER, 0, compressed, 0, COMPRESS_MARKER.length);
111-
int compressedLen = Snappy.compress(buffer, 1, buffer.length - 1, compressed, COMPRESS_MARKER.length);
112-
ptr.set(compressed, 0, compressedLen + 1);
112+
try {
113+
int compressedLen = Snappy.compress(buffer, 1, buffer.length - 1, compressed, COMPRESS_MARKER.length);
114+
ptr.set(compressed, 0, compressedLen + 1);
115+
} catch (IOException e) {
116+
throw new RuntimeException(e);
117+
}
113118
return true;
114119
}
115120
ptr.set(buffer, 0, offset);

phoenix-core-client/src/main/java/org/apache/phoenix/join/HashCacheClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
import org.apache.phoenix.util.ClientUtil;
4545
import org.apache.phoenix.util.TrustedByteArrayOutputStream;
4646
import org.apache.phoenix.util.TupleUtil;
47-
import org.iq80.snappy.Snappy;
48-
47+
import org.xerial.snappy.Snappy;
4948
import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
5049

5150
/**

phoenix-core-client/src/main/java/org/apache/phoenix/join/HashCacheFactory.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@
5151
import org.apache.phoenix.util.ResultUtil;
5252
import org.apache.phoenix.util.SizedUtil;
5353
import org.apache.phoenix.util.TupleUtil;
54-
import org.iq80.snappy.CorruptionException;
55-
import org.iq80.snappy.Snappy;
54+
import org.xerial.snappy.Snappy;
5655

5756
public class HashCacheFactory implements ServerCacheFactory {
5857

@@ -71,12 +70,11 @@ public void write(DataOutput output) throws IOException {
7170
public Closeable newCache(ImmutableBytesWritable cachePtr, byte[] txState, MemoryChunk chunk, boolean useProtoForIndexMaintainer, int clientVersion) throws SQLException {
7271
try {
7372
// This reads the uncompressed length from the front of the compressed input
74-
int uncompressedLen = Snappy.getUncompressedLength(cachePtr.get(), cachePtr.getOffset());
73+
int uncompressedLen = Snappy.uncompressedLength(cachePtr.get(), cachePtr.getOffset(), cachePtr.getLength());
7574
byte[] uncompressed = new byte[uncompressedLen];
76-
Snappy.uncompress(cachePtr.get(), cachePtr.getOffset(), cachePtr.getLength(),
77-
uncompressed, 0);
75+
Snappy.uncompress(cachePtr.get(), cachePtr.getOffset(), cachePtr.getLength(), uncompressed, 0);
7876
return new HashCacheImpl(uncompressed, chunk, clientVersion);
79-
} catch (CorruptionException e) {
77+
} catch (IOException e) {
8078
throw ClientUtil.parseServerException(e);
8179
}
8280
}

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<sqlline.version>1.9.0</sqlline.version>
121121
<jcip-annotations.version>1.0-1</jcip-annotations.version>
122122
<jsr305.version>2.0.1</jsr305.version>
123-
<snappy.version>0.5</snappy.version>
123+
<snappy.version>1.1.10.5</snappy.version>
124124
<commons-codec.version>1.16.0</commons-codec.version>
125125
<htrace.version>3.1.0-incubating</htrace.version>
126126
<jodatime.version>2.10.5</jodatime.version>
@@ -1651,8 +1651,8 @@
16511651
<version>${jsr305.version}</version>
16521652
</dependency>
16531653
<dependency>
1654-
<groupId>org.iq80.snappy</groupId>
1655-
<artifactId>snappy</artifactId>
1654+
<groupId>org.xerial.snappy</groupId>
1655+
<artifactId>snappy-java</artifactId>
16561656
<version>${snappy.version}</version>
16571657
</dependency>
16581658
<dependency>

0 commit comments

Comments
 (0)