package kr.pe.kwonnam.spymemcached.extratranscoders.snappy;

import kr.pe.kwonnam.spymemcached.extratranscoders.compresswrapper.AbstractCompressionWrapperTranscoder;
import kr.pe.kwonnam.spymemcached.extratranscoders.compresswrapper.Compressor;
import kr.pe.kwonnam.spymemcached.extratranscoders.compresswrapper.Decompressor;
import org.xerial.snappy.Snappy;

import java.io.IOException;

/**
 * <a href="https://github.com/xerial/snappy-java">snappy-java</a> based compression wrapper spymemcached transcoder.
 */
public class SnappyCompressWrapperTranscoder<T> extends AbstractCompressionWrapperTranscoder<T> implements Compressor, Decompressor {

    @Override
    public byte[] compress(byte[] bytes) {
        try {
            return Snappy.compress(bytes);
        } catch (IOException e) {
            throw new IllegalStateException("Failed to compress with snappy.", e);
        }
    }

    @Override
    public byte[] decompress(byte[] bytes) {
        try {
            return Snappy.uncompress(bytes);
        } catch (IOException e) {
            throw new IllegalStateException("Failed to decompress with snappy.", e);
        }
    }
}

@@ -315,24 +315,73 @@
 compressor;%0A
+import net.spy.memcached.transcoders.Transcoder;%0A
 import org.x
@@ -692,16 +692,210 @@
 ssor %7B%0A%0A
+    public SnappyCompressWrapperTranscoder(Transcoder%3CT%3E wrappedTranscoder) %7B%0A        setWrappedTranscoder(wrappedTranscoder);%0A        setCompressor(this);%0A        setDecompressor(this);%0A    %7D%0A%0A
     @Ove

add constructor to SnappyCompressWrapperTranscoder