@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(); }
public Compressor(long timestamp, BitOutput output) { blockTimestamp = timestamp; out = output; addHeader(timestamp); }
/** * Adds a new long value to the series. Note, values must be inserted in order. * * @param timestamp Timestamp which is inside the allowed time block (default 24 hours with millisecond precision) * @param value next floating point value in the series */ public void addValue(long timestamp, long value) { if(storedTimestamp == 0) { writeFirst(timestamp, value); } else { compressTimestamp(timestamp); compressValue(value); } }
switch(metricType.getCode()) { case 0: // GAUGE compressor.addValue(d.getTimestamp(), (Double) d.getValue()); break; case 1: // AVAILABILITY compressor.addValue(d.getTimestamp(), ((Byte) ((AvailabilityType) d.getValue()).getCode()) .doubleValue()); break; case 2: // COUNTER compressor.addValue(d.getTimestamp(), ((Long) d.getValue()).doubleValue()); break; default: compressor.close(); ByteBuffer valueBuffer = (ByteBuffer) out.getByteBuffer().flip(); ByteBuffer tagsBuffer = (ByteBuffer) tagsSerializer.getByteBuffer().flip();
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); }
private void compressValue(long value) { // TODO Fix already compiled into a big method long xor = storedVal ^ value; if(xor == 0) { // Write 0 out.skipBit(); } else { int leadingZeros = Long.numberOfLeadingZeros(xor); int trailingZeros = Long.numberOfTrailingZeros(xor); // Check overflow of leading? Can't be 32! if(leadingZeros >= 32) { leadingZeros = 31; } // Store bit '1' out.writeBit(); if(leadingZeros >= storedLeadingZeros && trailingZeros >= storedTrailingZeros) { writeExistingLeading(xor); } else { writeNewLeading(xor, leadingZeros, trailingZeros); } } storedVal = value; }
switch(metricType.getCode()) { case 0: // GAUGE compressor.addValue(d.getTimestamp(), (Double) d.getValue()); break; case 1: // AVAILABILITY compressor.addValue(d.getTimestamp(), ((Byte) ((AvailabilityType) d.getValue()).getCode()) .doubleValue()); break; case 2: // COUNTER compressor.addValue(d.getTimestamp(), ((Long) d.getValue()).doubleValue()); break; default: compressor.close(); ByteBuffer valueBuffer = (ByteBuffer) out.getByteBuffer().flip(); ByteBuffer tagsBuffer = (ByteBuffer) tagsSerializer.getByteBuffer().flip();
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); }
private void compressValue(long value) { // TODO Fix already compiled into a big method long xor = storedVal ^ value; if(xor == 0) { // Write 0 out.skipBit(); } else { int leadingZeros = Long.numberOfLeadingZeros(xor); int trailingZeros = Long.numberOfTrailingZeros(xor); // Check overflow of leading? Can't be 32! if(leadingZeros >= 32) { leadingZeros = 31; } // Store bit '1' out.writeBit(); if(leadingZeros >= storedLeadingZeros && trailingZeros >= storedTrailingZeros) { writeExistingLeading(xor); } else { writeNewLeading(xor, leadingZeros, trailingZeros); } } storedVal = value; }
@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(); }
/** * Adds a new long value to the series. Note, values must be inserted in order. * * @param timestamp Timestamp which is inside the allowed time block (default 24 hours with millisecond precision) * @param value next floating point value in the series */ public void addValue(long timestamp, long value) { if(storedTimestamp == 0) { writeFirst(timestamp, value); } else { compressTimestamp(timestamp); compressValue(value); } }
public Compressor(long timestamp, BitOutput output) { blockTimestamp = timestamp; out = output; addHeader(timestamp); }
LongArrayOutput arrayOutput = new LongArrayOutput(amountOfPoints); Compressor c = new Compressor(blockStart, output); GorillaCompressor gc = new GorillaCompressor(blockStart, arrayOutput); c.addValue(bb.getLong(), bb.getDouble()); gc.addValue(uncompressedTimestamps[j], uncompressedDoubles[j]); c.close();
/** * Adds a new double value to the series. Note, values must be inserted in order. * * @param timestamp Timestamp which is inside the allowed time block (default 24 hours with millisecond precision) * @param value next floating point value in the series */ public void addValue(long timestamp, double value) { if(storedTimestamp == 0) { writeFirst(timestamp, Double.doubleToRawLongBits(value)); } else { compressTimestamp(timestamp); compressValue(Double.doubleToRawLongBits(value)); } }
LongArrayOutput arrayOutput = new LongArrayOutput(amountOfPoints); Compressor c = new Compressor(blockStart, output); GorillaCompressor gc = new GorillaCompressor(blockStart, arrayOutput); c.addValue(bb.getLong(), bb.getDouble()); gc.addValue(uncompressedTimestamps[j], uncompressedDoubles[j]); c.close();
/** * Adds a new double value to the series. Note, values must be inserted in order. * * @param timestamp Timestamp which is inside the allowed time block (default 24 hours with millisecond precision) * @param value next floating point value in the series */ public void addValue(long timestamp, double value) { if(storedTimestamp == 0) { writeFirst(timestamp, Double.doubleToRawLongBits(value)); } else { compressTimestamp(timestamp); compressValue(Double.doubleToRawLongBits(value)); } }
out.getByteBuffer().put(gorillaHeader); Compressor compressor = new Compressor(timeslice, out); TagsSerializer tagsSerializer = new TagsSerializer(timeslice); switch(r.getByte(1)) { case 0: // GAUGE compressor.addValue(timestamp, r.getDouble(4)); break; case 1: // AVAILABILITY compressor.addValue(timestamp, ((Byte) (AvailabilityType.fromBytes(r.getBytes(5)) .getCode())).doubleValue()); break; case 2: // COUNTER compressor.addValue(timestamp, ((Long) r.getLong(6)).doubleValue()); break; default: compressor.close();
out.getByteBuffer().put(gorillaHeader); Compressor compressor = new Compressor(timeslice, out); TagsSerializer tagsSerializer = new TagsSerializer(timeslice); switch(r.getByte(1)) { case 0: // GAUGE compressor.addValue(timestamp, r.getDouble(4)); break; case 1: // AVAILABILITY compressor.addValue(timestamp, ((Byte) (AvailabilityType.fromBytes(r.getBytes(5)) .getCode())).doubleValue()); break; case 2: // COUNTER compressor.addValue(timestamp, ((Long) r.getLong(6)).doubleValue()); break; default: compressor.close();