You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/09/08 14:30:16 UTC

[GitHub] [pinot] richardstartin commented on a change in pull request #7412: Reduce allocation in JSONPath evaluation

richardstartin commented on a change in pull request #7412:
URL: https://github.com/apache/pinot/pull/7412#discussion_r704476933



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java
##########
@@ -97,9 +102,9 @@ public static String jsonFormat(Object object)
   @ScalarFunction
   public static Object jsonPath(Object object, String jsonPath) {
     if (object instanceof String) {
-      return JsonPath.read((String) object, jsonPath);
+      return PARSE_CONTEXT.parse((String) object).read(jsonPath, NO_PREDICATES);

Review comment:
       yes, I don't know why it's allocated each time in the library, it just builds a `Configuration` each time (also thread-safe) which makes a wrapper around a Jackson `ObjectMapper` (thread-safe) available via `configuration.jsonProvider()`:
   
   ```java
       private final Configuration configuration;
   
       public ParseContextImpl() {
           this(Configuration.defaultConfiguration());
       }
   
       public ParseContextImpl(Configuration configuration) {
           this.configuration = configuration;
       }
   
       @Override
       public DocumentContext parse(String json) {
           notEmpty(json, "json string can not be null or empty");
           Object obj = configuration.jsonProvider().parse(json);
           return new JsonContext(obj, configuration);
       }
   ```
   
   It might be best to fix this in the library but there's no guarantee on if or when that will get merged...




-- 
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: commits-unsubscribe@pinot.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org