public static Codec get(MetaData meta) { String name = meta.getCodec(); if (name == null || "null".equals(name)) return new NullCodec(); else if ("deflate".equals(name)) return new DeflateCodec(); else if ("snappy".equals(name)) return new SnappyCodec(); else if ("bzip2".equals(name)) return new BZip2Codec(); else throw new TrevniRuntimeException("Unknown codec: "+name); }
@Override ByteBuffer compress(ByteBuffer data) throws IOException { ByteArrayOutputStream baos = getOutputBuffer(data.remaining()); writeAndClose(data, new DeflaterOutputStream(baos, getDeflater())); return ByteBuffer.wrap(baos.toByteArray()); }
@Override ByteBuffer decompress(ByteBuffer data) throws IOException { ByteArrayOutputStream baos = getOutputBuffer(data.remaining()); writeAndClose(data, new InflaterOutputStream(baos, getInflater())); return ByteBuffer.wrap(baos.toByteArray()); }
@Override ByteBuffer decompress(ByteBuffer data) throws IOException { ByteArrayOutputStream baos = getOutputBuffer(data.remaining()); writeAndClose(data, new InflaterOutputStream(baos, getInflater())); return ByteBuffer.wrap(baos.toByteArray()); }
@Override ByteBuffer compress(ByteBuffer data) throws IOException { ByteArrayOutputStream baos = getOutputBuffer(data.remaining()); writeAndClose(data, new DeflaterOutputStream(baos, getDeflater())); return ByteBuffer.wrap(baos.toByteArray()); }
public static Codec get(MetaData meta) { String name = meta.getCodec(); if (name == null || "null".equals(name)) return new NullCodec(); else if ("deflate".equals(name)) return new DeflateCodec(); else if ("snappy".equals(name)) return new SnappyCodec(); else throw new TrevniRuntimeException("Unknown codec: "+name); }