blob: c77603e466c01bbf219efa4174cb8f69186eb81a [file] [log] [blame]
---
title: Register the Type
---
<!--
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.
-->
To use the `BankAccount` type, you must register it with the type system. Then, when an incoming stream contains a `BankAccount`, it can be manufactured from the associated `TypeFactoryMethod.`
``` pre
Serializable.RegisterType(BankAccount.CreateInstance);
```
Typically, you would register the type before creating the system.
## <a id="concept_FFFB0AAA131E46D09065F910EFF218CB__section_1B68CDA7392E45CAA413362F42CCF829" class="no-quick-link"></a>Using ClassId
A `ClassId` is an integer that returns the `ClassId` of the instance being serialized. The `ClassId` is used by deserialization to determine what instance type to create and deserialize into.
## <a id="concept_FFFB0AAA131E46D09065F910EFF218CB__section_8A63DBA039744DCCB6840A7F1F5734DA" class="no-quick-link"></a>Using DSFID
A `DSFID` is an integer that returns the data serialization fixed ID type. `DSFID` is used to determine what instance type to create and deserialize into. `DSFID` should not be overridden by custom implementations, and it is reserved only for built-in serializable types.
## <a id="concept_FFFB0AAA131E46D09065F910EFF218CB__section_A02B5E61D03B4B0893DFF3D21F2346F9" class="no-quick-link"></a>Using Custom Key Types
If your application uses its own key types that are too complex to easily force into strings, you can probably improve performance by using a custom type and implementing `HashCode` and `Equals` functions. For example, if you have hybrid data types such as floating point numbers, you can implement your own type that encapsulates the floating point number. Comparing floating point numbers in this way provides better performance than comparing a string representation of the floating point numbers, with such noticeable improvements as faster cache access and smaller payloads.
See [Serialization in Native Client Mode with a Java Server](../cpp-caching-api/serialization-using-serializable.html#concept_696AB5206C3E45898CC1A24CDD93D003__section_AFB685227E4048BF9FB4FD7C55AED274) for information about implementing key types for a client that is used with a Java cache server.
To extend a type that implements `IPdxSerializable` or `IDataSerializable` for your key, override and implement the `HashCode` and `Equals` methods in the key as needed.