apurtell commented on a change in pull request #3244:
URL: https://github.com/apache/hbase/pull/3244#discussion_r630673256
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
##########
@@ -256,6 +267,61 @@ public void write(Cell cell) throws IOException {
}
}
}
+
+ private byte[] compressValue(Cell cell) throws IOException {
+ Deflater deflater = compression.getValueCompressor().getDeflater();
+ if (cell instanceof ByteBufferExtendedCell) {
+
deflater.setInput(((ByteBufferExtendedCell)cell).getValueByteBuffer().array(),
+ ((ByteBufferExtendedCell)cell).getValueByteBuffer().arrayOffset() +
+ ((ByteBufferExtendedCell)cell).getValuePosition(),
+ cell.getValueLength());
+ } else {
+ deflater.setInput(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength());
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ int bufferSize = 1024;
+ byte[] buffer = new byte[bufferSize];
+ // Deflater#deflate will return 0 only if more input is required. We
iterate until
+ // that condition is met, sending the content of 'buffer' to the output
stream at
+ // each step, until deflate returns 0. Then the compressor must be
flushed in order
+ // for all of the value's output to be written into the corresponding
edit. (Otherwise
+ // the compressor would carry over some of the output for this value
into the output
+ // of the next.) To flush the compressor we call deflate again using the
method option
+ // that allows us to specify the SYNC_FLUSH flag. The sync output will
be placed into
+ // the buffer. When flushing we iterate until there is no more output.
Then the flush
+ // is complete and the compressor is ready for more input.
+ int bytesOut;
Review comment:
@bharathv I can come back to try this again, but the first time around
code that would seem to work did not. Must have missed something, although it
was not obvious.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]