Silberfuchs1 commented on a change in pull request #8245:
URL: https://github.com/apache/ignite/pull/8245#discussion_r490045074



##########
File path: docs/_docs/restapi.adoc
##########
@@ -240,6 +243,69 @@ Similarly, the `get` command with `keyType=int` and 
`valueType=date` would be:
 
http://[host]:[port]/ignite?cmd=get&key=1&cacheName=myCache&keyType=int&valueType=date
 ----
 
+=== Custom user defined types
+
+For custom objects, the JSON format is used. For example, we can work with the 
following object using the REST API:
+[source, javascript]
+ {
+  "uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac",
+  "name": "John Doe",
+  "organization": 5678901,
+  "married": false,
+  "salary": 156.1
+ }
+
+The following request puts this object into the cache `testCache` as a value 
with a type name `Person` and a key `1`.

Review comment:
       '...cache named 'testCache' as a value...'

##########
File path: docs/_docs/restapi.adoc
##########
@@ -240,6 +243,69 @@ Similarly, the `get` command with `keyType=int` and 
`valueType=date` would be:
 
http://[host]:[port]/ignite?cmd=get&key=1&cacheName=myCache&keyType=int&valueType=date
 ----
 
+=== Custom user defined types
+
+For custom objects, the JSON format is used. For example, we can work with the 
following object using the REST API:
+[source, javascript]
+ {
+  "uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac",
+  "name": "John Doe",
+  "organization": 5678901,
+  "married": false,
+  "salary": 156.1
+ }
+
+The following request puts this object into the cache `testCache` as a value 
with a type name `Person` and a key `1`.
+
+ 
http://[host]:[port]/ignite?cacheName=testCache&cmd=put&keyType=int&key=1&valueType=Person&val=%7B%0A+++++%22uid%22%3A+%227e51118b-eb15-4373-b57f-4984cb9cd7ac%22%2C%0A+++++%22name%22%3A+%22John+Doe%22%2C%0A+++++%22organization%22%3A+5678901%2C%0A+++++%22married%22%3A+false%2C%0A+++++%22salary%22%3A+156.1%0A++%7D&;
+
+On the server side, the JSON value from this request will be converted to 
link:/docs/data-modeling/data-modeling#binary-object-format[binary object]. 
Field types are resolved in the following order:
+
+* If the type name is a `Java class` available on the server, the class field 
types with corresponding names will be used for JSON object field types 
resolving.
+* If the type name is a `query entity` type, the field types will be resolved 
according to the field type defined in the `query entity`.
+* Otherwise, the field types will be resolved according to regular JSON types.
+
+For example, if there is no definition of the "Person" type on the server, the 
fields will be converted in accordance with the standard JSON types:
+[source, javascript]
+"uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac", // string
+"name": "John Doe",                            // string
+"organization": 5678901,                       // int
+"married": false,                              // boolean
+"salary": 156.1                                // double
+
+In case the `query entity` was set

Review comment:
       If the `query entity` is set

##########
File path: docs/_docs/restapi.adoc
##########
@@ -240,6 +243,69 @@ Similarly, the `get` command with `keyType=int` and 
`valueType=date` would be:
 
http://[host]:[port]/ignite?cmd=get&key=1&cacheName=myCache&keyType=int&valueType=date
 ----
 
+=== Custom user defined types
+
+For custom objects, the JSON format is used. For example, we can work with the 
following object using the REST API:
+[source, javascript]
+ {
+  "uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac",
+  "name": "John Doe",
+  "organization": 5678901,
+  "married": false,
+  "salary": 156.1
+ }
+
+The following request puts this object into the cache `testCache` as a value 
with a type name `Person` and a key `1`.
+
+ 
http://[host]:[port]/ignite?cacheName=testCache&cmd=put&keyType=int&key=1&valueType=Person&val=%7B%0A+++++%22uid%22%3A+%227e51118b-eb15-4373-b57f-4984cb9cd7ac%22%2C%0A+++++%22name%22%3A+%22John+Doe%22%2C%0A+++++%22organization%22%3A+5678901%2C%0A+++++%22married%22%3A+false%2C%0A+++++%22salary%22%3A+156.1%0A++%7D&;
+
+On the server side, the JSON value from this request will be converted to 
link:/docs/data-modeling/data-modeling#binary-object-format[binary object]. 
Field types are resolved in the following order:
+
+* If the type name is a `Java class` available on the server, the class field 
types with corresponding names will be used for JSON object field types 
resolving.
+* If the type name is a `query entity` type, the field types will be resolved 
according to the field type defined in the `query entity`.
+* Otherwise, the field types will be resolved according to regular JSON types.
+
+For example, if there is no definition of the "Person" type on the server, the 
fields will be converted in accordance with the standard JSON types:
+[source, javascript]
+"uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac", // string
+"name": "John Doe",                            // string
+"organization": 5678901,                       // int
+"married": false,                              // boolean
+"salary": 156.1                                // double
+
+In case the `query entity` was set
+[source,xml]
+ <bean class="org.apache.ignite.cache.QueryEntity">
+  <property name="keyType"   value="java.lang.Integer"/>
+  <property name="valueType" value="Person"/>
+  <property name="fields">
+   <map>
+    <entry key="uid"          value="java.util.UUID"/>
+    <entry key="name"         value="java.lang.String"/>
+    <entry key="organization" value="java.lang.Long"/>
+    <entry key="married"      value="java.lang.Boolean"/>
+    <entry key="salary"       value="java.lang.Float"/>
+   </map>
+  </property>
+ </bean>
+
+or Java class "Person" loaded on the server.

Review comment:
       '...is loaded on the server.'

##########
File path: docs/_docs/restapi.adoc
##########
@@ -240,6 +243,69 @@ Similarly, the `get` command with `keyType=int` and 
`valueType=date` would be:
 
http://[host]:[port]/ignite?cmd=get&key=1&cacheName=myCache&keyType=int&valueType=date
 ----
 
+=== Custom user defined types
+
+For custom objects, the JSON format is used. For example, we can work with the 
following object using the REST API:
+[source, javascript]
+ {
+  "uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac",
+  "name": "John Doe",
+  "organization": 5678901,
+  "married": false,
+  "salary": 156.1
+ }
+
+The following request puts this object into the cache `testCache` as a value 
with a type name `Person` and a key `1`.
+
+ 
http://[host]:[port]/ignite?cacheName=testCache&cmd=put&keyType=int&key=1&valueType=Person&val=%7B%0A+++++%22uid%22%3A+%227e51118b-eb15-4373-b57f-4984cb9cd7ac%22%2C%0A+++++%22name%22%3A+%22John+Doe%22%2C%0A+++++%22organization%22%3A+5678901%2C%0A+++++%22married%22%3A+false%2C%0A+++++%22salary%22%3A+156.1%0A++%7D&;
+
+On the server side, the JSON value from this request will be converted to 
link:/docs/data-modeling/data-modeling#binary-object-format[binary object]. 
Field types are resolved in the following order:
+
+* If the type name is a `Java class` available on the server, the class field 
types with corresponding names will be used for JSON object field types 
resolving.

Review comment:
       '...will be used for resolving JSON object field types.'

##########
File path: docs/_docs/restapi.adoc
##########
@@ -240,6 +243,69 @@ Similarly, the `get` command with `keyType=int` and 
`valueType=date` would be:
 
http://[host]:[port]/ignite?cmd=get&key=1&cacheName=myCache&keyType=int&valueType=date
 ----
 
+=== Custom user defined types
+
+For custom objects, the JSON format is used. For example, we can work with the 
following object using the REST API:
+[source, javascript]
+ {
+  "uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac",
+  "name": "John Doe",
+  "organization": 5678901,
+  "married": false,
+  "salary": 156.1
+ }
+
+The following request puts this object into the cache `testCache` as a value 
with a type name `Person` and a key `1`.
+
+ 
http://[host]:[port]/ignite?cacheName=testCache&cmd=put&keyType=int&key=1&valueType=Person&val=%7B%0A+++++%22uid%22%3A+%227e51118b-eb15-4373-b57f-4984cb9cd7ac%22%2C%0A+++++%22name%22%3A+%22John+Doe%22%2C%0A+++++%22organization%22%3A+5678901%2C%0A+++++%22married%22%3A+false%2C%0A+++++%22salary%22%3A+156.1%0A++%7D&;
+
+On the server side, the JSON value from this request will be converted to 
link:/docs/data-modeling/data-modeling#binary-object-format[binary object]. 
Field types are resolved in the following order:
+
+* If the type name is a `Java class` available on the server, the class field 
types with corresponding names will be used for JSON object field types 
resolving.
+* If the type name is a `query entity` type, the field types will be resolved 
according to the field type defined in the `query entity`.

Review comment:
       'If the type name is of a `query entity` type,...'

##########
File path: docs/_docs/restapi.adoc
##########
@@ -169,10 +169,13 @@ To set a custom expire time, set the system variable: 
`IGNITE_REST_SESSION_TIMEO
 ====
 
 == Data Types
-The REST API also supports Java built-in types for put/get operations via 
`keyType` and `valueType` optional parameters.
-Note that unless one of the below mentioned types are explicitly specified, 
the REST protocol exchanges the key-value data in `String` format.
+The REST API also supports <<Java built-in types>> and <<Custom user defined 
types>> for put/get operations via `keyType` and `valueType` optional 
parameters.
+
+Note that unless one of the mentioned below types are explicitly specified, 
the REST protocol exchanges the key-value data in `String` format.

Review comment:
       '...unless one of the types mentioned below is explicitly specified, the 
REST protocol will exchange the key-value data in 'String' format.'




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to