You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to Snappy-Java and wrote a basic test for examining the compression ratio for arrays of int, float and double. I'm finding for small arrays of ~10 elements the compressed bytes are greater than the original arrays. For larger arrays of ~100 elements, int[] compression is around 50% but for float[]/double[] the compressed size is greater than the original size, which surely defeats the purpose of running a compressor.
Maybe I'm doing something wrong, but my test code is pasted below. The results of the test functions is below.
Results:
`Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.
public class SnappyTest {
/**
* Website example.
*/ @test
public void test_website_example() {
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.";
try {
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
Hi
I'm new to Snappy-Java and wrote a basic test for examining the compression ratio for arrays of int, float and double. I'm finding for small arrays of ~10 elements the compressed bytes are greater than the original arrays. For larger arrays of ~100 elements, int[] compression is around 50% but for float[]/double[] the compressed size is greater than the original size, which surely defeats the purpose of running a compressor.
Maybe I'm doing something wrong, but my test code is pasted below. The results of the test functions is below.
Results:
`Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.
compressed length: 87, uncompressed length: 96
compressed int[] bytes: 42, uncompressed bytes: 40
compressed float[] bytes: 42, uncompressed bytes: 40
compressed double[] bytes: 74, uncompressed bytes: 80
compressed int[] bytes: 2208, uncompressed bytes: 4096
compressed float[] bytes: 4101, uncompressed bytes: 4096
compressed double[] bytes: 8197, uncompressed bytes: 8192`
Code:
`package utils.tocompress;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import org.junit.jupiter.api.Test;
import org.xerial.snappy.Snappy;
public class SnappyTest {
/**
* Website example.
*/
@test
public void test_website_example() {
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.";
try {
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
} // class SnappyTest
`
The text was updated successfully, but these errors were encountered: