java类com.google.protobuf.CodedOutputStream的实例源码

Mumble.java 文件源码 项目:grumble 阅读 21 收藏 0 点赞 0 评论 0
public int getSerializedSize() {
    int size = memoizedSerializedSize;
    if (size != -1) return size;

    size = 0;
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        size += CodedOutputStream
                .computeBytesSize(1, getActionBytes());
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
        size += CodedOutputStream
                .computeBytesSize(2, getTextBytes());
    }
    if (((bitField0_ & 0x00000004) == 0x00000004)) {
        size += CodedOutputStream
                .computeUInt32Size(3, context_);
    }
    if (((bitField0_ & 0x00000008) == 0x00000008)) {
        size += CodedOutputStream
                .computeEnumSize(4, operation_.getNumber());
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSerializedSize = size;
    return size;
}
Mumble.java 文件源码 项目:grumble 阅读 20 收藏 0 点赞 0 评论 0
public int getSerializedSize() {
    int size = memoizedSerializedSize;
    if (size != -1) return size;

    size = 0;
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        size += CodedOutputStream
                .computeUInt32Size(1, session_);
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
        size += CodedOutputStream
                .computeUInt32Size(2, channelId_);
    }
    if (((bitField0_ & 0x00000004) == 0x00000004)) {
        size += CodedOutputStream
                .computeBytesSize(3, getActionBytes());
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSerializedSize = size;
    return size;
}
Mumble.java 文件源码 项目:grumble 阅读 22 收藏 0 点赞 0 评论 0
public int getSerializedSize() {
    int size = memoizedSerializedSize;
    if (size != -1) return size;

    size = 0;
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        size += CodedOutputStream
                .computeUInt32Size(1, userId_);
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
        size += CodedOutputStream
                .computeBytesSize(2, getNameBytes());
    }
    if (((bitField0_ & 0x00000004) == 0x00000004)) {
        size += CodedOutputStream
                .computeBytesSize(3, getLastSeenBytes());
    }
    if (((bitField0_ & 0x00000008) == 0x00000008)) {
        size += CodedOutputStream
                .computeUInt32Size(4, lastChannel_);
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSerializedSize = size;
    return size;
}
Mumble.java 文件源码 项目:grumble 阅读 28 收藏 0 点赞 0 评论 0
public int getSerializedSize() {
    int size = memoizedSerializedSize;
    if (size != -1) return size;

    size = 0;
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        size += CodedOutputStream
                .computeUInt32Size(1, id_);
    }
    for (int i = 0; i < targets_.size(); i++) {
        size += CodedOutputStream
                .computeMessageSize(2, targets_.get(i));
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSerializedSize = size;
    return size;
}
Mumble.java 文件源码 项目:grumble 阅读 24 收藏 0 点赞 0 评论 0
public void writeTo(CodedOutputStream output)
        throws IOException {
    getSerializedSize();
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        output.writeInt32(1, alpha_);
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
        output.writeInt32(2, beta_);
    }
    if (((bitField0_ & 0x00000004) == 0x00000004)) {
        output.writeBool(3, preferAlpha_);
    }
    if (((bitField0_ & 0x00000008) == 0x00000008)) {
        output.writeBool(4, opus_);
    }
    getUnknownFields().writeTo(output);
}
Mumble.java 文件源码 项目:grumble 阅读 21 收藏 0 点赞 0 评论 0
public int getSerializedSize() {
    int size = memoizedSerializedSize;
    if (size != -1) return size;

    size = 0;
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        size += CodedOutputStream
                .computeInt32Size(1, alpha_);
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
        size += CodedOutputStream
                .computeInt32Size(2, beta_);
    }
    if (((bitField0_ & 0x00000004) == 0x00000004)) {
        size += CodedOutputStream
                .computeBoolSize(3, preferAlpha_);
    }
    if (((bitField0_ & 0x00000008) == 0x00000008)) {
        size += CodedOutputStream
                .computeBoolSize(4, opus_);
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSerializedSize = size;
    return size;
}
Mumble.java 文件源码 项目:grumble 阅读 22 收藏 0 点赞 0 评论 0
public void writeTo(CodedOutputStream output)
        throws IOException {
    getSerializedSize();
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        output.writeUInt32(1, good_);
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
        output.writeUInt32(2, late_);
    }
    if (((bitField0_ & 0x00000004) == 0x00000004)) {
        output.writeUInt32(3, lost_);
    }
    if (((bitField0_ & 0x00000008) == 0x00000008)) {
        output.writeUInt32(4, resync_);
    }
    getUnknownFields().writeTo(output);
}
NestedSetCodec.java 文件源码 项目:bazel 阅读 20 收藏 0 点赞 0 评论 0
private void serializeOneNestedSet(
    Object children, CodedOutputStream codedOut, Map<Object, byte[]> childToDigest)
    throws IOException, SerializationException {
  // Serialize nested set into an inner byte array so we can take its digest
  ByteArrayOutputStream childOutputStream = new ByteArrayOutputStream();
  HashingOutputStream hashingOutputStream =
      new HashingOutputStream(Hashing.md5(), childOutputStream);
  CodedOutputStream childCodedOut = CodedOutputStream.newInstance(hashingOutputStream);
  if (children instanceof Object[]) {
    serializeMultiItemChildArray((Object[]) children, childToDigest, childCodedOut);
  } else if (children != NestedSet.EMPTY_CHILDREN) {
    serializeSingleItemChildArray(children, childCodedOut);
  } else {
    // Empty set
    childCodedOut.writeInt32NoTag(0);
  }
  childCodedOut.flush();
  byte[] digest = hashingOutputStream.hash().asBytes();
  codedOut.writeByteArrayNoTag(digest);
  byte[] childBytes = childOutputStream.toByteArray();
  codedOut.writeByteArrayNoTag(childBytes);
  childToDigest.put(children, digest);
}
Mumble.java 文件源码 项目:grumble 阅读 19 收藏 0 点赞 0 评论 0
public void writeTo(CodedOutputStream output)
        throws IOException {
    getSerializedSize();
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
        output.writeUInt32(1, maxBandwidth_);
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
        output.writeBytes(2, getWelcomeTextBytes());
    }
    if (((bitField0_ & 0x00000004) == 0x00000004)) {
        output.writeBool(3, allowHtml_);
    }
    if (((bitField0_ & 0x00000008) == 0x00000008)) {
        output.writeUInt32(4, messageLength_);
    }
    if (((bitField0_ & 0x00000010) == 0x00000010)) {
        output.writeUInt32(5, imageMessageLength_);
    }
    getUnknownFields().writeTo(output);
}
ProtobufVarint32LengthFieldPrepender.java 文件源码 项目:wecard-server 阅读 17 收藏 0 点赞 0 评论 0
@Override
protected void encode(
        ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
    int bodyLen = msg.readableBytes();
    int headerLen = CodedOutputStream.computeRawVarint32Size(bodyLen);
    out.ensureWritable(headerLen + bodyLen);

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

    out.writeBytes(msg, msg.readerIndex(), bodyLen);
}


问题


面经


文章

微信
公众号

扫码关注公众号