[
https://issues.apache.org/jira/browse/THRIFT-110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625825#action_12625825
]
Johan Stuyts commented on THRIFT-110:
-------------------------------------
Exactly, you can use a single byte for lots of information:
- 0 = stop
- 1 = boolean false
- 2 = boolean true
- 3 = int
- 4 = vint >= 32 (followed by vint with value - 32)
- 5 = zig-zag int (possibly added to/subtracted from just like vint)
- 6 = string >= 64 bytes (followed by vint of length - 64 and the 64+ bytes)
- ...
- 64-127 = integers with values -32 to 31 (direct value)
- 128-191 = longs with values -32 to 31 (direct value)
- 192-255 = string lengths for UTF-8 strings with 0-31 bytes (followed by 0-31
bytes)
As you can see you can get pretty dense, and I am sure other people can come up
with an even better ways to encode values (e.g. maybe inline values -1 to 62
for integers is more effective).
Not having to choose the encoding in IDL also ensures that changes to the range
of valid values (e.g. allowing negative values for integers) will require no
changes to the IDL and deployed systems.
You might not be able to get as dense as with hints specified in the IDL, but I
think you can come close enough to the optimum. And protocols do not have to
contend for IDL keywords and type bits.
> A more compact format
> ----------------------
>
> Key: THRIFT-110
> URL: https://issues.apache.org/jira/browse/THRIFT-110
> Project: Thrift
> Issue Type: Improvement
> Reporter: Noble Paul
>
> Thrift is not very compact in writing out data as (say protobuf) . It does
> not have the concept of variable length integers and various other
> optimizations possible . In Solr we use a lot of such optimizations to make a
> very compact payload. Thrift has a lot common with that format.
> It is all done in a single class
> http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/common/util/NamedListCodec.java?revision=685640&view=markup
> The other optimizations include writing type/value in same byte, very fast
> writes of Strings, externalizable strings etc
> We could use a thrift format for non-java clients and I would like to see it
> as compact as the current java version
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.