...
The purpose of this document to describe the native serialization of a various data type types which Geode understandsunderstand.
Data Types
Geode supports all the Java primitive data types and Java arrays and collections.. Custom Java object objects can be serialized through Geode PdxSerializable and DataSerializable interfaces. The Application can attach its data serializer through Geode the Geode DataSerializer
and Geode PdxSerializer interface. Using Geode, the application can also serialize arrays of primitive Java types and Java collections. It also understands the Java Serializable and PdxSerializer
interfaces. Objects implementing java.io.Serializable
can be serialized with Geode as well.
In Geode, every supported data type is associated with type Id. Type Id is represented by one bytea single-byte type Id. To serialize any date type Geode first writes the typeId. Then For variable sized objects, it then writes the length of serialized byte for variable typesthe serialized object followed by the serialized bytes. For fixed data types it just writes those the serialized bytes in the Big Indian Endian byte order.
For native serialization, strings are serialized using the Java Modified UTF-8 Format.
Data Type | Geode Region Key Types | Type Id | Value | Serialized Bytes | Description |
---|
Null | | 41 = 0x29 | null | | |
Boolean | YES | 53 = 0x35 | true | | |
Character | YES | 54 = 0x36 | 'a' | | |
Byte | YES | 55 = 0x37 | 1 | | |
Short | YES | 56 = 0x38 | 1000 | | |
Integer | YES | 57 = 0x39 | 1000 | typeId | 0x39 |
---|
bytes | 0x00 0x00 0x03 0xE8 |
| |
Long | YES | 58 = 0x3A | 1000 | typeId | 0x3A |
---|
bytes | 0x00 0x00 0x00 0x00 0x00 0x00 0x03 0xE8 |
| |
Float | YES | 59 = 0x3B | 1000f | typeId | 0x3B |
---|
bytes | 0x44 0x7A 0x00 0x00 |
| |
Double | YES | 60 = 0x3C | 1000d |
typeId | 0x3C |
---|
bytes | 0x40 0xF1 0x40 0x00 0x00 0x00 0x00 0x00 |
| |
ASCII_STRING | YES | 87 = 0x57 | "hello" | typeid | 0x57 |
---|
len | 0x00 0x05 | bytes | 0x68 0x65 0x40 0x40 0x6F |
| This represents ASCII string with maximum length 0xFFFF. Code snippet to serialize and deserialize the string. |
UTF_STRING | YES | 42 = 0x2A | | | This represents UTF string with maximum length 0xFFFF. Code snippet to serialize and deserialize the string. |
HUGE_ASCII_STRING | YES | 88 = 0x58 | | | This represents ASCII string with length greater than 0xFFFF. Code snippet to serialize and deserialize the string. |
HUGE_UTF_STRING | YES | 89 = 0x59 | | | This represents UTF string with length greater than 0xFFFF. Code snippet to serialize and deserialize the string. |
byte[] | YES (This we plan to support) | 46 = 0x2E | byte[] {1,2} | typeId | 0x2E |
---|
len | 0x02 | bytes | 0x01 0x02 |
| |
short[] | | 47 = 0x2F | short[] {1,2} | typeId | 0x2F |
---|
len | 0x02 | bytes | 0x00 0x01 0x00 0x02 |
| |
int[] | | 48 = 0x30 | int[] {1,2} | typeId | 0x30 |
---|
len | 0x02 | bytes | 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x02 |
| |
long[] | | 49 = 0x31 | long[] {1} | typeId | 0x31 |
---|
len | 0x01 | bytes | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 |
| |
float[] | | 50 = 0x32 | float[] {2.0f} | typeId | 0x32 |
---|
len | 0x01 | bytes | 0x40 0x00 0x00 0x00 |
| |
double[] | | 51 = 0x33 | double[] {2.0d} | typeId | 0x33 |
---|
len | 0x01 | bytes | 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 |
| |
string[] | | 64 = 0x40 | String[]{"hello", "world"} | typeId | 0x40 |
---|
len | 0x02 | "hello" bytes | 0x57 - ASCII_STRING 0x00 0x05 0x68 0x65 0x6c 0x6c 0x6f | "world" bytes | 0x57 - ASCII_STRING 0x00 0x05 - len 0x77 0x6f 0x72 0x6c 0x64
|
| |
Map | | 67 = 0x43 | Map s = new HashMap<>(); s.put("hello", "world") | typeId | 0x43 |
---|
len | 0x01 | "hello" bytes | 0x57 - ASCII_STRING 0x00 0x05 0x68 0x65 0x6c 0x6c 0x6f | "world" bytes | 0x57 - ASCII_STRING 0x00 0x05 - len 0x77 0x6f 0x72 0x6c 0x64 |
| |
Set | | 66 = 0x42 | Set s = new HashSet(); s.add("hello"); s.add("world");
| typeId | 0x42 |
---|
len | 0x02 | "hello" bytes | 0x57 - ASCII_STRING 0x00 0x05 0x68 0x65 0x6c 0x6c 0x6f | "world" bytes | 0x57 - ASCII_STRING 0x00 0x05 - len 0x77 0x6f 0x72 0x6c 0x64 |
| |
List | | 10 = 0x0a | List s = new LinkedList(); s.add("hello"); s.add("world"); | typeId | 0x0a |
---|
len | 0x02 | "hello" bytes | 0x57 - ASCII_STRING 0x00 0x05 0x68 0x65 0x6c 0x6c 0x6f | "world" bytes | 0x57 - ASCII_STRING 0x00 0x05 - len 0x77 0x6f 0x72 0x6c 0x64 |
| |
ArrayList | | 65=0x41 | List s = new ArrayList(); s.add("hello"); s.add("world"); | typeId | 0x41 |
---|
len | 0x02 | "hello" bytes | 0x57 - ASCII_STRING 0x00 0x05 0x68 0x65 0x6c 0x6c 0x6f | "world" bytes | 0x57 - ASCII_STRING 0x00 0x05 - len 0x77 0x6f 0x72 0x6c 0x64 |
| |
PDX_SERIALIZATION | | 93=0x5D | | | Java Object can implement PdxSerializable interface to serialize data in pdx format |
PDX_SERIALIZER | | | | | The application can implement PdxSerializer interface and then install with geode cache to serialize data in pdx format. |
DATA_SERIALIZATION | | | | | Java Object can implement DataSerializable interface to serialize data. |
USER_SERIALIZATION | | | | | The application can implement DataSerializer interface and then install with geode cache to serialize data. |
JAVA_SERIALIZATIOn | 44= 0x2C | |
Key Data Types
...
Calculate Collection/Array Size
...