Aklakan commented on issue #1314:
URL: https://github.com/apache/jena/issues/1314#issuecomment-1142038151

   In the process of implementing this bulk retrieval and caching I have 
extended the custom service executor system.
   I am proposing the following revisions and extensions:
   
   * The original ServiceExectorFactory continues to exist with the same 
signature but is now called ServiceExecutor. The rationale is that an executor 
is already a factory for executions.
   ```java
   public interface ServiceExecutor {
      ServiceExecution createExecution(OpService opExecute, OpService original, 
Binding binding, ExecutionContext execCxt);
   }
   ```
   
   * There is now a new ChainingServiceExectutor which enables implementing 
chains (much like jetty servlet filters):
   ```java
   public interface ChainingServiceExecutor {
     ServiceExecution createExecution(OpService opExecute, OpService 
opOriginal, Binding binding, ExecutionContext execCxt, ServiceExecutor chain);
   }
   ```
   
   This allows for passing modified/rewritten ops down the chain - which is not 
possible with the ServiceExecutor interface.
   The `ServiceExecutorRegistry` still exists but now internally holds 
`ChainingServiceExecutor` instances rather than `ServiceExecutor`.
   There is `ServiceExecutorOverRegistry` which abstracts the existing 
`ServiceExecutorRegistry`.
   
   * The same concept is now repeated for bulk processing:
   ```java
   public interface ServiceExecutorBulk {
     ServiceExecution createExecution(OpService opService, QueryIterator input, 
ExecutionContext execCxt);
   }
   
   public interface ChainingServiceExecutorBulk {
     ServiceExecution createExecution(OpService opService, QueryIterator input, 
ExecutionContext execCxt, ServiceExecutorBulk chain);
   }
   ```
   * There is now a new `ServiceExecutorRegistryBulk` which is essentially the 
same as `ServiceExecutorRegistry` but with an internal list of 
`ChainingServiceExecutorBulk` instances.
   
   * By default, `ServiceExecutorRegistryBulk` is initialized with an 
`ChainingServiceExecutorBulkToSingle` instance which bridges to the non-bulk 
registry.
   
   
   This way, caching and bulk retrieval system can be plugged in using
   ```
   ServiceExecutorRegistryBulk.get().chain(new 
ChainingServiceExecutorBulkSpecial());
   ```
   
   
[ChainingServiceExecutorBulkSpecial](https://github.com/Aklakan/jena/blob/f85548c488c7f7002eb30943cd7469aa84a6c22b/jena-arq/src/main/java/org/apache/jena/sparql/service/impl/ChainingServiceExecutorBulkSpecial.java#L68)
 addes support for special service iris such as
   ```
   SERVICE <cache:bulk+20:correlate:http://dbpedia.org/sparql> { }
   ``` 
   or equivalently
   ```
   SERVICE <cache:bulk+20:correlate> { SERVICE <http://dbpedia.org/sparql> { } }
   ```
   where:
   * bulk+20 requests a bulk size of 20 bindings
   * cache enables caching
   * correlate performs a naive `Rename.reverseVarRename` such that 
substitution with the outer variables (regardless of scoping) can be performed. 
(There is a caveat that this only works reliably if none of the joining 
variables is projected because otherwise VarFinder will prevent converting 
OpJoin to OpSequence).
   
   With the revised plugin system it is easy to add/remove this special 
functionality or add more custom ones.
   
   
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to