Hi, I dont know whats going wrong I am still having problems in converting/manipulating :( ..
It all started with just aliasing problem and it still exists in my brain. well here is what I found.... hope any one can help me.... Problem 1 : Test Original Query 1 -------------------------------------------------- PREFIX movie: <http://data.linkedmdb.org/resource/movie/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX fn: <java:facet.> SELECT ?fpredicate (count(distinct ?instance) AS ?ficount) (count(distinct ?object) AS ?focount) WHERE { ?instance rdf:type movie:film . ?instance ?fpredicate ?object FILTER regex(str(?fpredicate), "http://data.linkedmdb.org/resource/", "i") } GROUP BY ?fpredicate Test Original Query 1 Algebra-------------------------------------------- (project (?fpredicate ?ficount ?focount) (extend ((?ficount ?.0) (?focount ?.1)) (group (?fpredicate) ((?.0 (count distinct ?instance)) (?.1 (count distinct ?object))) (filter (regex (str ?fpredicate) "http://data.linkedmdb.org/resource/" "i") (bgp (triple ?instance <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://data.linkedmdb.org/resource/movie/film>) (triple ?instance ?fpredicate ?object) ))))) Test OpAsQuery Query 1 -------------------------------------------------- SELECT ?fpredicate (count(distinct ?instance) AS ?ficount) (count(distinct ?object) AS ?focount) WHERE { ?instance <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://data.linkedmdb.org/resource/movie/film> . ?instance ?fpredicate ?object FILTER regex(str(?fpredicate), "http://data.linkedmdb.org/resource/", "i") } GROUP BY ?fpredicate Test Original Query 2 -------------------------------------------------- PREFIX movie: <http://data.linkedmdb.org/resource/movie/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX fn: <java:facet.> SELECT ?fpredicate (count(distinct ?instance) AS ?ficount) (count(distinct ?object) AS ?focount) (fn:weights3(count(distinct ?instance), count(distinct ?object), 85620) AS ?coverage) WHERE { ?instance rdf:type movie:film . ?instance ?fpredicate ?object FILTER regex(str(?fpredicate), "http://data.linkedmdb.org/resource/", "i") } GROUP BY ?fpredicate Test Original Query 2 Algebra --------------------------------------------- (project (?fpredicate ?ficount ?focount ?coverage) (extend ((?ficount ?.0) (?focount ?.1) (?coverage (<java:facet.weights3> ?.0 ?.1 85620))) (group (?fpredicate) ((?.0 (count distinct ?instance)) (?.1 (count distinct ?object))) (filter (regex (str ?fpredicate) "http://data.linkedmdb.org/resource/" "i") (bgp (triple ?instance <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://data.linkedmdb.org/resource/movie/film>) (triple ?instance ?fpredicate ?object) ))))) Test OpAsQuery Query 2 -------------------------------------------------- Exception in thread "main" com.hp.hpl.jena.sparql.ARQNotImplemented: Expected simple assignment for group at com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.visit(OpAsQuery.java:385) at com.hp.hpl.jena.sparql.algebra.op.OpExtend.visit(OpExtend.java:107) at com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.visit(OpAsQuery.java:417) at com.hp.hpl.jena.sparql.algebra.op.OpProject.visit(OpProject.java:34) at com.hp.hpl.jena.sparql.algebra.OpAsQuery.asQuery(OpAsQuery.java:45) at test.Temp.main(Temp.java:145) Can any body help me with this exception ... What is did was Query query1 = QueryFactory.create(queryString); System.out.println("\n\n Test Original Query 1 --------------------------------------------------"); query1.serialize(new IndentedWriter(System.out)); System.out.println("\n\n Test Original Query 1 Algebra--------------------------------------------"); Op o1 = Algebra.compile(query1); o1.output(new IndentedWriter(System.out)); System.out.println("\n\n Test OpAsQuery Query 1 --------------------------------------------------"); Query queryRe1 = OpAsQuery.asQuery(o1); queryRe1.serialize(new IndentedWriter(System.out)); ///ry for 2nd I could not follow in code what does /** * Special case: group involves and internal assignment * e.g. (assign ((?.1 ?.0)) (group () ((?.0 (count))) * We attempt to intercept that here. */ mean and how should I handle this case in building query , If problem above was Obvious . Problem 2: op =new OpGroup(op,exl, aggrelist); What if I dont want to have aggrelist ? if My Query is some thing like SELECT DISTINCT ?fpredicate WHERE { ?instance rdf:type movie:film . ?instance ?fpredicate ?object FILTER regex(str(?fpredicate), "http://data.linkedmdb.org/resource/", "i") } GROUP BY ?fpredicate Can I leave my List<ExprAggregator> aggrelist = new ArrayList<ExprAggregator>(); Empty in here or pass NULL value to aggrelist ? Could not try this out myself as was stuck in above. Problem 3: Aggregator agg1 = new AggCountVarDistinct(ev1); VarAlloc va = new VarAlloc(ARQConstants.allocVarMarker); Var temp1 = va.allocVar(); Expr extemp1 = new ExprVar(temp1); ExprAggregator eagg1 = new ExprAggregator(temp1, agg1); aggrelist.add(eagg1); When there are count expressions in my projection, Is It Mandatory to have Temporary Variables to define implicit grouping of variables when I am building Algebra of query? Problem 4: Dataset dataset = TDBFactory.createDataset(directory) ; PrefixMapping premap = dataset.asDatasetGraph().getDefaultGraph().getPrefixMapping(); It does not return any prefix entries ,...... I asked this before but when I tried The result is 0; Pardon me I could not follow properly .. :/ Question General : Can I make TDB use customize StageGenerator than its native StageGeneratorDirectTDB ? I debugged a bit and found out that its not using customized one. Thanks, Regards, aj ________________________________ From: Andy Seaborne <[email protected]> To: [email protected] Sent: Friday, 18 November 2011 7:56 PM Subject: Re: ARQ Building query incrementally help On 18/11/11 18:26, ajaz shaik wrote: > Hi again, > > I solved the problem myself with help of andy's previous reply. > I just needed some patients. Sorry for inconvenience. > > > In case if it helps for some one around this group here is the code Thanks for letting us know what you've discovered. Andy
