本文整理了Java中org.apache.ratis.thirdparty.com.google.protobuf.ByteString.asReadOnlyByteBuffer()
方法的一些代码示例,展示了ByteString.asReadOnlyByteBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.asReadOnlyByteBuffer()
方法的具体详情如下:
包路径:org.apache.ratis.thirdparty.com.google.protobuf.ByteString
类名称:ByteString
方法名:asReadOnlyByteBuffer
暂无
代码示例来源:origin: apache/incubator-ratis
public static String bytes2HexString(ByteString bytes) {
Objects.requireNonNull(bytes, "bytes == null");
return bytes2HexString(bytes.asReadOnlyByteBuffer());
}
代码示例来源:origin: apache/incubator-ratis
private static UUID toUuid(ByteString bytes) {
Objects.requireNonNull(bytes, "bytes == null");
checkLength(bytes.size(), "bytes.size()");
final ByteBuffer buf = bytes.asReadOnlyByteBuffer();
return new UUID(buf.getLong(), buf.getLong());
}
代码示例来源:origin: apache/incubator-ratis
private int write(long offset, ByteString data, boolean close) throws IOException {
if (offset != writeSize) {
throw new IOException("Offset/size mismatched: offset = " + offset
+ " != writeSize = " + writeSize + ", path=" + getRelativePath());
}
if (out == null) {
throw new IOException("File output is not initialized, path=" + getRelativePath());
}
synchronized (out) {
int n = 0;
if (data != null) {
final ByteBuffer buffer = data.asReadOnlyByteBuffer();
try {
for (; buffer.remaining() > 0; ) {
n += out.write(buffer);
}
} finally {
writeSize += n;
}
}
if (close) {
out.close();
}
return n;
}
}
代码示例来源:origin: apache/incubator-ratis
void verify(ByteString read, int offset, int length, ByteBuffer expected) {
Assert.assertEquals(length, read.size());
assertBuffers(offset, length, expected, read.asReadOnlyByteBuffer());
}
代码示例来源:origin: apache/incubator-ratis
final ByteBuffer expected = ByteString.copyFrom(randomBytes(length, r)).asReadOnlyByteBuffer();
内容来源于网络,如有侵权,请联系作者删除!