Examples of writeRawVarint32()


Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

      // if exists, write data body and tag.
      if(msg.getRawBodySize() > 0){
        if(RpcConstants.EXTRA_DEBUGGING) logger.debug("Writing raw body of size {}", msg.getRawBodySize());
       
        cos.writeRawVarint32(RAW_BODY_TAG);
        cos.writeRawVarint32(rawBodyLength);
        cos.flush(); // need to flush so that dbody goes after if cos is caching.
       
        CompositeByteBuf cbb = new CompositeByteBuf(buf.alloc(), true, msg.dBodies.length + 1);
        cbb.addComponent(buf);
        int bufLength = buf.readableBytes();
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

    final int vlen = CodedOutputStream.computeRawVarint32Size(pblen);
    final byte[] buf = new byte[4 + 19 + method.length + vlen + pblen];
    try {
      final CodedOutputStream out = CodedOutputStream.newInstance(buf, 4 + 19 + method.length,
                                                                  vlen + pblen);
      out.writeRawVarint32(pblen);
      pb.writeTo(out);
      out.checkNoSpaceLeft();
    } catch (IOException e) {
      throw new RuntimeException("Should never happen", e);
    }
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

        int headerLen = CodedOutputStream.computeRawVarint32Size(bodyLen);
        out.ensureWritable(headerLen + bodyLen);

        CodedOutputStream headerOut =
                CodedOutputStream.newInstance(new ByteBufOutputStream(out));
        headerOut.writeRawVarint32(bodyLen);
        headerOut.flush();

        out.writeBytes(msg, msg.readerIndex(), bodyLen);
    }
}
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

      } else if (t instanceof Boolean) {
         out.writeBool(wrappedBool, (Boolean) t);
      } else if (t instanceof byte[]) {
         byte[] bytes = (byte[]) t;
         out.writeTag(wrappedBytes, WireFormat.WIRETYPE_LENGTH_DELIMITED);
         out.writeRawVarint32(bytes.length);
         out.writeRawBytes(bytes);
      } else if (t instanceof Enum) {
         // use an enum encoder
         EnumEncoder enumEncoder = ctx.getEnumEncoder((Class<Enum>) t.getClass());
         out.writeString(wrappedDescriptorFullName, enumEncoder.getFullName());
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

  }
 
  private void doVarIntTest(int value) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CodedOutputStream cout = CodedOutputStream.newInstance(baos);
    cout.writeRawVarint32(value);
    cout.flush();

    DataInputStream dis = new DataInputStream(
        new ByteArrayInputStream(baos.toByteArray()));
    assertEquals(value, ProtoUtil.readRawVarint32(dis));
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

            channel.getConfig().getBufferFactory().getBuffer(
                    body.order(),
                    CodedOutputStream.computeRawVarint32Size(length));
        CodedOutputStream codedOutputStream = CodedOutputStream
                .newInstance(new ChannelBufferOutputStream(header));
        codedOutputStream.writeRawVarint32(length);
        codedOutputStream.flush();
        return wrappedBuffer(header, body);
    }

}
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

  }
 
  private void doVarIntTest(int value) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CodedOutputStream cout = CodedOutputStream.newInstance(baos);
    cout.writeRawVarint32(value);
    cout.flush();

    DataInputStream dis = new DataInputStream(
        new ByteArrayInputStream(baos.toByteArray()));
    assertEquals(value, ProtoUtil.readRawVarint32(dis));
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

        protobufOut.writeRawByte(Constants.VERSION_1_FULL_RES);

        switch (type) {
            case Constants.B_I32:
                protobufOut.writeRawByte(type);
                protobufOut.writeRawVarint32((Integer) o);
                break;
            case Constants.B_I64:
                protobufOut.writeRawByte(type);
                protobufOut.writeRawVarint64((Long) o);
                break;
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

        CodedOutputStream out = CodedOutputStream.newInstance(buf);
        CounterRollupSize.update(buf.length);
        out.writeRawByte(Constants.VERSION_1_COUNTER_ROLLUP);
        putUnversionedDoubleOrLong(rollup.getCount(), out);
        out.writeDoubleNoTag(rollup.getRate());
        out.writeRawVarint32(rollup.getSampleCount());
    }
   
    private static CounterRollup deserializeV1CounterRollup(CodedInputStream in) throws IOException {
        Number value = getUnversionedDoubleOrLong(in);
        double rate = in.readDouble();
View Full Code Here

Examples of com.google.protobuf.CodedOutputStream.writeRawVarint32()

   
    private static void serializeSetRollup(SetRollup rollup, byte[] buf) throws IOException {
        CodedOutputStream out = CodedOutputStream.newInstance(buf);
        SetRollupSize.update(buf.length);
        out.writeRawByte(Constants.VERSION_1_SET_ROLLUP);
        out.writeRawVarint32(rollup.getCount());
        for (Integer i : rollup.getHashes()) {
            out.writeRawVarint32(i);
        }
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.