public byte[] deflate(byte[] data) throws IOException { return LZFEncoder.encode(data); }
private int _handleFiles(File dir) throws IOException { System.out.println("Testing files from dir '" + dir.getAbsolutePath() + "'..."); int count = 0; for(File f: dir.listFiles()) { if(f.isDirectory()) { count += _handleFiles(f); } else { byte[] data = _readData(f); byte[] enc = LZFEncoder.encode(data); byte[] dec = LZFDecoder.decode(enc); assertArrayEquals("File '" + f.getAbsolutePath() + "'", data, dec); ++count; } } return count; }
final String updatedBy = UUID.randomUUID().toString().substring(0, 4); final byte[] properties = LZFEncoder.encode(new byte[] { 'c', 'a', 'f', 'e' }); final String tableNameA = "test_database_export_dao_a"; final String tableNameB = "test_database_export_dao_b";
@Override public void closeForChange() { checkUpdateMode(); try { compressed = LZFEncoder.encode(uncompressed, 0, valueLen * size); } catch (Exception e) { throw new RuntimeException("LZF encode failure", e); } }
/** * Compression method that uses specified {@link ChunkEncoder} for actual * encoding. */ public static byte[] encode(ChunkEncoder enc, byte[] data, int length) { return encode(enc, data, 0, length); }
/** * Compression method that uses specified {@link ChunkEncoder} for actual * encoding. */ public static byte[] encode(ChunkEncoder enc, byte[] data, int length) { return encode(enc, data, 0, length); }
/** * Method for compressing given input data using LZF encoding and * block structure (compatible with lzf command line utility). * Result consists of a sequence of chunks. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static byte[] encode(byte[] data) { return encode(data, 0, data.length); }
/** * Method for compressing given input data using LZF encoding and * block structure (compatible with lzf command line utility). * Result consists of a sequence of chunks. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static byte[] encode(byte[] data) { return encode(data, 0, data.length); }
/** * Method for compressing given input data using LZF encoding and * block structure (compatible with lzf command line utility). * Result consists of a sequence of chunks. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static byte[] encode(byte[] data) { return encode(data, 0, data.length); }
@Test public void test() throws IOException { byte[] raw = new byte[] { 1, 2, 3, 3, 2, 23 }; byte[] data = LZFEncoder.encode(raw); byte[] data2 = new byte[data.length * 2]; java.lang.System.arraycopy(data, 0, data2, 0, data.length); ImmutableBytesWritable bytes = new ImmutableBytesWritable(); bytes.set(data2, 0, data.length); try { byte[] uncompressed = LZFDecoder.decode(bytes.get(), bytes.getOffset(), bytes.getLength()); } catch (IOException e) { throw new RuntimeException("LZF decode failure", e); } } }
@Override public byte[] withBytes(byte[] buffer, int offset, int length) { try { return LZFEncoder.encode(buffer, offset, length); } catch (Exception e) { throw new IllegalArgumentException(e); } } });
public byte[] compressString(String source, Charset charset) { byte[] strBytes = source.getBytes(charset); return LZFEncoder.encode(strBytes); }
public byte[] compressString(String source) { byte[] strBytes = source.getBytes(); return LZFEncoder.encode(strBytes); }
@Override public void closeForChange() { checkUpdateMode(); try { compressed = LZFEncoder.encode(uncompressed, 0, valueLen * size); } catch (Exception e) { throw new RuntimeException("LZF encode failure", e); } }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length, bufferRecycler); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length, bufferRecycler); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length, bufferRecycler); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }