[ 
https://issues.apache.org/jira/browse/IGNITE-26758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18041773#comment-18041773
 ] 

Kirill Anisimov commented on IGNITE-26758:
------------------------------------------

h3. *Where it is used*

The field is declared and utilized exclusively in 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java.
 It appears in the following methods:


h4. Declaration

```private volatile ConcurrentMap<Object, CachedResult<?>> qryResCache = new 
ConcurrentHashMap<>();  ```
Before it, it looked like this:
```private volatile ConcurrentMap<Object, CachedResult<?>> qryResCache = new 
ConcurrentHashMap8<>();```
But was changed in +*IGNITE-7513*+

Purpose: Thread-safe map for storing temporary query results.
h4. 
Usage in the code
 # invalidateResultCache() (private method):
Called to clear the cache after data mutations to ensure consistency.
```
private void invalidateResultCache() {
if (!qryResCache.isEmpty())
qryResCache = new ConcurrentHashMap<>();
}```
 # executeFieldsQuery(...) (private method):
Core usage for caching and deduplicating concurrent SQL fields queries. Key is 
based on query clause and arguments.
```
// Attempt to get result from cache.
T2<String, List<Object>> resKey = new T2<>(qry.clause(), F.asList(args));

FieldsResult res = (FieldsResult)qryResCache.get(resKey);

if (res != null && res.addRecipient(rcpt))
return res; // Cached result found.

res = new FieldsResult(rcpt);

if (qryResCache.putIfAbsent(resKey, res) != null)
resKey = null; // Failed to cache result.

if (resKey != null)
qryResCache.remove(resKey, res);

return res;
}```
 # store(...) (public method):
Invalidates cache after storing data.
```
finally {
invalidateResultCache();

leaveBusy();
}```
 # remove(...) (public method):
Similar to store, invalidates cache after removal.
```
finally {
invalidateResultCache();

leaveBusy();
}```

> Figure out what qryResCache is used for and where it is used
> ------------------------------------------------------------
>
>                 Key: IGNITE-26758
>                 URL: https://issues.apache.org/jira/browse/IGNITE-26758
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Kirill Anisimov
>            Assignee: Kirill Anisimov
>            Priority: Major
>              Labels: cache, investigation
>             Fix For: 2.18
>
>
> There is a qryResCache module in our codebase, but it is not entirely clear 
> what exactly it caches and what it is intended for. It is necessary to 
> analyze its operation and determine whether it needs to be used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to