Hello Andy,

I have build a prototype version for the SPARQL Query Cache implementation.

I have provided the implementation details below:

1. Created CacheStore class with utility operation as doGet, doSet and
doUnset cache.
2. Created CacheClient interface and implemented client for local in memory
cache.
3. Created CacheAction class with enum fields as READ_CACHE and WRITE_CACHE.
4. Created Cache class as a wrapper object to hold the Cache result(Json
result as of now) and SPARQLResultSet
5.  I check in SPARQLQuery that if cache is null or is it  initialised.
6. If it is null I set WRITE_CACHE action and pass cache object to
ResponseResultSet.
7. ResponseResultSet creates a StringBuilder object and pass it to
IndentedWriter.
8. As Query results are iterated and written in ServletOut Stream I also
append the data in StringBuilder object.
9. Before flushing the data to Outstream I store the StringBuilder object
which contain the json result in cache and set data in cache object has
been initialised.
10. If CacheStore already contain the data then I retrieve the data from
cache and write it to ServletOutStream and flush the data.

Here are the code details in my jena fork.

https://github.com/samaitra/jena/tree/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache

https://github.com/samaitra/jena/blob/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java

https://github.com/samaitra/jena/blob/master/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java


Please let me know your feedback.

Currently I have tested the implementation with Ask and Select Queries. I
still need to test it for Construct and Describe Queries. I will also need
to make modification for returning thrift response.

Regards

Saikat














On Sat, Jan 24, 2015 at 1:16 PM, Saikat Maitra <[email protected]>
wrote:

> Thank you so much for your suggestion Andy. I have started working on 2a.
>
>
> Regards
> Saikat
>
> On Sat, Jan 24, 2015 at 1:38 AM, Andy Seaborne <[email protected]> wrote:
>
>> Hello Claude, Andy,
>>>
>>> In reference to your email I would like to discuss the way I am looking
>>> forward to implement the Cache Layer.
>>>
>>> 1. We will be creating a global cache store based on config params passed
>>> via cache.properties.
>>> 2. Users will have option to select any of the following cache store as
>>> default
>>>          a) In memory local cache
>>>          b) remote in memory cache
>>>          c) remote in memory cache with persistence in disk
>>> 3. We will update SPARQL_QUERY to read query results from cache  if
>>> available and if the ResultSet is within valid time to live.
>>> 4. If cache has expired we will run executeQuery and repopulate the cache
>>> with updated time to live.
>>> 5. We will add Tests to validate different cache store operations.
>>> 6. I am still evaluating the changes required to accommodate different
>>> datasets.
>>>
>>> Please let me know if there are changes required in the implementation.
>>>
>>> Regards
>>> Saikat
>>>
>>
>> Hi Saikat,
>>
>> The plan looks good.
>>
>> One suggestion is to start simple.
>>
>> For example, get 2a working first, maybe with hardwired config, focus on
>> getting that working end-to-end then go back and handle 2b and 2c and 1.
>>
>> By working on just one case, you'll validate the framework into which 2b
>> and 2c have to fit.
>>
>> And it's nice to have something working as soon as possible :-)
>>
>> Tests - good!
>>
>>         Andy
>>
>>
>>
>

Reply via email to