Problem with mappings of select (count(...) ) requests ?
Hello,
It seems when making a "SELECT (count(?z) as ?count) WHERE { ?y humans:hasFriend ?z }" request, the mapping returned contains "ghost" values of ?y ?z even if there are not asked for by the select.
If I run the following program:
public class MappingsProblem { public static void main(String[] args) throws EngineException{ Graph graph = Graph.create(); Load ld = Load.create(graph); ld.load("human_2007_04_17.rdf"); QueryProcess exec = QueryProcess.create(graph); String query = "PREFIX humans: <http://www.inria.fr/2007/04/17/humans.rdfs#>\n SELECT (count(?z) as ?count) WHERE { ?y humans:hasFriend ?z }"; Mappings map = exec.query(query); ResultFormat f1 = ResultFormat.create(map); System.out.println(map.get(0).toString()); System.out.println(f1); } }
I obtain the following output:
`
?y = http://www.inria.fr/2007/04/17/humans.rdfs-instances#Eve
?z = http://www.inria.fr/2007/04/17/humans.rdfs-instances#Alice
?count = 6
Hello,
There are two solutions:
-
use (count(*) as ?c) instead of (count(?z) as ?c)
-
use map.getSelect() to iterate on select variables of the query to compare result Mappings.
Regards,
Olivier