io.protostuff.Output.writeByteRange()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(130)

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

Output.writeByteRange介绍

[英]Writes a binary or a pre-encoded utf8 string.
[中]写入二进制或预编码的utf8字符串。

代码示例

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

@Override
public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value,
    int offset, int length, boolean repeated) throws IOException
{
  output.writeByteRange(utf8String, fieldNumber, value, offset, length, repeated);
}

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

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
    boolean repeated) throws IOException
{
  final int size = readRawVarint32();
  if (size <= (bufferSize - bufferPos) && size > 0)
  {
    // Fast path: We already have the bytes in a contiguous buffer
    output.writeByteRange(utf8String, fieldNumber, buffer, bufferPos, size, repeated);
    bufferPos += size;
  }
  else
  {
    // Slow path: Build a byte array first then copy it.
    output.writeByteRange(utf8String, fieldNumber, readRawBytes(size), 0, size, repeated);
  }
}

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

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
    boolean repeated) throws IOException
{
  final int length = readRawVarint32();
  if (length < 0)
    throw ProtobufException.negativeSize();
  output.writeByteRange(utf8String, fieldNumber, buffer, offset, length, repeated);
  offset += length;
}

代码示例来源:origin: fengjiachun/Jupiter

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
                boolean repeated) throws IOException {
  final int length = readRawVarInt32();
  if (length < 0) {
    throw ProtocolException.negativeSize();
  }
  if (utf8String) {
    // if it is a UTF string, we have to call the writeByteRange.
    if (nioBuffer.hasArray()) {
      output.writeByteRange(true, fieldNumber, nioBuffer.array(),
          nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
      nioBuffer.position(nioBuffer.position() + length);
    } else {
      byte[] bytes = new byte[length];
      nioBuffer.get(bytes);
      output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
    }
  } else {
    // Do the potentially vastly more efficient potential splice call.
    if (nioBuffer.remaining() < length) {
      throw ProtocolException.misreportedSize();
    }
    ByteBuffer dup = nioBuffer.slice();
    dup.limit(length);
    output.writeBytes(fieldNumber, dup, repeated);
    nioBuffer.position(nioBuffer.position() + length);
  }
}

代码示例来源:origin: fengjiachun/Jupiter

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
                boolean repeated) throws IOException {
  final int length = readRawVarInt32();
  if (length < 0) {
    throw ProtocolException.negativeSize();
  }
  if (utf8String) {
    // if it is a UTF string, we have to call the writeByteRange.
    if (nioBuffer.hasArray()) {
      output.writeByteRange(true, fieldNumber, nioBuffer.array(),
          nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
      nioBuffer.position(nioBuffer.position() + length);
    } else {
      byte[] bytes = new byte[length];
      nioBuffer.get(bytes);
      output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
    }
  } else {
    // Do the potentially vastly more efficient potential splice call.
    if (nioBuffer.remaining() < length) {
      throw ProtocolException.misreportedSize();
    }
    ByteBuffer dup = nioBuffer.slice();
    dup.limit(length);
    output.writeBytes(fieldNumber, dup, repeated);
    nioBuffer.position(nioBuffer.position() + length);
  }
}

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

output.writeByteRange(true, fieldNumber, buffer.array(),
    buffer.arrayOffset() + buffer.position(), length, repeated);
buffer.position(buffer.position() + length);
output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);

代码示例来源:origin: fengjiachun/Jupiter

output.writeByteRange(true, fieldNumber, nioBuffer.array(),
    nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
nioBuffer.position(nioBuffer.position() + length);
UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length);
nioBuffer.position(position + length);
output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);

代码示例来源:origin: fengjiachun/Jupiter

output.writeByteRange(true, fieldNumber, nioBuffer.array(),
    nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
nioBuffer.position(nioBuffer.position() + length);
UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length);
nioBuffer.position(position + length);
output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);

代码示例来源:origin: org.jupiter-rpc/jupiter-all

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
                boolean repeated) throws IOException {
  final int length = readRawVarInt32();
  if (length < 0) {
    throw ProtocolException.negativeSize();
  }
  if (utf8String) {
    // if it is a UTF string, we have to call the writeByteRange.
    if (nioBuffer.hasArray()) {
      output.writeByteRange(true, fieldNumber, nioBuffer.array(),
          nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
      nioBuffer.position(nioBuffer.position() + length);
    } else {
      byte[] bytes = new byte[length];
      nioBuffer.get(bytes);
      output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
    }
  } else {
    // Do the potentially vastly more efficient potential splice call.
    if (nioBuffer.remaining() < length) {
      throw ProtocolException.misreportedSize();
    }
    ByteBuffer dup = nioBuffer.slice();
    dup.limit(length);
    output.writeBytes(fieldNumber, dup, repeated);
    nioBuffer.position(nioBuffer.position() + length);
  }
}

代码示例来源:origin: org.jupiter-rpc/jupiter-serialization-protostuff

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
                boolean repeated) throws IOException {
  final int length = readRawVarInt32();
  if (length < 0) {
    throw ProtocolException.negativeSize();
  }
  if (utf8String) {
    // if it is a UTF string, we have to call the writeByteRange.
    if (nioBuffer.hasArray()) {
      output.writeByteRange(true, fieldNumber, nioBuffer.array(),
          nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
      nioBuffer.position(nioBuffer.position() + length);
    } else {
      byte[] bytes = new byte[length];
      nioBuffer.get(bytes);
      output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
    }
  } else {
    // Do the potentially vastly more efficient potential splice call.
    if (nioBuffer.remaining() < length) {
      throw ProtocolException.misreportedSize();
    }
    ByteBuffer dup = nioBuffer.slice();
    dup.limit(length);
    output.writeBytes(fieldNumber, dup, repeated);
    nioBuffer.position(nioBuffer.position() + length);
  }
}

代码示例来源:origin: org.jupiter-rpc/jupiter-serialization-protostuff

output.writeByteRange(true, fieldNumber, nioBuffer.array(),
    nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
nioBuffer.position(nioBuffer.position() + length);
UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length);
nioBuffer.position(position + length);
output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);

代码示例来源:origin: org.jupiter-rpc/jupiter-all

output.writeByteRange(true, fieldNumber, nioBuffer.array(),
    nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated);
nioBuffer.position(nioBuffer.position() + length);
UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length);
nioBuffer.position(position + length);
output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);

代码示例来源:origin: hank-whu/turbo-rpc

output.writeByteRange(true, fieldNumber, byteBuf.array(), byteBuf.arrayOffset() + byteBuf.readerIndex(),
    length, repeated);
byteBuf.readerIndex(byteBuf.readerIndex() + length);
byte[] bytes = new byte[length];
byteBuf.readBytes(bytes);
output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);

相关文章