private void flipByte() { if(bitsLeft == 0) { bb.put(b); if(!bb.hasRemaining()) { expandAllocation(); } b = bb.get(bb.position()); bitsLeft = Byte.SIZE; } }
@Override public void writeBit() { b |= (1 << (bitsLeft - 1)); bitsLeft--; flipByte(); }
public DataPointCompressTransformer(MetricType<T> metricType, long timeslice) { out = new ByteBufferBitOutput(); this.metricType = metricType; // Write the appropriate header, at first we're stuck to Gorilla only byte gorillaHeader = CompressorHeader.getHeader(CompressorHeader.Compressor.GORILLA, EnumSet.noneOf (CompressorHeader.GorillaSettings.class)); out.getByteBuffer().put(gorillaHeader); this.sliceTimestamp = timeslice; this.compressor = new Compressor(timeslice, out); this.tagsSerializer = new TagsSerializer(timeslice); }
@OperationsPerInvocation(100000) public void encodingBenchmark(DataGenerator dg) { ByteBufferBitOutput output = new ByteBufferBitOutput(); Compressor c = new Compressor(dg.blockStart, output); for(int j = 0; j < dg.amountOfPoints; j++) { c.addValue(dg.uncompressedBuffer.getLong(), dg.uncompressedBuffer.getDouble()); } c.close(); dg.uncompressedBuffer.rewind(); }
.doOnNext(cpc -> { compressor.close(); ByteBuffer valueBuffer = (ByteBuffer) out.getByteBuffer().flip(); ByteBuffer tagsBuffer = (ByteBuffer) tagsSerializer.getByteBuffer().flip(); cpc.setValueBuffer(valueBuffer);
public DataPointCompressTransformer(MetricType<T> metricType, long timeslice) { out = new ByteBufferBitOutput(); this.metricType = metricType; // Write the appropriate header, at first we're stuck to Gorilla only byte gorillaHeader = CompressorHeader.getHeader(CompressorHeader.Compressor.GORILLA, EnumSet.noneOf (CompressorHeader.GorillaSettings.class)); out.getByteBuffer().put(gorillaHeader); this.sliceTimestamp = timeslice; this.compressor = new Compressor(timeslice, out); this.tagsSerializer = new TagsSerializer(timeslice); }
@OperationsPerInvocation(100000) public void encodingBenchmark(DataGenerator dg) { ByteBufferBitOutput output = new ByteBufferBitOutput(); Compressor c = new Compressor(dg.blockStart, output); for(int j = 0; j < dg.amountOfPoints; j++) { c.addValue(dg.uncompressedBuffer.getLong(), dg.uncompressedBuffer.getDouble()); } c.close(); dg.uncompressedBuffer.rewind(); }
.doOnNext(cpc -> { compressor.close(); ByteBuffer valueBuffer = (ByteBuffer) out.getByteBuffer().flip(); ByteBuffer tagsBuffer = (ByteBuffer) tagsSerializer.getByteBuffer().flip(); cpc.setValueBuffer(valueBuffer);
uncompressedBuffer.flip(); ByteBufferBitOutput output = new ByteBufferBitOutput(); LongArrayOutput arrayOutput = new LongArrayOutput(amountOfPoints); c.close(); ByteBuffer byteBuffer = output.getByteBuffer(); byteBuffer.flip(); compressedBuffer = byteBuffer;
@Override public void skipBit() { bitsLeft--; flipByte(); }
private void flipByte() { if(bitsLeft == 0) { bb.put(b); if(!bb.hasRemaining()) { expandAllocation(); } b = bb.get(bb.position()); bitsLeft = Byte.SIZE; } }
uncompressedBuffer.flip(); ByteBufferBitOutput output = new ByteBufferBitOutput(); LongArrayOutput arrayOutput = new LongArrayOutput(amountOfPoints); c.close(); ByteBuffer byteBuffer = output.getByteBuffer(); byteBuffer.flip(); compressedBuffer = byteBuffer;
/** * Causes the currently handled byte to be written to the stream */ @Override public void flush() { bitsLeft = 0; flipByte(); // Causes write to the ByteBuffer }
@Override public Observable<CompressedPointContainer> call(Observable<Row> dataRow) { ByteBufferBitOutput out = new ByteBufferBitOutput(); out.getByteBuffer().put(gorillaHeader); compressor.close(); ByteBuffer valueBuffer = (ByteBuffer) out.getByteBuffer().flip(); ByteBuffer tagsBuffer = (ByteBuffer) tagsSerializer.getByteBuffer().flip(); cpc.setValueBuffer(valueBuffer);
@Override public void skipBit() { bitsLeft--; flipByte(); }
@Override public Observable<CompressedPointContainer> call(Observable<Row> dataRow) { ByteBufferBitOutput out = new ByteBufferBitOutput(); out.getByteBuffer().put(gorillaHeader); compressor.close(); ByteBuffer valueBuffer = (ByteBuffer) out.getByteBuffer().flip(); ByteBuffer tagsBuffer = (ByteBuffer) tagsSerializer.getByteBuffer().flip(); cpc.setValueBuffer(valueBuffer);
/** * Causes the currently handled byte to be written to the stream */ @Override public void flush() { bitsLeft = 0; flipByte(); // Causes write to the ByteBuffer }
@Override public void writeBit() { b |= (1 << (bitsLeft - 1)); bitsLeft--; flipByte(); }
/** * Writes the given long to the stream using bits amount of meaningful bits. * * @param value Value to be written to the stream * @param bits How many bits are stored to the stream */ public void writeBits(long value, int bits) { while(bits > 0) { int shift = bits - bitsLeft; if(shift >= 0) { b |= (byte) ((value >> shift) & ((1 << bitsLeft) - 1)); bits -= bitsLeft; bitsLeft = 0; } else { shift = bitsLeft - bits; b |= (byte) (value << shift); bitsLeft -= bits; bits = 0; } flipByte(); } }
/** * Writes the given long to the stream using bits amount of meaningful bits. * * @param value Value to be written to the stream * @param bits How many bits are stored to the stream */ public void writeBits(long value, int bits) { while(bits > 0) { int shift = bits - bitsLeft; if(shift >= 0) { b |= (byte) ((value >> shift) & ((1 << bitsLeft) - 1)); bits -= bitsLeft; bitsLeft = 0; } else { shift = bitsLeft - bits; b |= (byte) (value << shift); bitsLeft -= bits; bits = 0; } flipByte(); } }