> On March 30, 2020, 4:59 p.m., Karthik Manamcheri wrote:
> > repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
> > Lines 1301 (patched)
> > <https://reviews.apache.org/r/72278/diff/2/?file=2216459#file2216459line1307>
> >
> >     You can use the .putAll function in HashMap. It does what you want it 
> > to do. It over-writes existing keys and adds non-existing keys.
> >     
> >     ```
> >       HashMap<String, Object> currVal = ...
> >       // Add everything from newVal into currVal.
> >       // currVal becomes the merged map.
> >       currVal.putAll(newVal);
> >       ctx.getReferringVertex().setProperty(propertyName, currVal);
> >     ```
> >     
> >     
> > https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html#putAll-java.util.Map-
> 
> Na Li wrote:
>     currVal could be null

Sure then you can just check and create a new map right?

```
// If currVal is null, then there is nothing to merge with. Otherwise, merge 
the new values
// with current value.
HashMap<String, Object> mergedVal = (currVal == null) ? newVal : 
currVal.putAll(newVal);
ctx.getReferringVertex().setProperty(propertyName, mergedVal);
```


- Karthik


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/72278/#review220114
-----------------------------------------------------------


On March 30, 2020, 3:58 p.m., Na Li wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/72278/
> -----------------------------------------------------------
> 
> (Updated March 30, 2020, 3:58 p.m.)
> 
> 
> Review request for atlas, Ashutosh Mestry, Karthik Manamcheri, Sridhar K, and 
> Sarath Subramanian.
> 
> 
> Bugs: atlas-3700
>     https://issues.apache.org/jira/browse/atlas-3700
> 
> 
> Repository: atlas
> 
> 
> Description
> -------
> 
> 1) The model definition is in 
> "https://github.com/apache/atlas/blob/master/addons/models/4000-MachineLearning/4010-ml_model.json#L90";
> 
> 2) I created a request of type EntityCreateRequestV2. It contains an entity 
> of type ml_model_build with an attribute "metadata", which is a map, and 
> contains key-value entries for "engineImageTag" and "engineImageName".
> 
> 3) Then I created a request of type EntityPartialUpdateRequestV2. It contains 
> an entity of type ml_model_build with an attribute "metadata", which is a 
> map, and contains key-value entry for "updated_at".
> 
> 4) In the properties of the entity ml_model_build, the * attribute 
> "*metadata" only contains key-value entry for "updated_at".
> 
> Desired behavior:
> 
> The attribute "metadata" should contains key-value entries for 
> "engineImageTag", "engineImageName" and "updated_at".
> 
> Current behavior:
> 
> the attribute "metadata" only contains key-value entry for "updated_at".
> 
> 
> Diffs
> -----
> 
>   
> intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java
>  1434a24590c4f4172378f98d83ca8d9e9ec9c4d8 
>   
> repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
>  75b016cca04801c4c1512c1527453fd59a11a6c4 
>   
> repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2Test.java
>  225b72cbef20b2329b36f550da60c1bbe1f95efa 
> 
> 
> Diff: https://reviews.apache.org/r/72278/diff/2/
> 
> 
> Testing
> -------
> 
> add new test case for map attribute for partial update
> 
> 
> Thanks,
> 
> Na Li
> 
>

Reply via email to