gRPC java does LongArrayList resize when deserializing?

Viewed 58

I'm using grpc 1.37.0 and Java. As far as I can see from the generated code, when doing deserialization on an int64 list as below, the code essentially creates an empty LongArrayList and adds to it.

My question is, does that have the resizing problem when deserializing the elements from the message? Just like now Java ArrayList needs to resize to twice as big and do a full copy, is that the same for gRPC LongArrayList?

For example my proto looks like below, when I'm sending a list of blockIDs from the server to client:

message BlockIdList {
  repeated int64 blockId = 1;
}

From the generated java code I can see below. I'm trying to read the code and trace down where the elements are added to blockId_ and see if resizing happened, but I was not able to find out. Could someone help point me to the correct direction?

class BlockIdList {
    private com.google.protobuf.Internal.LongList blockId_ = emptyLongList();

    // By the time I call getBlockIdList(), the list is already there
    // When were the elements added to the list?
    public java.util.List<java.lang.Long>
        getBlockIdList() {
      return ((bitField0_ & 0x00000001) != 0) ?
               java.util.Collections.unmodifiableList(blockId_) : blockId_;
    }

    // This size is known only after the list is completed?
    public int getBlockIdCount() {
      return blockId_.size();
    }
}
0 Answers
Related