protobuf: Implement repeated support for List/Set

Repeated fields are now supported for List<String>, Set<String>,
and List/Set of any protobuf encodable entity.  These repeated
columns work only in the protobuf model, and fail horribly if
used in a schema running on SQL.

This is a small hack to try and implement some simple encoding of
cache values for Gerrit Code Review, to support storing the cached
data into byte string based systems like the open source memcached,
without relying on expensive Java serialization.

As a side effect of this change, nested message support was rewritten
to acquire the ProtobufCodec for the nested message and reference
that instance through a static field.  This reduces the number of
times a common message's implementation exists in the JVM down to
only once, which may help the JIT to produce more optimal code.
It also can help to avoid costly field traversal on deeply nested
messages, as the message gets pushed onto the call stack rather
then being repeatedly fetched from the parent.

Invocation of the nested message encoders is made through
a type-specific overload of the generic Object based methods,
avoiding an unnecessary checkcast at runtime as the code enters
into the nested message.

Change-Id: I1a6f2ffc584adb8fda716edb7e42edd369e1f527
Signed-off-by: Shawn O. Pearce <sop@google.com>
7 files changed