You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by GitBox <gi...@apache.org> on 2022/08/02 11:54:38 UTC

[GitHub] [unomi] jkevan commented on a diff in pull request #469: UNOMI-637 : do not create mapping for property type if not necessary

jkevan commented on code in PR #469:
URL: https://github.com/apache/unomi/pull/469#discussion_r935474565


##########
persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java:
##########
@@ -1444,7 +1444,10 @@ public void setPropertyMapping(final PropertyType property, final String itemTyp
             }
             Map<String, Object> subMappings = mappings.computeIfAbsent("properties", k -> new HashMap<>());
             Map<String, Object> subSubMappings = (Map<String, Object>) subMappings.computeIfAbsent("properties", k -> new HashMap<>());
-            mergePropertiesMapping(subSubMappings, createPropertyMapping(property));
+            Map<String, Object> propertyMapping = createPropertyMapping(property);
+            if (propertyMapping != null) {
+                mergePropertiesMapping(subSubMappings, propertyMapping);
+            }

Review Comment:
   I think we should simplify this function, if `Map<String, Object> propertyMapping = createPropertyMapping(property);` is null we can simply abort this function by `return;`
   
   Also for better perf, we can do this in the first line to avoid calculating the existing mapping in case createPropertyMapping return null.



-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org