Skip to content

Commit

Permalink
Delete snappy compression as it doesn't work symmetrically for stream…
Browse files Browse the repository at this point in the history
… and bytes
  • Loading branch information
dpisklov committed Feb 11, 2019
1 parent e965701 commit e146024
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 144 deletions.
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@

<!-- test dependencies -->

<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/openhft/chronicle/wire/BinaryWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ private void copySpecial(@NotNull WireOut wire, int peekCode) {
long readPosition = bytes.readPosition();
bytes.uncheckedReadSkipOne();
@Nullable StringBuilder sb = readUtf8();
if (StringUtils.isEqual("snappy", sb) || StringUtils.isEqual("gzip", sb) || StringUtils.isEqual("lzw", sb)) {
if (StringUtils.isEqual("gzip", sb) || StringUtils.isEqual("lzw", sb)) {
bytes.readPosition(readPosition);
wire.writeComment(sb);
wire.getValueOut().text(valueIn.text());
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/net/openhft/chronicle/wire/TextWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import net.openhft.chronicle.core.values.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.xerial.snappy.Snappy;

import java.io.Externalizable;
import java.io.IOException;
Expand Down Expand Up @@ -2165,16 +2164,6 @@ <ACS extends Appendable & CharSequence> CharSequence textTo0(@NotNull ACS a) {
if (StringUtils.isEqual(sb, "!null")) {
textTo(sb);
ret = null;
} else if (StringUtils.isEqual(sb, "snappy")) {
textTo(sb);
try {
//todo needs to be made efficient
byte[] decodedBytes = Base64.getDecoder().decode(sb.toString().getBytes(ISO_8859_1));
String csq = Snappy.uncompressString(decodedBytes);
ret = acquireStringBuilder().append(csq);
} catch (IOException e) {
throw new AssertionError(e);
}
} else {
// ignore the type.
if (a instanceof StringBuilder) {
Expand Down
32 changes: 0 additions & 32 deletions src/test/java/net/openhft/chronicle/wire/BinaryWire2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@
import org.jetbrains.annotations.Nullable;
import org.junit.After;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import java.io.IOException;
import java.lang.reflect.Field;
import java.time.*;
import java.util.*;
import java.util.function.Consumer;

import static net.openhft.chronicle.bytes.Bytes.elasticByteBuffer;
import static net.openhft.chronicle.bytes.NativeBytes.nativeBytes;
import static org.junit.Assert.*;

Expand Down Expand Up @@ -478,35 +475,6 @@ public void readDemarshallable() {
}
}

@Test
@Ignore("Snappy decompression doesn't work for some reason")
public void testSnappyCompressWithSnappy() {
if (!Compressions.Snappy.available())
return;

@NotNull Wire wire = createWire();
@NotNull String str = "xxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxx" +
"xxxxxxxxxxxxxxxx";

wire.write().compress("snappy", Bytes.from(str));

wire.bytes().readPosition(0);
Bytes b = elasticByteBuffer();
wire.read().bytes(b);
assertEquals(str, b.toString());

wire.bytes().readPosition(0);
Bytes asText = Bytes.elasticByteBuffer();
wire.copyTo(new TextWire(asText));
assertEquals("message: " + str + "\n", asText.toString());

wire.bytes().release();
asText.release();
}

@Test
public void testSnappyCompressWithGzip() {
if (!Compressions.Snappy.available())
Expand Down
58 changes: 0 additions & 58 deletions src/test/java/net/openhft/chronicle/wire/SnappyComparisonMain.java

This file was deleted.

36 changes: 0 additions & 36 deletions src/test/java/net/openhft/chronicle/wire/TextWireTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1206,42 +1206,6 @@ public void testArrays2() {
assertArrayEquals(a3, (Object[]) o3);
}

@Test
@Ignore
public void testSnappyCompression() {
if (!Compressions.Snappy.available())
return;
@NotNull Wire wire = createWire();
@NotNull final String s = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
@NotNull String str = s + s + s + s;

wire.write().compress("snappy", Bytes.wrapForRead(str.getBytes(ISO_8859_1)));

@NotNull Bytes ret = Bytes.allocateElasticDirect();
wire.read().bytes(ret);
@NotNull byte[] returnBytes = new byte[(int) ret.readRemaining()];
ret.read(returnBytes);
assertArrayEquals(str.getBytes(ISO_8859_1), returnBytes);
}

@Test
@Ignore
public void testSnappyCompressionAsText() {
if (!Compressions.Snappy.available())
return;

@NotNull Wire wire = createWire();
@NotNull final String s = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
@NotNull String str = s + s + s + s;

@NotNull byte[] bytes0 = str.getBytes(ISO_8859_1);
wire.write().compress("snappy", Bytes.wrapForRead(bytes0));

@NotNull Bytes bytes = allocateElasticDirect();
wire.read().bytes(bytes);
assertEquals(str, bytes.toString());
}

@Test
public void testGZIPCompressionAsText() {
@NotNull Wire wire = createWire();
Expand Down

0 comments on commit e146024

Please sign in to comment.