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

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

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

Message.getSerializedSize介绍

暂无

代码示例

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

  1. @Override
  2. public int encodedLength(T val) {
  3. return val.getSerializedSize();
  4. }

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

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

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

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

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

  1. @Override
  2. void writeTo(ResponseBuffer out) throws IOException {
  3. int length = message.getSerializedSize();
  4. length += CodedOutputStream.computeRawVarint32Size(length);
  5. out.ensureCapacity(length);
  6. message.writeDelimitedTo(out);
  7. }

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

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

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

  1. private byte[] setupResponseForProtobuf(
  2. RpcResponseHeaderProto header, Writable rv) throws IOException {
  3. Message payload = (rv != null)
  4. ? ((RpcWritable.ProtobufWrapper)rv).getMessage() : null;
  5. int length = getDelimitedLength(header);
  6. if (payload != null) {
  7. length += getDelimitedLength(payload);
  8. }
  9. byte[] buf = new byte[length + 4];
  10. CodedOutputStream cos = CodedOutputStream.newInstance(buf);
  11. // the stream only supports little endian ints
  12. cos.writeRawByte((byte)((length >>> 24) & 0xFF));
  13. cos.writeRawByte((byte)((length >>> 16) & 0xFF));
  14. cos.writeRawByte((byte)((length >>> 8) & 0xFF));
  15. cos.writeRawByte((byte)((length >>> 0) & 0xFF));
  16. cos.writeRawVarint32(header.getSerializedSize());
  17. header.writeTo(cos);
  18. if (payload != null) {
  19. cos.writeRawVarint32(payload.getSerializedSize());
  20. payload.writeTo(cos);
  21. }
  22. return buf;
  23. }

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

  1. outputContainer.ensureSpace(response.getSerializedSize());

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

  1. @Override
  2. public int getOutputSerializedSize(Object output) throws IOException {
  3. if (output instanceof Message) {
  4. return ((Message) output).getSerializedSize();
  5. }
  6. return 0;
  7. }
  8. }

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

  1. @Override
  2. public int encodedLength(T val) {
  3. return val.getSerializedSize();
  4. }

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

  1. @Override
  2. public int getInputSerializedSize(Object input) throws IOException {
  3. if (input instanceof Message) {
  4. return ((Message) input).getSerializedSize();
  5. }
  6. return 0;
  7. }

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

  1. @Override
  2. public int getOutputSerializedSize(Object output) throws IOException {
  3. if (output instanceof Message) {
  4. return ((Message) output).getSerializedSize();
  5. }
  6. return 0;
  7. }
  8. }

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

  1. @Override
  2. public int getInputSerializedSize(Object input) throws IOException {
  3. if (input instanceof Message) {
  4. return ((Message) input).getSerializedSize();
  5. }
  6. return 0;
  7. }

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

  1. @Override
  2. public int encodedLength(T val) {
  3. return val.getSerializedSize();
  4. }

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

  1. @Override
  2. public int size() {
  3. return value.getSerializedSize();
  4. }

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

  1. @Override
  2. public long getMemorySize() {
  3. // The protobuf estimate is obviously inaccurate.
  4. return msg_.getSerializedSize() + realTuple.getMemorySize();
  5. }
  6. }

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

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

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

  1. @Override
  2. public int getLength() {
  3. int resLen;
  4. if (theResponse != null) {
  5. resLen = theResponse.getSerializedSize();
  6. } else if (theResponseRead != null ) {
  7. resLen = theResponseRead.length;
  8. } else {
  9. throw new IllegalArgumentException(
  10. "getLength on uninitialized RpcWrapper");
  11. }
  12. return CodedOutputStream.computeRawVarint32Size(resLen) + resLen;
  13. }
  14. }

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

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

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

  1. protected void serialize() throws IOException {
  2. out_.write(Protobufs.KNOWN_GOOD_POSITION_MARKER);
  3. Message block = SerializedBlock
  4. .newInstance(innerClass_.getCanonicalName(),protoBlobs_)
  5. .getMessage();
  6. protoBlobs_ = new ArrayList<ByteString>(numRecordsPerBlock_);
  7. writeRawLittleEndian32(block.getSerializedSize());
  8. block.writeTo(out_);
  9. }

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

  1. @Override
  2. void writeTo(ResponseBuffer out) throws IOException {
  3. int length = message.getSerializedSize();
  4. length += CodedOutputStream.computeRawVarint32Size(length);
  5. out.ensureCapacity(length);
  6. message.writeDelimitedTo(out);
  7. }

相关文章