Hi again, I made a small correction below:
> On 01 Feb 2017, at 09:19, Dimitrianos Savva <[email protected]> wrote:
>
> Hi Andy,
>
> Thanks you for your quick response.
> I am working on a project that extends Apache Jena and in the preprocessing
> phase I need to find the triple patterns of all variables
> For example the following:
>
> (project (?o)
> (join
> (project (?p ?o) #project0
> (bgp
> (triple ?s ?p ?o) #triple0
> (triple ?s ?k ?m) #triple1
> ))
> (project (?p ?o) #project1
> (bgp (triple ?o ?p ?s) #triple2
> ))))
>
>
>
> will give the following map:
>
> ?s —> [ triple0 , triple1 ] <— This is for the first ?s under project0
?s —> [ triple2 ] <— This is for the second ?s under
project1
>
> ?p —> [ triple0 , triple2 ]
> ?o —> [ triple0 , triple2 ]
> ?k —> [ triple1 ]
> ?m —> [ triple1 ]
>
>
> So I thought that the easiest way of building the graph is to construct a map
> of variables to a list of (triple-position). This can be done by traversing
> an operator using the OpWalker.walk(Op op, OpVisitor visitor) and storing the
> variables to a Map<Node_Variable, List<Triple>>.
>
> To achieve that we need to rename all variables that are not visible outside
> project operators.
> The class TransformScopeRename can do exactly this by employing at some
> point the Rename.renameVars(Op op, Collection<Var> constants) function which
> eventually adds the prefix “/” to each local variable.
> However the local variables will have the same name across different project
> operators.
>
> For example the above algebra will be transformed to
>
> (project (?o)
> (join
> (project (?p ?o) #project0
> (bgp
> (triple ?/s ?p ?o) #triple0
> (triple ?s ?/k ?/m) #triple1
> ))
> (project (?p ?o) #project1
> (bgp (triple ?o ?p ?/s) #triple2
> ))))
>
> where variable ?s under project0 and project1 will get the same name ?/s so
> it remains the same variable and cannot be globally distinguished.
>
> I thought that the solution to this problem was to perform the renaming by
> adding different prefixes to the hidden variables per project operator.
>
> Thanks
> Dimis
>
>> On 31 Jan 2017, at 11:36, Andy Seaborne <[email protected]> wrote:
>>
>> Hi Dimis,
>>
>> Thanks for pointing this point.
>>
>> This function has changed recently in the development branch - there is no
>> longer a class member "varPrefix" because "varPrefix" was always set to the
>> constant "prefix". The fixed setting is assumed elsewhere in the code.
>>
>> https://github.com/apache/jena/blob/master/jena-arq/src/main/java/org/apache/jena/sparql/engine/Rename.java
>>
>> Do you have specific need to have "varPrefix" in RenameAnyVars? It can be
>> put back easily enough even if not required by ARQ itself.
>>
>> Andy
>>
>>
>> On 31/01/17 00:16, Dimitrianos Savva wrote:
>>> Hi,
>>>
>>> It seems that the field varPrefix should have been used as a parameter
>>> (instead of prefix):
>>>
>>> var2 = Rename.chooseVarName(var, constants, prefix) ;
>>>
>>> in function:
>>>
>>> Node apply(Node node)
>>>
>>> in static class RenameAnyVars
>>>
>>> in class org.apache.jena.sparql.engine.Rename
>>>
>>> Thanks
>>> Dimis
>>>
>