java.nio.ByteBuffer.asLongBuffer()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中java.nio.ByteBuffer.asLongBuffer()方法的一些代码示例,展示了ByteBuffer.asLongBuffer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.asLongBuffer()方法的具体详情如下:
包路径:java.nio.ByteBuffer
类名称:ByteBuffer
方法名:asLongBuffer

ByteBuffer.asLongBuffer介绍

[英]Returns a long buffer which is based on the remaining content of this byte buffer.

The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.

The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
[中]返回基于此字节缓冲区剩余内容的长缓冲区。
新缓冲区的位置为零,其限制和容量为剩余字节数除以8,且未设置其标记。新缓冲区的只读属性和字节顺序与此缓冲区的相同。如果此字节缓冲区是直接的,则新缓冲区是直接的。
新缓冲区与此缓冲区共享其内容,这意味着任何一个缓冲区的内容更改都将对另一个缓冲区可见。两个缓冲器的位置、极限和标记是独立的。

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
public void setBuffer(ByteBuffer buffer)
{
 this.buffer = buffer.asLongBuffer();
}

代码示例来源:origin: libgdx/libgdx

public static LongBuffer newLongBuffer (int numLongs) {
  ByteBuffer buffer = ByteBuffer.allocateDirect(numLongs * 8);
  buffer.order(ByteOrder.nativeOrder());
  return buffer.asLongBuffer();
}

代码示例来源:origin: libgdx/libgdx

public static LongBuffer newLongBuffer (int numLongs) {
  ByteBuffer buffer = ByteBuffer.allocateDirect(numLongs * 8);
  buffer.order(ByteOrder.nativeOrder());
  return buffer.asLongBuffer();
}

代码示例来源:origin: apache/incubator-druid

public LongsLongEncodingReader(ByteBuffer fromBuffer, ByteOrder order)
{
 this.buffer = fromBuffer.asReadOnlyBuffer().order(order).asLongBuffer();
}

代码示例来源:origin: HdrHistogram/HdrHistogram

@Override
  synchronized void fillCountsArrayFromBuffer(final ByteBuffer buffer, final int length) {
    buffer.asLongBuffer().get(counts, 0, length);
  }
}

代码示例来源:origin: Graylog2/graylog2-server

public UUID getMessageId() {
    final ByteBuffer wrap = ByteBuffer.wrap(messageIdBytes);
    return new UUID(wrap.asLongBuffer().get(0), wrap.asLongBuffer().get(1));
  }
}

代码示例来源:origin: apache/incubator-druid

@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);
}

代码示例来源:origin: apache/incubator-druid

@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);
}

代码示例来源:origin: apache/incubator-druid

/**
 * 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);
}

代码示例来源:origin: bytedeco/javacpp

/** @return {@code asByteBuffer().asLongBuffer()} */
  @Override public final LongBuffer asBuffer() {
    return asByteBuffer().asLongBuffer();
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public TempBuffer() {
    b16 = BufferUtils.createByteBuffer(16);
    b16s = b16.asShortBuffer();
    b16i = b16.asIntBuffer();
    b16l = b16.asLongBuffer();
    b16f = b16.asFloatBuffer();
    b16d = b16.asDoubleBuffer();
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public TempBuffer() {
    b16 = BufferUtils.createByteBuffer(16);
    b16s = b16.asShortBuffer();
    b16i = b16.asIntBuffer();
    b16l = b16.asLongBuffer();
    b16f = b16.asFloatBuffer();
    b16d = b16.asDoubleBuffer();
  }
}

代码示例来源:origin: apache/incubator-druid

/**
 * 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);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public TempBuffer() {
    b16 = BufferUtils.createByteBuffer(16);
    b16s = b16.asShortBuffer();
    b16i = b16.asIntBuffer();
    b16l = b16.asLongBuffer();
    b16f = b16.asFloatBuffer();
    b16d = b16.asDoubleBuffer();
  }
}

代码示例来源:origin: robovm/robovm

/**
 * 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();
}

代码示例来源:origin: robovm/robovm

@MarshalsArray
public static LongBuffer toLongBuffer(Class<?> cls, long handle, long flags, int d1) {
  return VM.newDirectByteBuffer(handle, d1 << 3).order(ByteOrder.nativeOrder()).asLongBuffer();
}
@MarshalsArray

代码示例来源:origin: apache/incubator-druid

/**
 * 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);
}

代码示例来源:origin: HdrHistogram/HdrHistogram

@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);
  }
}

代码示例来源:origin: apache/incubator-druid

@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;
 }
};

代码示例来源:origin: deeplearning4j/nd4j

@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());
}

相关文章

微信公众号

最新文章

更多