Skip to content

Commit d348063

Browse files
authored
Update README.md
1 parent 6caea07 commit d348063

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ During map generation, by default, the Adaptor sets export and Import conversion
8585

8686
### How could we configure our mapping for serialization?
8787

88-
We can have as much mapping definitions for a class as we need. An easy way to start to define our customized maps is exporting the default MAP0 and importing it again with a different name, then we can make changes in the map regarding the properties that should be exported /imported, names, conversor methods to apply (See `OPNLib.Serialize.Util` class for tools to export/import maps, get / set property mappings,etc…).
88+
We can have as much mapping definitions for a class as we need. An easy way to start to define our customized maps is exporting the default MAP0 and importing it again with a different name, then we can make changes in the map regarding the properties that should be exported /imported, names, conversor methods to apply. To do this, we can modify directly in the global, or do it programatically (See `OPNLib.Serialize.Util` class for tools to export/import maps, get / set property mappings,etc…)
8989

9090
---
9191
**Example:**
@@ -102,10 +102,10 @@ We can have as much mapping definitions for a class as we need. An easy way to s
102102
;Overwrite map (2) of SampleApps.Serialize.MapTesting with map in object:json
103103
set tSC = ##class(OPNLib.Serialize.Util).ImportMapsFromJSON(json,2,tClassName)
104104

105-
;Get settings of one of the properties. They're returned in a json object
105+
;Get settings of one of the properties. They are returned in a json object
106106
set propExprt = ##class(SampleApps.Serialize.MapTesting).GetMappedPropSettings("code","MAP1",tClassName,1)
107107

108-
;We'll change the targetPropertyName setting
108+
;We change the targetPropertyName setting
109109
set $ListUpdate(propExprt.settings,1) = "codeAccepted"
110110
do ##class(SampleApps.Serialize.MapTesting).SetMappedPropSettings("code",propExprt,"MAP1",tClassName,1)
111111

@@ -116,8 +116,6 @@ We can have as much mapping definitions for a class as we need. An easy way to s
116116

117117
```
118118

119-
120-
121119
We also have the possibility of changing a bit the way in which default map `MAP0` is generated :
122120
* Change the name of default map.
123121
* Use parameter `EXPTDEFAULTMAP` to indicate a name for default map before compiling the class
@@ -128,30 +126,26 @@ We also have the possibility of changing a bit the way in which default map `MAP
128126
* Drill down levels
129127
* Use `EXPTDRILLDOWN`To indicate up to what number of levels that the export/import logic should follow through object references. 0 means no drill down. A positive number(n) means to drill down n times through the chain of references.
130128

129+
## How did it work the default mechanism?
131130

131+
Both methods, `Export` and `Import` will call the generated methods: `exportStd` and `importStd` respectively. These two methods will go through the global `^MAPS` and `^MAPSREV` respectively, looking for the properties to export /import and applying the required conversions.
132+
Both methods work over an already instantiated method. This is particularly interesting for import, as we can have an object in memory with some data already and import the rest of the data from a serialized object. The import mechanism will replace with the new content the properties contained in the serialization but will preserve other properties already set in the instance that are not included in the serialization that we import.
132133

133-
How did it work the default mechanism?
134-
135-
Both methods, export and Import will call the generated methods: exportStd and imoortStd respectively. These two methods will go through the global ^MAPS and ^MAPSREV respectively, looking for the properties to export /import and applying the required conversions.
136-
Both methods work over an already instantiated method. This is particularly important for import, as we can have an object in memory with some data already and import the rest of the data from a serialized object. The import mechanism will replace with the new content the properties contained in the serialization but will preserve other properties already set in the instance that are not included in the serialization that we import.
137-
138-
Example:
134+
This way of working give us the flexibility of using different mappings using the same autogenerated code but it can have a penalty in performance if we use it massively in loops or in very high concurrency use cases. Anyway, better test in such scenarios.
139135

140-
<< import a JSON with just some properties in an object where we already have some others set >>>
136+
## Some considerations about performance
141137

142-
This way of working give us the flexibility of using different mappings using the same autogenerated code but it can have a penalty in performance if we use it massively in loops or in very high concurrency use cases. Anyway,better test in such scenarios.
138+
As it was already mentioned, the default mechanism resolve the mapping sets at real time, trasversing a global to set the properties to export/import targets. That means that this mechanism will always be slower than if we already had that settings resolved at compile time. In order to provide that functionality, we can use the Template classes.
143139

144-
Some considerations about performance
140+
## What are the template classes for?
145141

146-
As we already mentioned, the default mechanism resolve the mapping sets at real time, trasversing a global to set the properties to export/import targets. That means that this mechanism will always be slower than if we already had that settings resolved at compile time. In order to provide that functionality, we can use the Template classes.
147-
148-
What are the template classes for?
149-
150-
The templates classes allow us to generate the logic to export /import at compile time.
142+
The templates classes allow us to generate the logic to export/import at compile time.
151143
This have benefits over performance but comes at the price of having to use a different class for each type of serialization format and mapping.
152144

153145
Anyway, the primary class is not affected and doesn't have to be changed no matter how many templates define to handle the serialization of its objects.
154146

147+
148+
155149
Example :
156150

157151
<<< define and use different template classes, for different maps in JSON and also for different serialization (CSV)

0 commit comments

Comments
 (0)