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

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

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

Output.writeBytes介绍

[英]Writes a ByteString(wraps byte array) field.
[中]写入ByteString(包装字节数组)字段。

代码示例

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

@Override
public void writeTo(Output output, int number, ByteString value,
    boolean repeated) throws IOException
{
  output.writeBytes(number, value, repeated);
}

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

@Override
public void writeTo(Output output, int number, ByteString value,
    boolean repeated) throws IOException
{
  output.writeBytes(number, value, repeated);
}

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

@Override
public void writeTo(Output output, int number, ByteString value,
    boolean repeated) throws IOException
{
  output.writeBytes(number, value, repeated);
}

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

@Override
public void writeBytes(int fieldNumber, ByteString value, boolean repeated) throws IOException
{
  output.writeBytes(fieldNumber, value, repeated);
}

代码示例来源: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

dup.limit(length);
output.writeBytes(fieldNumber, dup, repeated);

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

dup.limit(length);
output.writeBytes(fieldNumber, dup, repeated);

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

dup.limit(length);
output.writeBytes(fieldNumber, dup, repeated);

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

@Override
  public void writeTo(Output output, Object value) throws IOException
  {
    ByteString[] array = (ByteString[]) value;
    output.writeInt32(ID_ARRAY_LEN, array.length, false);
    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
      ByteString v = array[i];
      if (v != null)
      {
        if (nullCount != 0)
        {
          output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
          nullCount = 0;
        }
        output.writeBytes(ID_ARRAY_DATA, v, true);
      }
      else if (allowNullArrayElement)
      {
        nullCount++;
      }
    }
    // if last element is null
    if (nullCount != 0)
      output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
  }
}

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

@Override
  public void writeTo(Output output, Object value) throws IOException
  {
    ByteString[] array = (ByteString[]) value;
    output.writeInt32(ID_ARRAY_LEN, array.length, false);
    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
      ByteString v = array[i];
      if (v != null)
      {
        if (nullCount != 0)
        {
          output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
          nullCount = 0;
        }
        output.writeBytes(ID_ARRAY_DATA, v, true);
      }
      else if (allowNullArrayElement)
      {
        nullCount++;
      }
    }
    // if last element is null
    if (nullCount != 0)
      output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
  }
}

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

@Override
public void writeTo(Output output, Bar message) throws IOException
{
  if (message.someInt != 0)
    output.writeInt32(1, message.someInt, false);
  if (message.someString != null)
    output.writeString(2, message.someString, false);
  if (message.someBaz != null)
    output.writeObject(3, message.someBaz, Baz.getSchema(), false);
  if (message.someEnum != null)
    output.writeEnum(4, message.someEnum.number, false);
  if (message.someBytes != null)
    output.writeBytes(5, message.someBytes, false);
  if (message.someBoolean)
    output.writeBool(6, message.someBoolean, false);
  if (message.someFloat != 0f)
    output.writeFloat(7, message.someFloat, false);
  if (message.someDouble != 0d)
    output.writeDouble(8, message.someDouble, false);
  if (message.someLong != 0l)
    output.writeInt64(9, message.someLong, false);
}

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

output.writeBytes(5, value, true);

代码示例来源:origin: dremio/dremio-oss

public void writeTo(Output output, PreparedStatementHandle message) throws IOException
{
  if(message.serverInfo != null)
    output.writeBytes(1, message.serverInfo, false);
}

代码示例来源:origin: dremio/dremio-oss

public void writeTo(Output output, UserAuth message) throws IOException
{
  if(message.uid != null)
     output.writeObject(1, message.uid, UID.getSchema(), false);
  if(message.prefix != null)
    output.writeBytes(2, message.prefix, false);
  if(message.authKey != null)
    output.writeBytes(3, message.authKey, false);
}

代码示例来源:origin: dremio/dremio-oss

public void writeTo(Output output, ExtraInfo message) throws IOException
{
  if(message.name != null)
    output.writeString(1, message.name, false);
  if(message.data != null)
    output.writeBytes(2, message.data, false);
}

代码示例来源:origin: dremio/dremio-oss

public void writeTo(Output output, CompleteRpcMessage message) throws IOException
{
  if(message.header != null)
     output.writeObject(1, message.header, RpcHeader.getSchema(), false);
  if(message.protobufBody != null)
    output.writeBytes(2, message.protobufBody, false);
  if(message.rawBody != null)
    output.writeBytes(3, message.rawBody, false);
}

代码示例来源:origin: dremio/dremio-oss

public void writeTo(Output output, SchedulingInfo message) throws IOException
{
  if(message.queueId != null)
    output.writeString(1, message.queueId, false);
  if(message.workloadClass != null)
     output.writeEnum(2, message.workloadClass.number, false);
  if(message.additionalInfo != null)
    output.writeBytes(3, message.additionalInfo, false);
}

代码示例来源:origin: dremio/dremio-oss

public void writeTo(Output output, ConfigurationEntry message) throws IOException
{
  if(message.type != null)
    output.writeString(1, message.type, false);
  if(message.value != null)
    output.writeBytes(2, message.value, false);
  if(message.version != null)
    output.writeInt64(3, message.version, false);
  if(message.tag != null)
    output.writeString(4, message.tag, false);
}

代码示例来源:origin: dremio/dremio-oss

public void writeTo(Output output, SharedData message) throws IOException
{
  if(message.majorFragmentId != 0)
    output.writeInt32(1, message.majorFragmentId, false);
  if(message.operatorId != 0)
    output.writeInt32(2, message.operatorId, false);
  if(message.name != null)
    output.writeString(3, message.name, false);
  if(message.value != null)
    output.writeBytes(4, message.value, false);
}

相关文章