blob: 5efba97923fb3b6c7c8f3658153b7572973f79ff [file] [log] [blame]
---
title: How Serialization Works with IDataSerializable
---
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
When your application puts an object into the cache for distribution, <%=vars.product_name%> serializes the data by taking these steps.
1. Calls the appropriate `ClassId` function and creates the `TypeId` from it.
2. Writes the `TypeId` for the instance.
3. Invokes the `ToData` function for the instance.
When your application subsequently receives a byte array, <%=vars.product_name%> takes the following steps:
1. Decodes the `TypeId` and creates an object of the designated type, using the registered factory functions.
2. Invokes the `FromData` function with input from the data stream.
3. Decodes the data and then populates the data fields.
The `TypeId` is an integer of four bytes, which is a combination of `ClassId` integer and `0x27`, which is an indicator of user-defined type.