afs commented on issue #1374:
URL: https://github.com/apache/jena/issues/1374#issuecomment-1153122216

   Hi @sszuev ,
   
   A copy of the context will share the original registries - the way to modify 
that is to modify the copy of the context. I'd put that code in the 
PropertyFunctionRegistry, not "teach" context about a specific setting - moie 
discussion for the PR - the copy operations look useful.
   
   The best control over a query setup is via the new (4.3.x) builders which 
allow a change of context: `QueryExec` for graph level, `QueryExecution.create` 
for model level (the associated builder also some legacy compatibility about 
setting timeouts).
   
   ```
           Graph graph = GraphFactory.createDefaultGraph();
   
           PropertyFunctionRegistry pfr = new PropertyFunctionRegistry();
           PropertyFunction pf = new version();
           pfr.put("urn:test:version", (x)->pf);
   
           Context cxt = ARQ.getContext().copy();
           PropertyFunctionRegistry.set(cxt, pfr);
   
           String qs = """
                   SELECT * { ?x <urn:test:version> ?y }
                   """;
           RowSet rowSet = QueryExec.graph(graph)
                   .context(cxt)
                   .query(qs)
                   .select();
           RowSetOps.out(rowSet);
   ```
   Unrelated: there is a problem with some system provided property functions. 
There is a hardwired translation in the code.
   ```
           Graph graph = GraphFactory.createDefaultGraph();
           Context cxt = ARQ.getContext().copy();    
           PropertyFunctionRegistry pfr = new PropertyFunctionRegistry();
           PropertyFunctionRegistry.set(cxt, pfr);
           String qs = """
                   PREFIX afn:     <http://jena.apache.org/ARQ/function#>
                   PREFIX apf:     <http://jena.apache.org/ARQ/property#>
                   SELECT * { ?x apf:version ?y }
                   """;
           RowSet rowSet = QueryExec.graph(graph)
                   .context(cxt)
                   .query(qs)
                   .select();
           RowSetOps.out(rowSet);
   ```
   doesn't work - `apf:version` is still a property function because `afn` and 
`apf` are hardwired in the registry code to map to "java:" URI which then will 
always happen. That's a bug.
   


-- 
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