ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Tupitsyn <ptupit...@apache.org>
Subject Re: What is the purpose of a binary schema and schema registry?
Date Tue, 06 Feb 2018 08:28:24 GMT
Hi John,

BinarySchema is an optimization to make serialized objects more compact.
Schema is basically int[] containing field ids. Schemas are stored by id in
the cluster.
Serialized objects themselves contain only a set of field offsets
(basically int[] or short[] or byte[]).

So to get a value of a field with a given name:
1) Retrieve schema by id from cluster
2) Convert field name to field id (hash function)
3) Look up the index (idx) of that field id in the schema
4) Get the field position in the serialized object: fieldOffsets[idx]
5) Deserialize the data from that position

In the previous versions of the binary protocol we had schema embedded in
the objects
(e.g. each object contained a map from field id to offset).

But most objects have fields always serialized in the same order, so it
makes sense to avoid
duplicating the same data in every object.

To answer your questions:
1) Multiple schemas occur when object is serialized in multiple different
ways.
    For example, Binarylizable.writeBinary implementation may have some
conditional logic which causes
    different set of fields in various cases
2) Binary schema registry helps reducing serialized objects size by storing
common information

Pavel

On Mon, Feb 5, 2018 at 10:44 PM, John Wilson <sami.hailu.15@gmail.com>
wrote:

> Hi,
>
> When objects are marshaled, Ignites adds a schema (BinarySchema) to the
> BinarySchemaRegistry. Moreover, the documentation says that an object can
> have a few different schemas.
>
> My question:
>
>    1. What does it mean for an object to have multiple schemas? (e.g. for a
>    simple person object Person obj = new Person())
>    2. What is the purpose of the binary schema registry?
>
> Thanks,
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message