@Override public void setBuffer(ByteBuffer buffer) { this.buffer = buffer.asLongBuffer(); }
public static LongBuffer newLongBuffer (int numLongs) { ByteBuffer buffer = ByteBuffer.allocateDirect(numLongs * 8); buffer.order(ByteOrder.nativeOrder()); return buffer.asLongBuffer(); }
public static LongBuffer newLongBuffer (int numLongs) { ByteBuffer buffer = ByteBuffer.allocateDirect(numLongs * 8); buffer.order(ByteOrder.nativeOrder()); return buffer.asLongBuffer(); }
public LongsLongEncodingReader(ByteBuffer fromBuffer, ByteOrder order) { this.buffer = fromBuffer.asReadOnlyBuffer().order(order).asLongBuffer(); }
@Override synchronized void fillCountsArrayFromBuffer(final ByteBuffer buffer, final int length) { buffer.asLongBuffer().get(counts, 0, length); } }
public UUID getMessageId() { final ByteBuffer wrap = ByteBuffer.wrap(messageIdBytes); return new UUID(wrap.asLongBuffer().get(0), wrap.asLongBuffer().get(1)); } }
@Override public Object get(ByteBuffer buf, int position) { long[] bins = new long[breaks.length + 1]; ByteBuffer mutationBuffer = buf.duplicate(); mutationBuffer.position(position); mutationBuffer.asLongBuffer().get(bins); float min = mutationBuffer.getFloat(position + minOffset); float max = mutationBuffer.getFloat(position + maxOffset); return new Histogram(breaks, bins, min, max); }
@Override public void init(ByteBuffer buf, int position) { ByteBuffer mutationBuffer = buf.duplicate(); mutationBuffer.position(position); final long[] bins = new long[breaks.length + 1]; mutationBuffer.asLongBuffer().put(bins); mutationBuffer.putFloat(position + minOffset, Float.POSITIVE_INFINITY); mutationBuffer.putFloat(position + maxOffset, Float.NEGATIVE_INFINITY); }
/** * Writes the dense representation of this ApproximateHistogram object to the given byte-buffer * * Requires 16 + 12 * size bytes of storage * * @param buf ByteBuffer to write the ApproximateHistogram to */ public void toBytesDense(ByteBuffer buf) { buf.putInt(size); buf.putInt(binCount); buf.asFloatBuffer().put(positions); buf.position(buf.position() + Float.BYTES * positions.length); buf.asLongBuffer().put(bins); buf.position(buf.position() + Long.BYTES * bins.length); buf.putFloat(min); buf.putFloat(max); }
/** @return {@code asByteBuffer().asLongBuffer()} */ @Override public final LongBuffer asBuffer() { return asByteBuffer().asLongBuffer(); } }
public TempBuffer() { b16 = BufferUtils.createByteBuffer(16); b16s = b16.asShortBuffer(); b16i = b16.asIntBuffer(); b16l = b16.asLongBuffer(); b16f = b16.asFloatBuffer(); b16d = b16.asDoubleBuffer(); } }
public TempBuffer() { b16 = BufferUtils.createByteBuffer(16); b16s = b16.asShortBuffer(); b16i = b16.asIntBuffer(); b16l = b16.asLongBuffer(); b16f = b16.asFloatBuffer(); b16d = b16.asDoubleBuffer(); } }
/** * Constructs an ApproximateHistogram object from the given dense byte-buffer representation * * @param buf ByteBuffer to construct an ApproximateHistogram from * * @return ApproximateHistogram constructed from the given ByteBuffer */ public static ApproximateHistogram fromBytesDense(ByteBuffer buf) { int size = buf.getInt(); int binCount = buf.getInt(); float[] positions = new float[size]; long[] bins = new long[size]; buf.asFloatBuffer().get(positions); buf.position(buf.position() + Float.BYTES * positions.length); buf.asLongBuffer().get(bins); buf.position(buf.position() + Long.BYTES * bins.length); float min = buf.getFloat(); float max = buf.getFloat(); return new ApproximateHistogram(binCount, positions, bins, min, max); }
public TempBuffer() { b16 = BufferUtils.createByteBuffer(16); b16s = b16.asShortBuffer(); b16i = b16.asIntBuffer(); b16l = b16.asLongBuffer(); b16f = b16.asFloatBuffer(); b16d = b16.asDoubleBuffer(); } }
/** * Returns a {@link LongBuffer} which reads and writes to the same memory * location pointed to by this {@link LongPtr}. * * @param n the maximum number of longs the {@link LongBuffer} can * read/write. This will be the {@link LongBuffer}'s * <code>capacity</code>. * @return the {@link LongBuffer}. */ public LongBuffer asLongBuffer(int n) { return as(BytePtr.class).asByteBuffer(n << 3).order(ByteOrder.nativeOrder()).asLongBuffer(); }
@MarshalsArray public static LongBuffer toLongBuffer(Class<?> cls, long handle, long flags, int d1) { return VM.newDirectByteBuffer(handle, d1 << 3).order(ByteOrder.nativeOrder()).asLongBuffer(); } @MarshalsArray
/** * Helper method for toBytesFull * * @param buf Destination buffer * @param withHeader If true, include the serialization header */ private void writeByteBufferFull(ByteBuffer buf, boolean withHeader) { if (withHeader) { writeByteBufferSerdeHeader(buf, FULL_ENCODING_MODE); } writeByteBufferCommonFields(buf); buf.asLongBuffer().put(histogram); buf.position(buf.position() + Long.BYTES * histogram.length); }
@Override synchronized void fillCountsArrayFromBuffer(final ByteBuffer buffer, final int length) { LongBuffer logbuffer = buffer.asLongBuffer(); for (int i = 0; i < length; i++) { inactiveCounts.lazySet(i, logbuffer.get()); activeCounts.lazySet(i, 0); } }
@Override protected void loadBuffer(int bufferNum) { CloseQuietly.close(holder); holder = singleThreadedLongBuffers.get(bufferNum); buffer = holder.get(); // asLongBuffer() makes the longBuffer's position = 0 longBuffer = buffer.asLongBuffer(); currBufferNum = bufferNum; } };
@Override public LongBuffer asNioLong() { if (offset() >= Integer.MAX_VALUE) throw new IllegalStateException("Index out of bounds " + offset()); if (offset() == 0) { return wrappedBuffer().asLongBuffer(); } else return (LongBuffer) wrappedBuffer().asLongBuffer().position((int) offset()); }