Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • We save object field IDs and offsets to array during write. When all fields are written, we simply copy this array to object footer in a single System.arrayCopy() or Unsafe.copyMemory() operation. To minimize GC garbage we can use thread-local array instead of "new byte[]";
  • If new schema is detected at the end of object write, it is added to the list of known object schemas.
  • If collision is detected on (schema ID, fields count) pair, we throw an excpetion in the same way as if we had field ID conflict. This should be very unlikely event. N.B.: we can support collisions with some additional computational overhead.

No or almost no additional overhead is expected comparing to Ignite 1.4.

Object read

  • First of all we check Check if object's schema is known. If . Normally this will require only 1-2 int comparisons. If no, we scan the whole object, create the schema and save it.
  • Until object read schema matches object write schema, we just read the object sequentially. Schema matching is performed using reference string equality as field names are usually interned literals. In case of failed comparison we fallback to normal "String.equals()".
  • If read/write schemas mismatch is detected, we fallback to random field read. Normally mismatch will only occur if different object versions co-exist in runtime. 

No additional overhead is expected comparing to Ignite 1.4.

Random object field read

  • Check if object's schema is known. Normally this will require only 1-2 int comparisons;. If no, we scan the whole object, create the schema and save it.
  • Field name is converted to field ID as usual;
  • Schema is queried for footer offset for this field ID order. We need to evaluate possible techniques for fast int lookup: normal HashMap, open-addressing like in ThreadLocal's, specialized int-int maps. Anyways, even HashMap should usually sustain 0(1) complexity;
  • Go to footer and get field offset: FieldOffset = valueOf(FooterOffset + SchemaFieldIdOffsetFieldIdOrder * 8);
  • Use FIeldOffset to get the field.

...