Github user afs commented on the pull request:
https://github.com/apache/jena/pull/95#issuecomment-165791089
Thank you for pushing on with this. It's looking good and nicely targeted
at just the Fuseki codebase.
I've cleaned up the white space in the master branch of Jena for the files
this PR touches which will make comparision easier.
Some design discussion points:
**Cache per dataset**
There is one cache for the system. This should be one cache per dataset,
so there will need to be
a map `ConcurrentHashMap<String, Cache>` where the string is the serice URI.
`getCache()` becomes `getCache(uri)`.
Now when an update happens, only the cache for the dataset needs to be
invalidated.
It also leaves open the possibility of different cache settings for
different datasets.
**No Cache**
What happens if `SPARQL_Query` (SPARQL_Query_Daatset) is used directly?
In other words, do things work for a datset if called dirctly, not via
SPARQL_Query_Cache?
Then whether the cache is used can be as simple as switching the SPARQL_*
implementation.
**Cache key**
Can the cache key be simply based on the query object+responsetype?
Queries are equal if they are the same structure.
See org.apache.jena.atlas.lib.Pair as an example of a class that is good as
a key
because it provides `.hashCode` and `.equals` based on it structure, not
it's object identity.
It devolves work to the two elements.
**Inherit to share code**
SPARQL_Query_Cache seems to have a lot of the operations of SPARQL_Query.
Can the code by DRYed (DRY - Don't Repeat Yourself)?
It looks to me like SPARQL_Query_Cache can share with SPARQL_Query. It
needs to do that by extending SPARQL_QueryDataset then
override `execute()` (that will need to make that protected in
SPARQL_Query), then have generateKey, getKey, getCache.
To call `SPARQL_Query` from `SPARQL_Query_Cache`, the no cache hit path,
instead of:
```
ActionSPARQL queryServlet = new SPARQL_QueryDataset() ;
queryServlet.executeLifecycle(action) ;
```
use
```
super.execute(....)
```
A new `SPARQL_QueryDataset` does not get created each time.
---
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.
---