Repository: geode Updated Branches: refs/heads/feature/GEODE-2282 [created] 5ea0bf027
GEODE-2282: Provide ability to sort field while creating pdxType for jSON document (Need to document system property) Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/5ea0bf02 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/5ea0bf02 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/5ea0bf02 Branch: refs/heads/feature/GEODE-2282 Commit: 5ea0bf0274d74f610ffbab0a1a2ae8ffadd31fc7 Parents: 9ff51ea Author: Dave Barnes <[email protected]> Authored: Thu Jan 26 14:43:36 2017 -0800 Committer: Dave Barnes <[email protected]> Committed: Thu Jan 26 14:43:36 2017 -0800 ---------------------------------------------------------------------- .../jsonformatter_pdxinstances.html.md.erb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/5ea0bf02/geode-docs/developing/data_serialization/jsonformatter_pdxinstances.html.md.erb ---------------------------------------------------------------------- diff --git a/geode-docs/developing/data_serialization/jsonformatter_pdxinstances.html.md.erb b/geode-docs/developing/data_serialization/jsonformatter_pdxinstances.html.md.erb index d5397ed..ee1fb29 100644 --- a/geode-docs/developing/data_serialization/jsonformatter_pdxinstances.html.md.erb +++ b/geode-docs/developing/data_serialization/jsonformatter_pdxinstances.html.md.erb @@ -21,7 +21,7 @@ limitations under the License. The `JSONFormatter` API allows you to put JSON formatted documents into regions and retrieve them later by storing the documents internally as PdxInstances. -Geode now supports the use of JSON formatted documents natively. When you add a JSON document to a Geode cache, you call the JSONFormatter APIs to transform them into the PDX format (as a `PdxInstance`), which enables Geode to understand the JSON document at a field level. +Geode supports the use of JSON formatted documents natively. When you add a JSON document to a Geode cache, you call the JSONFormatter APIs to transform them into the PDX format (as a `PdxInstance`), which enables Geode to understand the JSON document at a field level. In terms of querying and indexing, because the documents are stored internally as PDX, applications can index on any field contained inside the JSON document including any nested field (within JSON objects or JSON arrays.) Any queries run on these stored documents will return PdxInstances as results. To update a JSON document stored in Geode , you can execute a function on the PdxInstance. @@ -44,3 +44,14 @@ After executing a Geode query or calling `region.get`, you can use the following - `toJSONByteArray`. Reads a PdxInstance and returns a JSON byte array. For more information on using the JSONFormatter, see the Java API documentation for `org.apache.geode.pdx.JSONFormatter`. + +# Sorting Behavior of Serialized JSON Fields + +By default, Geode serialization creates a unique pdx typeID for each unique JSON document, even if the +only difference between the JSON documents is the order in which their fields are specified. + +If you prefer that JSON documents which differ only in the order in which their fields are specified +map to the same typeID, set the property `gemfire.pdx.mapper.sort-json-field-names` to `true`. This +tells the system to sort the JSON fields prior to serialization, allowing the system to identify +matching entries, and helps reduce the number of pdx typIDs that are generated by the serialization +mechanism.
