Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/119#discussion_r48902208
  
    --- Diff: 
jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java ---
    @@ -268,7 +276,25 @@ private QueryIterator concreteSubject(Binding binding, 
Node s, Node score, Node
             Explain.explain(execCxt.getContext(), "Text query: "+queryString) ;
             if ( log.isDebugEnabled())
                 log.debug("Text query: {} ({})", queryString,limit) ;
    -        return textIndex.query(property, queryString, limit) ;
    +
    +        String cacheKey = limit + " " + property + " " + queryString ;
    +        Map<String,ListMultimap<String,TextHit>> queryCache = 
    +            (Map<String,ListMultimap<String,TextHit>>) 
execCxt.getContext().get(cacheSymbol);
    +        if (queryCache == null) { /* doesn't yet exist, need to create it 
*/
    +            queryCache = new LinkedHashMap();
    +            execCxt.getContext().put(cacheSymbol, queryCache);
    +        }
    +
    +        ListMultimap<String,TextHit> results = queryCache.get(cacheKey) ;
    +        if (results == null) { /* cache miss */
    --- End diff --
    
    Because you want to cache the result if it isn't already cached, maybe 
`queryCache.asMap()::computeIfAbsent` could be useful here? Just a thought, 
maybe it's not more clear.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to