Skip to content

Commit dcac428

Browse files
authored
ObjectType field values needs to be described (#359)
* Added more description of what the ObjectType fields can be. Some typing fixes are done.
1 parent 2a7db90 commit dcac428

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* [Custom Serialization](#custom-serialization)
2222
* [Polymorphic Types Serialization](#polymorphic-types-serialization)
2323
* [Raw Pointer API](#raw-pointer-api)
24-
* [Mixed Object Types Supporting HazelcastClient](#mixed-object-types-supporting-hazelcastClient)
24+
* [Mixed Object Types Supporting HazelcastClient](#mixed-object-types-supporting-hazelcastclient)
2525
* [TypedData API](#typeddata-api)
2626
* [Query API](#query-api)
2727
* [Ringbuffer](#ringbuffer)
@@ -183,10 +183,10 @@ You can use Native C++ Client to connect to Hazelcast cluster members and perfor
183183

184184
The features of C++ Clients are listed below:
185185

186-
- Access to distributed data structures (IMap, IQueue, MultiMap, ITopic, etc.).
187-
- Access to transactional distributed data structures (TransactionalMap, TransactionalQueue, etc.).
186+
- Access to distributed data structures (`IMap`, `IQueue`, `MultiMap`, `ITopic`, etc.).
187+
- Access to transactional distributed data structures (`TransactionalMap`, `TransactionalQueue`, etc.).
188188
- Ability to add cluster listeners to a cluster and entry/item listeners to distributed data structures.
189-
- Distributed synchronization mechanisms with ILock, ISemaphore and ICountDownLatch.
189+
- Distributed synchronization mechanisms with `ILock`, `ISemaphore` and `ICountDownLatch`.
190190

191191

192192
# Setting Up the Client
@@ -321,11 +321,11 @@ registerSerializer(boost::shared_ptr<hazelcast::client::serialization::StreamSer
321321
```
322322

323323
## Polymorphic Types Serialization
324-
The client library can handle polymorphic objects such that you can use a base class type structure, such as IMap, you can put and get derived types. This support exists for IdentifiedDataSerializable, Portable and Custom objects.
324+
The client library can handle polymorphic objects such that you can use a base class type structure, such as `IMap`, you can put and get derived types. This support exists for `IdentifiedDataSerializable`, `Portable` and custom objects.
325325

326326
You can find the polymorphic usage examples at examples/distributed-map/mixed-map folder.
327327

328-
For IdentifiedDataSerializable objects, you need to register a factory implementation of type serialization::DataSerializableFactory. See the below example:
328+
For `IdentifiedDataSerializable` objects, you need to register a factory implementation of type `serialization::DataSerializableFactory`. See the below example:
329329
```
330330
class PolymorphicDataSerializableFactory : public serialization::DataSerializableFactory {
331331
public:
@@ -352,7 +352,7 @@ public:
352352
new PolymorphicDataSerializableFactory()));
353353
```
354354

355-
Similarly for Portable types you need to register a factory of type serialization::PortableFactory.
355+
Similarly for `Portable` types you need to register a factory of type `serialization::PortableFactory`.
356356
```
357357
serializationConfig.addPortableFactory(666, boost::shared_ptr<serialization::PortableFactory>(
358358
new PolymorphicPortableFactory));
@@ -436,13 +436,13 @@ value = vals->get(0);
436436
Using raw pointer based API may improve performance if you are using the API to return multiple values such as values, keySet, and entrySet. In this case, cost of deserialization is delayed until the item is actually accessed.
437437

438438
# Mixed Object Types Supporting HazelcastClient
439-
Sometimes, you may need to use Hazelcast data structures with objects of different types. For example, you may want to put int, string, identifieddataserializable, etc. objects into the same Hazelcast IMap data structure. You can do this by using the mixed type adopted HazelcastClient. You can adopt the client in this way:
439+
Sometimes, you may need to use Hazelcast data structures with objects of different types. For example, you may want to put `int`, `string`, `IdentifiedDataSerializable`, etc. objects into the same Hazelcast `IMap` data structure. You can do this by using the mixed type adopted `HazelcastClient`. You can adopt the client in this way:
440440
```
441441
ClientConfig config;
442442
HazelcastClient client(config);
443443
mixedtype::HazelcastClient &hazelcastClient = client.toMixedType();
444444
```
445-
The mixedtype::HazelcastClient interface is designed to provide you the data structures which allows you to work with any object types in a mixed manner. For example, the interface allows you to provide the key and value type differently for each map.put call. An example usage is shown below:
445+
The `mixedtype::HazelcastClient` interface is designed to provide you the data structures which allows you to work with any object types in a mixed manner. For example, the interface allows you to provide the key and value type differently for each map.put call. An example usage is shown below:
446446
```
447447
mixedtype::IMap map = hazelcastClient.getMap("MyMap");
448448
@@ -452,7 +452,7 @@ The mixedtype::HazelcastClient interface is designed to provide you the data str
452452
TypedData result = map.get<int>(3);
453453
```
454454

455-
As you can see in the above code snippet, we are putting int, string and MyCustomObject to the same map. Both the key and value can be of different type for each map.put call.
455+
As you can see in the above code snippet, we are putting `int`, `string` and MyCustomObject to the same map. Both the key and value can be of different type for each map.put call.
456456

457457
If you want to use mixed type map with near cache, then you should use the MixedNearCacheConfig class and add config to the ClientConfig using the addMixedNearCacheConfig method. See the below example:
458458
```
@@ -487,6 +487,17 @@ The TypedData class is a wrapper class for the serialized binary data. It presen
487487

488488
TypedData does late deserialization of the data only when the get method is called.
489489

490+
This TypedData allows you to retrieve the data type of the underlying binary to be used when being deserialized. This class represents the type of a Hazelcast serializable object. The fields can take the following values:
491+
1. <b>Primitive types</b>: `factoryId=-1`, `classId=-1`, `typeId` is the type ID for that primitive as listed in
492+
`SerializationConstants`
493+
2. <b>Array of primitives</b>: `factoryId=-1`, `classId=-1`, `typeId` is the type ID for that array as listed in
494+
`SerializationConstants`
495+
3. <b>IdentifiedDataSerializable</b>: `factoryId`, `classId` and `typeId` are non-negative values as registered by
496+
the `DataSerializableFactory`.
497+
4. <b>Portable</b>: `factoryId`, `classId` and `typeId` are non-negative values as registered by the `PortableFactory`.
498+
5. <b>Custom serialized objects</b>: `factoryId=-1`, `classId=-1`, `typeId` is the non-negative type ID as
499+
registered for the custom object.
500+
490501
# Query API
491502

492503
C++ client API allows you to query map values, keys and entries using predicates. It also allows you to use Hazelcast Map's `executeOnKey` and `executeOnEntries` methods with predicates. You can run a processor on a subset of entries with these methods.
@@ -530,23 +541,23 @@ This example query returns the values between 5 and 10, inclusive. You can find
530541

531542
# Ringbuffer
532543

533-
You can benefit from Hazelcast Ringbuffer using the C++ client library. You can start by obtaining the Ringbuffer using the `HazelcastClient` as usual, as shown below:
544+
You can benefit from Hazelcast `Ringbuffer` using the C++ client library. You can start by obtaining the `Ringbuffer` using the `HazelcastClient` as usual, as shown below:
534545

535546
```
536547
boost::shared_ptr<hazelcast::client::Ringbuffer<std::string> > rb = client.getRingbuffer<std::string>("myringbuffer");
537548
```
538549

539-
Ringbuffer interface allows you to add a new item to the Ringbuffer or read an entry at a sequence number.
550+
`Ringbuffer` interface allows you to add a new item to the `Ringbuffer` or read an entry at a sequence number.
540551

541-
You can query the Ringbuffer capacity which is configured at the server side.
552+
You can query the `Ringbuffer` capacity which is configured at the server side.
542553

543554
# Reliable Topic
544555

545556
You can use Reliable Topic if you do not want to miss any messages during failures. Hazelcast Reliable Topic provides a very similar interface to Topic structure but it has several configuration options.
546557

547-
Reliable Topic implementation depends on the Ringbuffer data structure. The data is kept in the Hazelcast cluster's Ringbuffer structure. These Ringbuffer structures' names start with "\_hz\_rb\_".
558+
Reliable Topic implementation depends on the `Ringbuffer` data structure. The data is kept in the Hazelcast cluster's `Ringbuffer` structure. These `Ringbuffer` structures' names start with "\_hz\_rb\_".
548559

549-
Reliable Topic also supports batch reads from the Ringbuffer. You can optimize the internal working of listener using the method `ReliableTopicConfig::setReadBatchSize`.
560+
Reliable Topic also supports batch reads from the `Ringbuffer`. You can optimize the internal working of listener using the method `ReliableTopicConfig::setReadBatchSize`.
550561

551562
# Map Near Cache
552563
Map can be configured to work with near cache enabled. Near cache allows local caching of entries fetched from the cluster at the client side. The local cache is updated when the client does a get request for a map entry. The locally cached entries are updated automatically as any change occurs in the map data in the cluster. Special internal event listeners are utilized for this purpose.

hazelcast/include/hazelcast/client/serialization/pimpl/SerializationService.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ namespace hazelcast {
5858

5959
namespace serialization {
6060
namespace pimpl {
61+
/**
62+
* This class represents the type of a Hazelcast serializable object. The fields can take the following
63+
* values:
64+
* 1. Primitive types: factoryId=-1, classId=-1, typeId is the type id for that primitive as listed in
65+
* @link SerializationConstants
66+
* 2. Array of primitives: factoryId=-1, classId=-1, typeId is the type id for that array as listed in
67+
* @link SerializationConstants
68+
* 3. IdentifiedDataSerializable: factory, class and type ids are non-negative values as registered by
69+
* the DataSerializableFactory.
70+
* 4. Portable: factory, class and type ids are non-negative values as registered by the PortableFactory.
71+
* 5. Custom serialized objects: factoryId=-1, classId=-1, typeId is the non-negative type id as
72+
* registered for the custom object.
73+
*
74+
*/
6175
struct HAZELCAST_API ObjectType {
6276
ObjectType() : typeId(0), factoryId(-1), classId(-1) {}
6377

0 commit comments

Comments
 (0)