net.openhft.chronicle.bytes.Bytes.ensureCapacity()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(90)

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

Bytes.ensureCapacity介绍

[英]grow the buffer if the buffer is elastic, if the buffer is not elastic and there is not enough capacity then this method will throws java.nio.BufferOverflowException
[中]如果缓冲区是弹性的,则增加缓冲区;如果缓冲区不是弹性的,并且没有足够的容量,则此方法将抛出java。尼奥。BufferOverflowException

代码示例

代码示例来源:origin: OpenHFT/Chronicle-Queue

try (DocumentContext dc = appender.writingDocument()) {
  Bytes<?> bytes0 = dc.wire().bytes();
  bytes0.ensureCapacity(size);
  bytes.setBytes(bytes0);
  bytes.readPosition(bytes.writePosition());

代码示例来源:origin: net.openhft/chronicle-engine

private Bytes getFileContentsFromDisk0(@NotNull Path path, Bytes using) throws IOException {
  if (!Files.exists(path)) return null;
  File file = path.toFile();
  Buffers b = Buffers.BUFFERS.get();
  Bytes<ByteBuffer> readingBytes = b.valueBuffer;
  try (FileChannel fc = new FileInputStream(file).getChannel()) {
    readingBytes.ensureCapacity(fc.size());
    @Nullable ByteBuffer dst = readingBytes.underlyingObject();
    dst.clear();
    fc.read(dst);
    readingBytes.readPositionRemaining(0, dst.position());
    dst.flip();
  }
  readingBytes.reserve();
  return readingBytes;
}

代码示例来源:origin: net.openhft/chronicle-bytes

@Override
public void ensureCapacity(long size) throws IllegalArgumentException {
  if (size > realCapacity()) {
    underlyingBytes.ensureCapacity(size);
    bytesStore = (NativeBytesStore<Underlying>) underlyingBytes.bytesStore();
  }
}

代码示例来源:origin: net.openhft/chronicle-bytes

@Override
public void ensureCapacity(long size) throws IllegalArgumentException {
  if (size > realCapacity()) {
    underlyingBytes.ensureCapacity(size);
    bytesStore = underlyingBytes.bytesStore();
  }
}

代码示例来源:origin: net.openhft/chronicle-bytes

outBytes.ensureCapacity(writePos + outputSize);
outBytes.readPositionRemaining(writePos, outputSize);
BytesInternal.assignBytesStoreToByteBuffer(outBytes, using2);

相关文章

微信公众号

最新文章

更多