/** * 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); }
/** * 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"); System.arraycopy(testdata, 500*i, twoDtest[i], 0, 500); byte[] twoDcompressed = compress(twoDtest, null); LOGGER.info("Comparing compressed data..."); if (twoDcompressed.length != compressed.length) {
r.nextBytes(testdata); LOGGER.info("Compressing data"); byte[] compressed = compress(testdata, null); LOGGER.info("Compressed size: {}", compressed.length); LOGGER.info("Decompressing data"); System.arraycopy(testdata, 500*i, twoDtest[i], 0, 500); byte[] twoDcompressed = compress(twoDtest, null); LOGGER.info("Comparing compressed data..."); if (twoDcompressed.length != compressed.length) {