@Override public byte[] decompress(byte[][] data) throws FormatException { return decompress(data, null); }
r.nextBytes(testdata); LOGGER.info("Compressing data"); byte[] compressed = compress(testdata, null); LOGGER.info("Compressed size: {}", compressed.length); LOGGER.info("Decompressing data"); byte[] decompressed = decompress(compressed); LOGGER.info("Comparing data..."); if (testdata.length != decompressed.length) { System.arraycopy(testdata, 500*i, twoDtest[i], 0, 500); byte[] twoDcompressed = compress(twoDtest, null); LOGGER.info("Comparing compressed data..."); if (twoDcompressed.length != compressed.length) {
/** * 2D data block encoding default implementation. * This method simply concatenates data[0] + data[1] + ... + data[i] into * a 1D block of data, then calls the 1D version of compress. * * @param data The data to be compressed. * @param options Options to be used during compression, if appropriate. * @return The compressed data. * @throws FormatException If input is not a compressed data block of the * appropriate type. */ @Override public byte[] compress(byte[][] data, CodecOptions options) throws FormatException { int len = 0; for (int i = 0; i < data.length; i++) { len += data[i].length; } byte[] toCompress = new byte[len]; int curPos = 0; for (int i = 0; i < data.length; i++) { System.arraycopy(data[i], 0, toCompress, curPos, data[i].length); curPos += data[i].length; } return compress(toCompress, options); }
r.nextBytes(testdata); LOGGER.info("Compressing data"); byte[] compressed = compress(testdata, null); LOGGER.info("Compressed size: {}", compressed.length); LOGGER.info("Decompressing data"); byte[] decompressed = decompress(compressed); LOGGER.info("Comparing data..."); if (testdata.length != decompressed.length) { System.arraycopy(testdata, 500*i, twoDtest[i], 0, 500); byte[] twoDcompressed = compress(twoDtest, null); LOGGER.info("Comparing compressed data..."); if (twoDcompressed.length != compressed.length) {
/** * 2D data block encoding default implementation. * This method simply concatenates data[0] + data[1] + ... + data[i] into * a 1D block of data, then calls the 1D version of compress. * * @param data The data to be compressed. * @param options Options to be used during compression, if appropriate. * @return The compressed data. * @throws FormatException If input is not a compressed data block of the * appropriate type. */ @Override public byte[] compress(byte[][] data, CodecOptions options) throws FormatException { int len = 0; for (int i = 0; i < data.length; i++) { len += data[i].length; } byte[] toCompress = new byte[len]; int curPos = 0; for (int i = 0; i < data.length; i++) { System.arraycopy(data[i], 0, toCompress, curPos, data[i].length); curPos += data[i].length; } return compress(toCompress, options); }
@Override public byte[] decompress(byte[] data) throws FormatException { return decompress(data, null); }
@Override public byte[] decompress(byte[] data) throws FormatException { return decompress(data, null); }
@Override public byte[] decompress(byte[][] data) throws FormatException { return decompress(data, null); }
/** * 2D data block decoding default implementation. * This method simply concatenates data[0] + data[1] + ... + data[i] into * a 1D block of data, then calls the 1D version of decompress. * * @param data The data to be decompressed. * @return The decompressed data. * @throws FormatException If input is not a compressed data block of the * appropriate type. */ @Override public byte[] decompress(byte[][] data, CodecOptions options) throws FormatException { if (data == null) throw new IllegalArgumentException("No data to decompress."); int len = 0; for (int i = 0; i < data.length; i++) { len += data[i].length; } byte[] toDecompress = new byte[len]; int curPos = 0; for (int i = 0; i < data.length; i++) { System.arraycopy(data[i], 0, toDecompress, curPos, data[i].length); curPos += data[i].length; } return decompress(toDecompress, options); }
/** * 2D data block decoding default implementation. * This method simply concatenates data[0] + data[1] + ... + data[i] into * a 1D block of data, then calls the 1D version of decompress. * * @param data The data to be decompressed. * @return The decompressed data. * @throws FormatException If input is not a compressed data block of the * appropriate type. */ @Override public byte[] decompress(byte[][] data, CodecOptions options) throws FormatException { if (data == null) throw new IllegalArgumentException("No data to decompress."); int len = 0; for (int i = 0; i < data.length; i++) { len += data[i].length; } byte[] toDecompress = new byte[len]; int curPos = 0; for (int i = 0; i < data.length; i++) { System.arraycopy(data[i], 0, toDecompress, curPos, data[i].length); curPos += data[i].length; } return decompress(toDecompress, options); }
@Override public byte[] decompress(byte[] data, CodecOptions options) throws FormatException { try (RandomAccessInputStream r = new RandomAccessInputStream(data)) { return decompress(r, options); } catch (IOException e) { throw new FormatException(e); } }
@Override public byte[] decompress(byte[] data, CodecOptions options) throws FormatException { try (RandomAccessInputStream r = new RandomAccessInputStream(data)) { return decompress(r, options); } catch (IOException e) { throw new FormatException(e); } }