Hessian 2.0
From Resin 3.0
Line 3: | Line 3: | ||
The current draft grammar is at [[Hessian 2.0 Grammar]] | The current draft grammar is at [[Hessian 2.0 Grammar]] | ||
− | Hessian 2.0 is in the very early stages. Feedback is welcome. | + | Hessian 2.0 is in the very early stages. Feedback is welcome. Some data on efficiency vs Java serialization is at [http://forum.caucho.com/node/52]forum.caucho.com/ |
= Non-Goals for Hessian 2.0 = | = Non-Goals for Hessian 2.0 = | ||
Line 75: | Line 75: | ||
= Encodings in Current [[Hessian 2.0 Grammar]] draft = | = Encodings in Current [[Hessian 2.0 Grammar]] draft = | ||
+ | |||
+ | == 32-bit integers == | ||
+ | |||
+ | Direct integers: | ||
+ | |||
+ | 0x80 - 0xcf | ||
+ | |||
+ | The codes between 0x80 and 0xcf represent integers between -16 and 63, i.e. <code>code - 0x90</code> |
Revision as of 21:10, 23 June 2006
The current draft grammar is at Hessian 2.0 Grammar
Hessian 2.0 is in the very early stages. Feedback is welcome. Some data on efficiency vs Java serialization is at [1]forum.caucho.com/
Contents |
Non-Goals for Hessian 2.0
We are not planning on any semantic additions or changes for Hessian 2.0. The current datatype and object model is intended to remain the same.
The only changes planned are extra compact encodings for better serialization and performance.
Goals for Hessian 2.0
Hessian 2.0 will be interoperable with Hessian 2.0
A Hessian 1.0 client can talk to any Hessian 2.0 server and receive a Hessian 1.0 response.
A Hessian 2.0 client can use Hessian 1.0 encoding to a server, but indicate that it can upgrade to Hessian 2.0 encoding.
Small number compression
In Hessian 1.0, all 32-bit integers are encoded in 5 bytes: 'I' b3 b2 b1 b0.
Most integers in actual data tends to be small. "0" is the most common integer value and "1" is the next most common value.
Small integers will be encoded in the single lead-byte, e.g. 0x90 might represent integer 0.
Bytes can be encoded in two bytes, e.g. x51 b0. Shorts encoded in three bytes e.g. x53 b1.
Similarly, small longs will have short encodings, and integer-valued doubles also have short encodings.
Short string compression
In Hessian 1.0, strings have a 3-byte overhead, 'S' b1 b0 data.
Hessian 2.0 will encode small strings with only a 1-byte overhead, e.g.
x25 hello
Object definition and instance
Hessian 1.0 encodes objects as associative arrays, where the keys correspond to fields, e.g.
M t x00 x08 test.Car S x00 x05 model S x00 x05 Honda S x00 x04 make S x00 x05 Civic S x00 x05 color S x00 x03 red z
When multiple Car objects are serialized, Hessian 1.0 has unnecessary overhead of duplicating the "test.Car", the "model", the "make", and the "color" strings, even though those fields are unchanged for all Cars.
Hessian 2.0 will have an Object definition/instance, which is equivalent to the above map
O x98 test.Car -- code and type/class x93 -- number of fields encoded as an integer xd5 model -- short string xd4 make xd5 color xd5 Honda -- data for first object follows immediately xd5 Civic xd3 red
A following car would look like:
o x91 -- integer representing defined object xda Volkswagen xd6 Beetle xd4 blue
Encodings in Current Hessian 2.0 Grammar draft
32-bit integers
Direct integers:
0x80 - 0xcf
The codes between 0x80 and 0xcf represent integers between -16 and 63, i.e. code - 0x90