[Mulgara-dev] Query Evaluation - binding variables

Life is hard, and then you die ronald at innovation.ch
Wed Apr 23 00:17:43 UTC 2008


On Tue, Apr 22, 2008 at 06:59:35PM -0400, Alex Hall wrote:
> I'm trying to write a TQL query to traverse an RDF list using the walk 
> function.  I would like to express the anchor for the walk function as a 
> variable that is bound by another constraint in the query.  So my TQL 
> command looks like this:
> 
> select $x $value from <rmi://localhost/server1#model>
>    where $x <rdf:type> <owl:AllDifferent>
>      and $x <owl:distinctMembers> $y
>      and walk($y <rdf:rest> $node and $z <rdf:rest> $node)
>      and $node <rdf:first> $value;
> 
> However, when I execute this query, I get an error message, 
> "org.mulgara.query.QueryException: The subject: $y and the object: $node 
> are invalid, one must be a variable and the other a fixed value around a 
> predicate."  I know that this can be worked around by using a subquery, 
> but I'm hoping to avoid a subquery.  It seems there should be some way 
> to force Mulgara to evaluate the first two constraints and bind the 
> variable $y to a value before evaluating the walk function.  Am I 
> mistaken here?  Any suggestions?

We ran into exactly the same problem! This limitation severly reduces
the usefulness of walk (and trans),. I started down the path of
changing the walk and trans functions to allow them to be anchored
anywhere, but never had time to finish - if any cares to take it and
finish it I'd be happy to send them what I have.

As a workaround we've used trans instead:

  select $x $value from <rmi://localhost/server1#model>
     where $x <rdf:type> <owl:AllDifferent>
       and $x <owl:distinctMembers> $y
       and (trans($y <rdf:rest> $node) or $y <rdf:rest> $node)
       and ($y <rdf:first> $value or $node <rdf:first> $value);

I think this is less efficient, though (I'm not sure offhand if the
trans is evaluated on the whole dataset first and then constrained, or
if it uses the $y values resulting from the previous constraints when
evaluating).


  Cheers,

  Ronald




More information about the Mulgara-dev mailing list