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

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

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

Bytes.read介绍

暂无

代码示例

代码示例来源:origin: oracle/opengrok

@NotNull
@Override
@SuppressWarnings("rawtypes")
public BytesRef read(Bytes in, long size, @Nullable BytesRef using) {
  if (size < 0L || size > (long) Integer.MAX_VALUE) {
    throw new IORuntimeException("byte[] size should be non-negative int, " +
        size + " given. Memory corruption?");
  }
  int arrayLength = (int) size;
  if (using == null) {
    using = new BytesRef(new byte[arrayLength]);
  } else if (using.bytes.length < arrayLength) {
    using.bytes = new byte[arrayLength];
  }
  in.read(using.bytes, 0, arrayLength);
  using.offset = 0;
  using.length = arrayLength;
  return using;
}

代码示例来源:origin: wavefrontHQ/java

private static String readString(Bytes in) {
 byte[] bytes = new byte[in.readShort()];
 in.read(bytes);
 return new String(bytes);
}

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

@NotNull
default BigInteger readBigInteger() {
  int length = Maths.toUInt31(readStopBit());
  if (length == 0)
    if (lenient())
      return BigInteger.ZERO;
    else
      throw new BufferUnderflowException();
  @NotNull byte[] bytes = new byte[length];
  read(bytes);
  return new BigInteger(bytes);
}

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

public int fetchOneMessage(@NotNull ExcerptTailer tailer, @NotNull byte[] using) {
  try (DocumentContext dc = tailer.readingDocument()) {
    return !dc.isPresent() ? -1 : dc.wire().bytes().read(using);
  }
}

代码示例来源:origin: com.wavefront/proxy

private static String readString(Bytes in) {
 byte[] bytes = new byte[in.readShort()];
 in.read(bytes);
 return new String(bytes);
}

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

@NotNull
@Override
public ByteBuffer read(@NotNull Bytes in, long size, @Nullable ByteBuffer using) {
  if (size < 0L || size > (long) Integer.MAX_VALUE)
    throw new IllegalArgumentException("ByteBuffer size should be non-negative int, " +
        size + " given. Memory corruption?");
  int bufferCap = (int) size;
  if (using == null || using.capacity() < bufferCap) {
    using = ByteBuffer.allocate(bufferCap);
  } else {
    using.position(0);
    using.limit(bufferCap);
  }
  in.read(using);
  using.flip();
  return using;
}

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

@NotNull
@Override
public byte[] read(@NotNull Bytes in, long size, @Nullable byte[] using) {
  if (size < 0L || size > (long) Integer.MAX_VALUE) {
    throw new IORuntimeException("byte[] size should be non-negative int, " +
        size + " given. Memory corruption?");
  }
  int arrayLength = (int) size;
  if (using == null || arrayLength != using.length)
    using = new byte[arrayLength];
  in.read(using);
  return using;
}

相关文章

微信公众号

最新文章

更多