Skip to content

Commit fcad1e1

Browse files
author
kmetin
committed
init compact serializer docs
1 parent 0484632 commit fcad1e1

File tree

3 files changed

+241
-0
lines changed

3 files changed

+241
-0
lines changed

docs/modules/ROOT/nav.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* xref:configuration.adoc[Configure]
1212
** xref:connect-to-viridian.adoc[Connect to {hazelcast-cloud}]
1313
** xref:connect-to-platform.adoc[Connect to Platform]
14+
** xref:using-compact-serializer-generator.adoc[Using Compact Serializer Generator]
1415
//** xref:config-wizard.adoc[CLC Configuration Wizard ]
1516
* xref:upgrade-clc.adoc[Upgrade]
1617
@@ -33,6 +34,7 @@
3334
** xref:clc-version.adoc[]
3435
** xref:clc-viridian.adoc[]
3536
** xref:clc-project.adoc[]
37+
** xref:clc-serializer-generator.adoc[]
3638
* xref:configuration-format.adoc[]
3739
* xref:environment-variables.adoc[]
3840
* xref:keyboard-shortcuts.adoc[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
= clc serializer generator (Beta)
2+
3+
Serializer commands are a group of serializer generator operations.
4+
5+
Check out the documentation for https://docs.hazelcast.com/hazelcast/latest/serialization/compact-serialization[Compact Serialization] for more information.
6+
7+
Usage:
8+
9+
[source,bash]
10+
----
11+
clc serializer [command] [flags]
12+
----
13+
14+
== Commands
15+
16+
* <<clc-serializer-generate, clc serializer generate>>
17+
18+
== clc serializer generate
19+
20+
Generates compact serialization code from the given schema for the target language. See https://docs.hazelcast.com/hazelcast/latest/serialization/compact-serialization#implementing-compactserializer[Compact Serialization] documentation for more information.
21+
22+
Usage:
23+
24+
[source, bash]
25+
----
26+
clc serializer generate [schema] [flags]
27+
----
28+
29+
Parameters:
30+
31+
[cols="1m,1a,2a,1a"]
32+
|===
33+
|Parameter|Required|Description|Default
34+
35+
|`output-dir`, `-o`
36+
|Optional
37+
|Output directory for the serialization files.
38+
|Current working directory.
39+
40+
|`language`, `-l`
41+
|Required
42+
|Programming language that the serializer created for.
43+
|
44+
|===
45+
46+
Example:
47+
48+
[source,bash]
49+
----
50+
clc serializer generate my-schema.yaml --language java --output-dir my-dir
51+
----
52+
53+
=== Schema Creation
54+
55+
A schema allows you to:
56+
57+
* describe the contents of a compact class using supported field types
58+
* import other schema
59+
* specify a namespaces for schema files and reference other namespaces
60+
* define cyclic references between classes
61+
* reference classes that are not present in the given schemas
62+
63+
A schema is written in YAML. Schema format is given below:
64+
65+
[source,yaml]
66+
----
67+
namespace: <namespace of the class>
68+
# note that other schema files can be imported with relative path to this yaml file
69+
imports:
70+
- someOtherSchema.yaml
71+
# All objects in this file will share the same namespace.
72+
classes:
73+
- name: <name of the class>
74+
fields:
75+
- name: <field name>
76+
type: <field type>
77+
external: bool # to mark external types (external to this yaml file)
78+
----
79+
80+
==== namespace:
81+
Used for logical grouping of classes. Typically, for every namespace, you will have a schema file. Namespace is optional. If not provided, the classes will be generated at global namespace (no namespace). The user should provide the language specific best practice when using the namespace. The tool will use the namespace while generating code if provided.
82+
83+
==== imports:
84+
Used to import other schema files. The type definitions in the imported yaml schemas can be used within this yaml file. Cyclic imports will be checked and handled properly. For this version of the tool, an import can only be a single file name and the tool will assume all yaml files imported will be in the same directory as the importing schema file.
85+
86+
==== classes:
87+
Used to define classes in the schema.
88+
89+
* name
90+
* fields
91+
** name: Name of the field
92+
** type: Type of the field. Normally you should refer to another class as namespace.classname. You can use a class without namespace when the class is defined in the same schema yaml file. type can be one of the following:
93+
*** `boolean`
94+
*** `boolean[]`
95+
*** `int8`
96+
*** `int8[]`
97+
*** `int16`
98+
*** `int16[]`
99+
*** `int32`
100+
*** `int32[]`
101+
*** `int64`
102+
*** `int64[]`
103+
*** `float32`
104+
*** `float32[]`
105+
*** `float64`
106+
*** `float64[]`
107+
*** `string`
108+
*** `string[]`
109+
*** `date`
110+
*** `date[]`
111+
*** `time`
112+
*** `time[]`
113+
*** `timestamp`
114+
*** `timestamp[]`
115+
*** `timestampWithTimezone`
116+
*** `timestampWithTimezone[]`
117+
*** `nullableBoolean`
118+
*** `nullableBoolean[]`
119+
*** `nullableInt8`
120+
*** `nullableInt8[]`
121+
*** `nullableInt16`
122+
*** `nullableInt16[]`
123+
*** `nullableInt32`
124+
*** `nullableInt32[]`
125+
*** `nullableInt64`
126+
*** `nullableInt64[]`
127+
*** `nullableFloat32`
128+
*** `nullableFloat32[]`
129+
*** `nullableFloat64`
130+
*** `nullableFloat64[]`
131+
*** `<OtherCompactClass[]>`
132+
** external:
133+
*** Used to mark if the type is external. If a field is external, the tool will not check if it is imported and available. External types are managed by the user and not generated by the tool.
134+
*** The serializer of an external field can be a custom serializer which is handwritten, the zero-config serializer for Java and .NET, or previously genereated using the tool. This flag will enable such mixed use cases.
135+
*** In generated code, external types are imported exactly what as the "type" of the field, hence for languages like Java the user should enter the full package name together with the class. E.g. type: `com.app1.dto.Address`.
136+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
= Using Compact Serializer Generator
2+
3+
:description: User can generate compact classes for their POJOs using CLC's compact serializer generator feature.
4+
{description}
5+
6+
== Before you Begin
7+
8+
You need the following:
9+
10+
- Hazelcast CLC
11+
- a Hazelcast cluster
12+
13+
== Creating Schemas for Business Objects
14+
Let's assume we have the following entities in our application:
15+
16+
* Student
17+
** Name
18+
** Number
19+
* Teacher
20+
** ID
21+
** Name
22+
* Classroom
23+
** ID
24+
** Students
25+
* School
26+
** ID
27+
** Classrooms
28+
29+
and their relationship defined as:
30+
31+
* School has classrooms.
32+
* Classrooms have students.
33+
34+
Their schema definitions should be:
35+
36+
[source,yaml]
37+
----
38+
namespace: "com.people"
39+
classes:
40+
- name: Student
41+
fields:
42+
- name: name
43+
type: string
44+
- name: number
45+
type: int16
46+
- name: assignedLessons
47+
type: com.lesson[]
48+
external: true
49+
- name: advisor
50+
type: Teacher
51+
- name: Teacher
52+
fields:
53+
- name: id
54+
type: string
55+
- name: name
56+
type: string
57+
----
58+
59+
[source,yaml]
60+
----
61+
namespace: "com.rooms"
62+
imports:
63+
- people.yaml
64+
classes:
65+
- name: Classroom
66+
fields:
67+
- name: id
68+
type: int32
69+
- name: students
70+
type: com.people.Student[]
71+
----
72+
73+
[source,yaml]
74+
----
75+
namespace: "com.education"
76+
imports:
77+
- classroom.yaml
78+
classes:
79+
- name: School
80+
fields:
81+
- name: id
82+
type: int32
83+
- name: classrooms
84+
type: com.rooms.Classroom[]
85+
----
86+
87+
Schema definitions can contain following information:
88+
89+
* described the contents of a compact classes: `Student`, `Classroom`, `School`, `Teacher`.
90+
* imported other schema using `imports`.
91+
* specify a namespaces for schema files using `namespace`.
92+
* referenced classes (in this example `com.lesson`) that are not present in the given schemas.
93+
* referenced to an internal class (in this example `Student` reference to `Teacher` in the same schema file).
94+
95+
== Generating POJOs and Compact Classes from Schemas
96+
97+
98+
99+
== Creating Compact Serialization Configuration
100+
101+
== Writing to a Map using Java Client
102+
103+
== Querying the Map using Python Client

0 commit comments

Comments
 (0)