Hi all,
I've been trying to optimize a query using sack to keep track of local information I gathered around, and I've been struggling a little bit against how to use the values stored in a sack when it is a map. Searching in the list I've found a pointer to a section of Kelvin's book I forgot in the past and I've already been able to write a query but I fail to see the rationale behind the following:
if I write:
g.withSac{tmp:'XXX'}.V().limit(100).
where(valuesMap('iri').next().is(eq(sack().map{x->x.get()['tmp']})))
it does not retrieve anything
(assumming that XXX coincides with an 'iri' value in the first 100 vertices of the graph, of course)
However, adapting it to use filter + project directly:
g.withSack{[tmp:'XXX']}.V().limit(100).
filter(project('a','b').by('iri').by(sack().map{x->x.get()['tmp']}).where('a',neq('b')))
it performs the comparison correctly.
I was supposing that sack().map{x->x.get['tmp'].next()} was returning a String and I could use it directly within the predicate as in:
g.withSack{[tmp:'XXX']}.V().limit(100).
where(values('iri').is(eq('XXX')))
which works as expected, but apparently, even though the class map{x->x.get()['tmp'].next()} is String, I cannot use it in the predicate.
This is only a sample, the query is quite more complex (this could have been done with withSideEffect).
The point is that the more straightforward approach using match (disclaimer: more straightforward having a SPARQL background :) ) gives always a timeout in my graphs and I wanted to speed up some joins.
Now, I want to see why it doesn't take that particular String directly :)
Thank you in advance,
Best