com.google.protobuf.Message.getSerializedSize()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(161)

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

Message.getSerializedSize介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

@Override
public int encodedLength(T val) {
 return val.getSerializedSize();
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

private static int getDelimitedLength(Message message) {
 int length = message.getSerializedSize();
 return length + CodedOutputStream.computeRawVarint32Size(length);
}

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

public static void writeMessage(DataOutputStream output, Message message) throws IOException {
  /*
   * We don't use varints here because the c++ version of the protocol
   * buffer classes seem to be buggy requesting more data than necessary
   * from the underlying stream causing it to block forever
   */
  output.writeInt(message.getSerializedSize());
  CodedOutputStream codedOut = CodedOutputStream.newInstance(output);
  message.writeTo(codedOut);
  codedOut.flush();
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
void writeTo(ResponseBuffer out) throws IOException {
 int length = message.getSerializedSize();
 length += CodedOutputStream.computeRawVarint32Size(length);
 out.ensureCapacity(length);
 message.writeDelimitedTo(out);
}

代码示例来源:origin: line/armeria

private ByteBuf serializeProto(Message message) throws IOException {
  if (GrpcSerializationFormats.isProto(serializationFormat)) {
    final int serializedSize = message.getSerializedSize();
    if (serializedSize == 0) {
      return Unpooled.EMPTY_BUFFER;

代码示例来源:origin: org.apache.hadoop/hadoop-common

private byte[] setupResponseForProtobuf(
  RpcResponseHeaderProto header, Writable rv) throws IOException {
 Message payload = (rv != null)
   ? ((RpcWritable.ProtobufWrapper)rv).getMessage() : null;
 int length = getDelimitedLength(header);
 if (payload != null) {
  length += getDelimitedLength(payload);
 }
 byte[] buf = new byte[length + 4];
 CodedOutputStream cos = CodedOutputStream.newInstance(buf);
 // the stream only supports little endian ints
 cos.writeRawByte((byte)((length >>> 24) & 0xFF));
 cos.writeRawByte((byte)((length >>> 16) & 0xFF));
 cos.writeRawByte((byte)((length >>>  8) & 0xFF));
 cos.writeRawByte((byte)((length >>>  0) & 0xFF));
 cos.writeRawVarint32(header.getSerializedSize());
 header.writeTo(cos);
 if (payload != null) {
  cos.writeRawVarint32(payload.getSerializedSize());
  payload.writeTo(cos);
 }
 return buf;
}

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

outputContainer.ensureSpace(response.getSerializedSize());

代码示例来源:origin: baidu/brpc-java

@Override
  public int getOutputSerializedSize(Object output) throws IOException {
    if (output instanceof Message) {
      return ((Message) output).getSerializedSize();
    }
    return 0;
  }
}

代码示例来源:origin: org.apache.hbase/hbase-common

@Override
public int encodedLength(T val) {
 return val.getSerializedSize();
}

代码示例来源:origin: com.baidu/brpc-java

@Override
public int getInputSerializedSize(Object input) throws IOException {
  if (input instanceof Message) {
    return ((Message) input).getSerializedSize();
  }
  return 0;
}

代码示例来源:origin: com.baidu/brpc-java

@Override
  public int getOutputSerializedSize(Object output) throws IOException {
    if (output instanceof Message) {
      return ((Message) output).getSerializedSize();
    }
    return 0;
  }
}

代码示例来源:origin: baidu/brpc-java

@Override
public int getInputSerializedSize(Object input) throws IOException {
  if (input instanceof Message) {
    return ((Message) input).getSerializedSize();
  }
  return 0;
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

@Override
public int encodedLength(T val) {
 return val.getSerializedSize();
}

代码示例来源:origin: org.apache.tajo/tajo-common

@Override
public int size() {
 return value.getSerializedSize();
}

代码示例来源:origin: com.twitter.elephantbird/elephant-bird-pig

@Override
 public long getMemorySize() {
  // The protobuf estimate is obviously inaccurate.
  return msg_.getSerializedSize() + realTuple.getMemorySize();
 }
}

代码示例来源:origin: io.hops/hadoop-common

private static int getDelimitedLength(Message message) {
 int length = message.getSerializedSize();
 return length + CodedOutputStream.computeRawVarint32Size(length);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Override
 public int getLength() {
  int resLen;
  if (theResponse != null) {
   resLen = theResponse.getSerializedSize();
  } else if (theResponseRead != null ) {
   resLen = theResponseRead.length;
  } else {
   throw new IllegalArgumentException(
     "getLength on uninitialized RpcWrapper");      
  }
  return CodedOutputStream.computeRawVarint32Size(resLen) + resLen;
 }
}

代码示例来源:origin: indeedeng/imhotep

public static void sendProtobuf(Message request, OutputStream os) throws IOException {
  os.write(Bytes.intToBytes(request.getSerializedSize()));
  request.writeTo(os);
  os.flush();
}

代码示例来源:origin: com.twitter.elephantbird/elephant-bird-core

protected void serialize() throws IOException {
 out_.write(Protobufs.KNOWN_GOOD_POSITION_MARKER);
 Message block = SerializedBlock
   .newInstance(innerClass_.getCanonicalName(),protoBlobs_)
   .getMessage();
 protoBlobs_ = new ArrayList<ByteString>(numRecordsPerBlock_);
 writeRawLittleEndian32(block.getSerializedSize());
 block.writeTo(out_);
}

代码示例来源:origin: io.hops/hadoop-common

@Override
void writeTo(ResponseBuffer out) throws IOException {
 int length = message.getSerializedSize();
 length += CodedOutputStream.computeRawVarint32Size(length);
 out.ensureCapacity(length);
 message.writeDelimitedTo(out);
}

相关文章