- Common ways to obtain CompressLZF
private void myMethod () {}
/** * Compress the data in a byte array. * * @param page which page to compress */ void compressPage(int page) { final ByteBuffer d = buffers[page].get(); synchronized (d) { if (d.capacity() != BLOCK_SIZE) { // already compressed return; } final byte[] compressOutputBuffer = COMPRESS_OUT_BUF_THREAD_LOCAL.get(); int len = LZF_THREAD_LOCAL.get().compress(d, 0, compressOutputBuffer, 0); ByteBuffer out = ByteBuffer.allocateDirect(len); out.put(compressOutputBuffer, 0, len); buffers[page].compareAndSet(d, out); } }
/** * Compress the data in a byte array. * * @param page which page to compress */ void compress(int page) { byte[] old = getPage(page); if (old == null || old.length != BLOCK_SIZE) { // not yet initialized or already compressed return; } synchronized (LZF) { int len = LZF.compress(old, BLOCK_SIZE, BUFFER, 0); if (len <= BLOCK_SIZE) { byte[] d = Arrays.copyOf(BUFFER, len); // maybe data was changed in the meantime setPage(page, old, d, false); } } }
private void compressAndWrite(byte[] buff, int len) throws IOException { if (len > 0) { ensureOutput(len); int compressed = compress.compress(buff, len, outBuffer, 0); if (compressed > len) { writeInt(-len); out.write(buff, 0, len); } else { writeInt(compressed); writeInt(len); out.write(outBuffer, 0, compressed); } } }
int pageSize = store.getPageSize(); if (COMPRESS_UNDO) { int size = compress.compress(page.getBytes(), pageSize, compressBuffer, 0); if (size < pageSize) {
private static void compress(byte[][] data, int i) { byte[] d = data[i]; synchronized (LZF) { int len = LZF.compress(d, BLOCK_SIZE, BUFFER, 0); if (len <= BLOCK_SIZE) { d = new byte[len]; System.arraycopy(BUFFER, 0, d, 0, len); data[i] = d; } } }
/** * Compress the data in a byte array. * * @param data the page array * @param page which page to compress */ static void compress(byte[][] data, int page) { byte[] d = data[page]; synchronized (LZF) { int len = LZF.compress(d, BLOCK_SIZE, BUFFER, 0); if (len <= BLOCK_SIZE) { d = new byte[len]; System.arraycopy(BUFFER, 0, d, 0, len); data[page] = d; } } }
/** * Compress the data in a byte array. * * @param data the page array * @param page which page to compress */ static void compress(ByteBuffer[] data, int page) { ByteBuffer d = data[page]; synchronized (LZF) { int len = LZF.compress(d, 0, BUFFER, 0); d = ByteBuffer.allocateDirect(len); d.put(BUFFER, 0, len); data[page] = d; } }
/** * Compress the data in a byte array. * * @param page which page to compress */ void compress(int page) { ByteBuffer[] list = data; if (page >= list.length) { // was truncated return; } ByteBuffer d = list[page]; synchronized (LZF) { int len = LZF.compress(d, 0, BUFFER, 0); d = ByteBuffer.allocateDirect(len); d.put(BUFFER, 0, len); list[page] = d; } }
/** * Compress the data in a byte array. * * @param page which page to compress * @param old the page array */ void compress(int page, byte[] old) { byte[][] array = data; if (page >= array.length) { return; } byte[] d = array[page]; if (d != old) { return; } synchronized (LZF) { int len = LZF.compress(d, BLOCK_SIZE, BUFFER, 0); if (len <= BLOCK_SIZE) { d = new byte[len]; System.arraycopy(BUFFER, 0, d, 0, len); // maybe data was changed in the meantime byte[] o = array[page]; if (o != old) { return; } array[page] = d; } } }
private void compressAndWrite(byte[] buff, int len) throws IOException { if (len > 0) { ensureOutput(len); int compressed = compress.compress(buff, len, outBuffer, 0); if (compressed > len) { writeInt(-len); out.write(buff, 0, len); } else { writeInt(compressed); writeInt(len); out.write(outBuffer, 0, compressed); } } }
private void compressAndWrite(byte[] buff, int len) throws IOException { if (len > 0) { ensureOutput(len); int compressed = compress.compress(buff, len, outBuffer, 0); if (compressed > len) { writeInt(-len); out.write(buff, 0, len); } else { writeInt(compressed); writeInt(len); out.write(outBuffer, 0, compressed); } } }
private void compressAndWrite(byte[] buff, int len) throws IOException { if (len > 0) { ensureOutput(len); int compressed = compress.compress(buff, len, outBuffer, 0); if (compressed > len) { writeInt(-len); out.write(buff, 0, len); } else { writeInt(compressed); writeInt(len); out.write(outBuffer, 0, compressed); } } }
int pageSize = store.getPageSize(); if (COMPRESS_UNDO) { int size = compress.compress(page.getBytes(), pageSize, compressBuffer, 0); if (size < pageSize) {
int pageSize = store.getPageSize(); if (COMPRESS_UNDO) { int size = compress.compress(page.getBytes(), pageSize, compressBuffer, 0); if (size < pageSize) {