You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

 

Purpose 

The purpose of this document to describe serialization of a various data type which Geode understands. 

Data Types

Geode supports all the Java primitive data types. Custom Java object can be serialized through Geode PdxSerializable and DataSerializable interfaces. The Application can attach its own data serializer through 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.

In Geode, every supported data type is associated with type Id. Type Id is represented by one byte. To serialize any date type Geode first writes the typeId. Then it writes the length of serialized byte for variable types. For fixed data types it just write those bytes in the Big Indian byte order.

 

Data TypeType IdValueSerialized BytesDescription
Null41 = 0x29null
typeID0x29
 
Boolean 53 = 0x35true
typeId0x35
bytes0x01
 
Character 54 = 0x36'a'
typeId0x36
  
 
Byte 55 = 0x37 
typeId0x37
  
 
Short 56 = 0x38 
typeId0x38
  
 
Integer 57 = 0x39 
typeId0x39
  
 
Long 58 = 0x3A 
typeId0x3A
  
 
Float 59 = 0x3B 
typeId0x3B
  
 
Double 60 = 0x3C 



typeId0x3C
  
 
String87 = 0x57"hello"
typeid0x57
len0x00 0x05
bytes0x68 0x65 0x40 0x40 0x6F
 
UTF_STRING 42 = 0x2A   
HUGE_STRING 88 = 0x58   
HUGE_UTF_STRING 89 = 0x59   
byte[] 46 = 0x2E 
typeId0x2E
  
 
short[]47 = 0x2F 
typeId0x2F
  
 
int[]48 = 0x30 
typeId0x30
  
 
long[]49 = 0x31 
typeId0x31
  
 
float[]50 = 0x32 
typeId0x32
  
 
double[]51 = 0x33 
typeId0x33
  
 
string[]64 = 0x40 
typeId0x40
  
 
Map67 = 0x43 
typeId0x43
  
 
Set66 = 0x42 
typeId0x42
  
 
List  
  
  
 
ArrayList  
  
  
 
PDX_SERIALIZATION    
PDX_SERIALIZER    
DATA_SERIALIZATION     
USER_SERIALIZATION     

 



 

  1. Null (41 = 0x29): Null object will be represented by single byte.

 

 

0x41 (typeid)

 


  1. Boolean (53 = 0x35) : Boolean object will be represented by typeId and value byte. Following demonstrate the serialize representation boolean value true.

 

 

0x52 (typeid)

0x01

 


  1. Character (54 = 0x36) : Character object will be represented by typeId and two bytes. Following demonstrate the serialize representation of character ‘a’.

 

 

0x54 (typeid)

0x00

0x61

 


  1. Byte (55 = 0x37) : Byte object will represted by typeId and  value byte. Following demonstrate the serialize representation of 1’.

 

 

0x55 (typeid)

0x01

 


  1. Short (56 = 0x38): Following will be serialized representation of 1000(0x3E8)


 

0x38 (typeid)

0x03

0xE8

 

 

  1. Integer (57 = 0x39): Following will be serialized representation of 1000(0x3E8)

 

 

0x39

0x00

0x00

0x03

0xE8

 


  1. Long (58 = 0x3A): Following will be serialized representation of 1000(0x3E8)

 

 

0x58

0x00

0x00

0x00

0x00

0x00

0x00

0x03

0xE8

 


  1. Float (59 = 0x3B)

 float s = 1000f;

[59, 68, 122, 0, 0]

 

 

0x3B (typeid)

0x44

0x7A

0x00

0x00

 


  1. Double (60 = 0x3C)

 double s = 1000d;

 [60, 64, -113, 64, 0, 0, 0, 0, 0]

 

 

0x3C

0x40

0xF1

0x40

0x00

0x00

0x00

0x00

0x00

 


  1. String (42 = 0x2A)

    1. STRING (87 = 0x57) ASCII; Length is 2 bytes

String s = "hello";

 [87, 0, 5, 104, 101, 108, 108, 111]

 

 

0x57

0x00(len)

0x05(len)

0x68

0x65

0x40

0x40

0x6F

 


    1. HUGE_STRING (88 = 0x58) ASCII Length is 4 bytes

    2. UTF_STRING (42 = 0x2A) UTF; Length is 2 bytes

    3. HUGE_UTF_STRING (89 = 0x59) UTF; Length is 4 bytes

  1. Array (52 = 0x34) ??

  2. BYTE_ARRAY (46 = 0x2E)

 byte[] {1,2};

 

 

0x2E

0x02(len)

0x01

0x02

 


  1. SHORT_ARRAY (47 = 0x2F)

 short[] {1,2};

 

 

0x2F

0x02(len)

0x00

0x01

0x00

0x02

 


  1. INTEGER_ARRAY (48 = 0x30)

 int[] {1,2};

 

 

0x30

0x02(len)

0x00

0x00

0x00

0x01

0x00

0x00

0x00

0x02

 


  1. LONG_ARRAY (49 = 0x31)

 long[] {1};

 

 

0x31

0x01(len)

0x00

0x00

0x00

0x00

0x00

0x00

0x00

0x01

 


  1. FLOAT_ARRAY (50 = 0x32)

 float[] {2.0f};

 

 

0x32

0x01(len)

0x40

0x00

0x00

0x00

 


  1. DOUBLE_ARRAY (51 = 0x33)

 double[] {2.0d}

 

 

0x33

0x01(len)

0x40

0x00

0x00

0x00

0x00

0x00

0x00

0x00

 


  1. STRING_ARRAY (64 = 0x40)

 String[] s = new String[]{"hello", "world"};

 [64, 2, 87, 0, 5, 104, 101, 108, 108, 111, 87, 0, 5, 119, 111, 114, 108, 100]

  1. Map (67 = 0x43)

 Map s = new HashMap<>();

    s.put("hello", "world");

 [67, 1, 87, 0, 5, 104, 101, 108, 108, 111, 87, 0, 5, 119, 111, 114, 108, 100]

  1. Set (66 = 0x42)

 Set s = new HashSet();

    s.add("hello");

    s.add("world");

 [66, 2, 87, 0, 5, 119, 111, 114, 108, 100, 87, 0, 5, 104, 101, 108, 108, 111]

  1. List

  2. ArrayList

  3. JSON_STRING ??

  4. JSON_BYTE_ARRAY ??

  5. PDX_SERIALIZATION (93 = 0x5D)

  6. DATA_SERIALIZATION (37 = 0x25)

  7. USER_SERIALIZATION (40 = 0x28)

  • No labels