12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package com.sdyc.ndmp.protobuf.serializer;
- import org.xerial.snappy.Snappy;
- import java.io.IOException;
- /**
- * <pre>
- * Created with IntelliJ IDEA.
- * User: lwj
- * Date: 2015/2/27
- * Time: 10:48
- * To change this template use File | Settings | File Templates.
- * </pre>
- *
- * @author lwj
- */
- public class SnappySerializer extends CompressSerializer {
- public SnappySerializer() {
- }
- @Override
- public byte[] compress(byte[] bytes) {
- try {
- return Snappy.compress(bytes);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- @Override
- public byte[] uncompress(byte[] bytes) {
- try {
- return Snappy.uncompress(bytes);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
- }
|