@Override public synchronized int encodeIntoCompressedByteBuffer(final ByteBuffer targetBuffer) { return super.encodeIntoCompressedByteBuffer(targetBuffer); } }
@Override public synchronized int encodeIntoCompressedByteBuffer( final ByteBuffer targetBuffer, final int compressionLevel) { return super.encodeIntoCompressedByteBuffer(targetBuffer, compressionLevel); }
/** * Encode this histogram in compressed form into a byte array * @param targetBuffer The buffer to encode into * @return The number of bytes written to the array */ public int encodeIntoCompressedByteBuffer(final ByteBuffer targetBuffer) { return encodeIntoCompressedByteBuffer(targetBuffer, Deflater.DEFAULT_COMPRESSION); }
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); out.writeDoubleArray(keys); out.writeLong(state.getHighestToLowestValueRatio()); ByteBuffer stateBuffer = ByteBuffer.allocate(state.getNeededByteBufferCapacity()); final int serializedLen = state.encodeIntoCompressedByteBuffer(stateBuffer); out.writeVInt(serializedLen); out.writeBytes(stateBuffer.array(), 0, serializedLen); out.writeBoolean(keyed); }
@Override public synchronized int encodeIntoCompressedByteBuffer(final ByteBuffer targetBuffer) { return super.encodeIntoCompressedByteBuffer(targetBuffer); } }
/** * Encode this histogram in compressed form into a byte array * @param targetBuffer The buffer to encode into * @return The number of bytes written to the array */ public int encodeIntoCompressedByteBuffer(final ByteBuffer targetBuffer) { return encodeIntoCompressedByteBuffer(targetBuffer, Deflater.DEFAULT_COMPRESSION); }
@Override public synchronized int encodeIntoCompressedByteBuffer( final ByteBuffer targetBuffer, final int compressionLevel) { return super.encodeIntoCompressedByteBuffer(targetBuffer, compressionLevel); }
@Override public byte[] toBinary() { final int positiveBytes = positiveHistogram.getEstimatedFootprintInBytes(); final int bytesNeeded = positiveBytes + (negativeHistogram == null ? 0 : negativeHistogram.getEstimatedFootprintInBytes()); final ByteBuffer buffer = super.binaryBuffer(bytesNeeded + 5); final int startPosition = buffer.position(); buffer.putInt(startPosition); // buffer out an int positiveHistogram.encodeIntoCompressedByteBuffer(buffer); final int endPosition = buffer.position(); buffer.position(startPosition); buffer.putInt(endPosition); buffer.position(endPosition); if (negativeHistogram != null) { buffer.put((byte) 0x01); negativeHistogram.encodeIntoCompressedByteBuffer(buffer); } else { buffer.put((byte) 0x00); } final byte result[] = new byte[buffer.position() + 1]; buffer.rewind(); buffer.get(result); return result; }
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); out.writeDoubleArray(keys); out.writeLong(state.getHighestToLowestValueRatio()); ByteBuffer stateBuffer = ByteBuffer.allocate(state.getNeededByteBufferCapacity()); final int serializedLen = state.encodeIntoCompressedByteBuffer(stateBuffer); out.writeVInt(serializedLen); out.writeBytes(stateBuffer.array(), 0, serializedLen); out.writeBoolean(keyed); }
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); out.writeDoubleArray(keys); out.writeLong(state.getHighestToLowestValueRatio()); ByteBuffer stateBuffer = ByteBuffer.allocate(state.getNeededByteBufferCapacity()); final int serializedLen = state.encodeIntoCompressedByteBuffer(stateBuffer); out.writeVInt(serializedLen); out.writeBytes(stateBuffer.array(), 0, serializedLen); out.writeBoolean(keyed); }
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); out.writeDoubleArray(keys); out.writeLong(state.getHighestToLowestValueRatio()); ByteBuffer stateBuffer = ByteBuffer.allocate(state.getNeededByteBufferCapacity()); final int serializedLen = state.encodeIntoCompressedByteBuffer(stateBuffer); out.writeVInt(serializedLen); out.writeBytes(stateBuffer.array(), 0, serializedLen); out.writeBoolean(keyed); }
@Override protected void doWriteTo(StreamOutput out) throws IOException { ValueFormatterStreams.writeOptional(valueFormatter, out); out.writeInt(keys.length); for (int i = 0 ; i < keys.length; ++i) { out.writeDouble(keys[i]); } out.writeLong(state.getHighestToLowestValueRatio()); ByteBuffer stateBuffer = ByteBuffer.allocate(state.getNeededByteBufferCapacity()); final int serializedLen = state.encodeIntoCompressedByteBuffer(stateBuffer); out.writeVInt(serializedLen); out.writeBytes(stateBuffer.array(), 0, serializedLen); out.writeBoolean(keyed); }