use of org.apache.hadoop.hbase.codec.Codec in project hbase by apache.
the class CellBlockBuilder method encodeCellsTo.
private void encodeCellsTo(OutputStream os, CellScanner cellScanner, Codec codec, CompressionCodec compressor) throws IOException {
Compressor poolCompressor = null;
try {
if (compressor != null) {
if (compressor instanceof Configurable) {
((Configurable) compressor).setConf(this.conf);
}
poolCompressor = CodecPool.getCompressor(compressor);
os = compressor.createOutputStream(os, poolCompressor);
}
Codec.Encoder encoder = codec.getEncoder(os);
while (cellScanner.advance()) {
encoder.write(cellScanner.current());
}
encoder.flush();
} catch (BufferOverflowException | IndexOutOfBoundsException e) {
throw new DoNotRetryIOException(e);
} finally {
os.close();
if (poolCompressor != null) {
CodecPool.returnCompressor(poolCompressor);
}
}
}
use of org.apache.hadoop.hbase.codec.Codec in project hbase by apache.
the class CodecPerformance method doCodec.
static void doCodec(final Codec codec, final Cell[] cells, final int cycles, final int count, final int initialBufferSize) throws IOException {
byte[] bytes = null;
Cell[] cellsDecoded = null;
for (int i = 0; i < cycles; i++) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(initialBufferSize);
Codec.Encoder encoder = codec.getEncoder(baos);
bytes = runEncoderTest(i, initialBufferSize, baos, encoder, cells);
}
for (int i = 0; i < cycles; i++) {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
Codec.Decoder decoder = codec.getDecoder(bais);
cellsDecoded = CodecPerformance.runDecoderTest(i, count, decoder);
}
verifyCells(cells, cellsDecoded);
}
use of org.apache.hadoop.hbase.codec.Codec in project phoenix by apache.
the class ReadWriteKeyValuesWithCodecIT method writeWALEdit.
private void writeWALEdit(WALCellCodec codec, List<Cell> kvs, FSDataOutputStream out) throws IOException {
out.writeInt(kvs.size());
Codec.Encoder cellEncoder = codec.getEncoder(out);
// We interleave the two lists for code simplicity
for (Cell kv : kvs) {
cellEncoder.write(kv);
}
}
Aggregations