Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change 
notification.

The following page has been changed by NoblePaul:
http://wiki.apache.org/thrift/New_compact_binary_protocol

------------------------------------------------------------------------------
  ||Variable ints for string, binary, and collection sizes||Will often shrink 
to one or two bytes|| ||
  || Have two types BOOLEAN_TRUE and BOOLEAN_FALSE instead of type and value|| 
Save a byte on every boolean|| ||
  
+ === Better usage of type byte ===
+ If we spent one whole byte for type it is quite a waste considering we have 
~15 types . That is a wastage of almost 4 bits on EACH field. 
+ Let us have two types of types. One with extra information and one which does 
not . Let us take the 5 least significant bit (LSB) to represent them. Let us 
make use of the 3 most significant bits (MSB) for types with extra information 
+ 
+  ||<#FF8080>  7  ||<#FF8080>  6  ||<#FF8080>  5  ||<#80FF80>  4  ||<#80FF80>  
3  ||<#80FF80>  2  ||<#80FF80>  1  ||<#80FF80>  0  ||
+ 
+ The 5 LSB (green) could be used for these types 
+  # VOID
+  # STOP
+  # BOOLEAN_TRUE
+  # BOOLEAN_FALSE
+  # DOUBLE
+  # I16 
+  # I32 
+  # I64 
+ The 3 MSB (red) can be used for a max 7 types. The 5 MSB can be used in these 
types for length ,value etc (depending on the type)
+  # STRING 
+  # SET 
+  # LIST
+  # MAP
+  # POSITIVE_I32
+  # STRUCT
+  # EXTERN_STRING
+ 
  == Information sources ==
  [http://publists.facebook.com/pipermail/thrift/2008-January/000275.html 2008 
jan mail thread][[BR]]
  [https://issues.apache.org/jira/browse/THRIFT-110 jira ticket][[BR]]

Reply via email to