@Test public void testOptimizeQ4() throws Exception { RdfEvalStatsDAO<RdfCloudTripleStoreConfiguration> res = new ProspectorServiceEvalStatsDAO(conn, arc); AccumuloSelectivityEvalDAO accc = new AccumuloSelectivityEvalDAO(); accc.setConf(arc); accc.setConnector(conn); accc.setRdfEvalDAO(res); accc.init(); BatchWriter bw1 = conn.createBatchWriter("rya_prospects", config); BatchWriter bw2 = conn.createBatchWriter("rya_selectivity", config); String s1 = "predicateobject" + DELIM + "http: String s2 = "predicateobject" + DELIM + "uri:barksAt" + DELIM + "uri:cat"; String s3 = "predicateobject" + DELIM + "uri:peesOn" + DELIM + "uri:hydrant"; String s5 = "predicateobject" + DELIM + "uri:scratches" + DELIM + "uri:ears"; String s4 = "predicateobject" + DELIM + "uri:eats" + DELIM + "uri:chickens"; List<Mutation> mList = new ArrayList<Mutation>(); List<Mutation> mList2 = new ArrayList<Mutation>(); List<String> sList = Arrays.asList("subjectobject", "subjectpredicate", "subjectsubject", "predicateobject", "predicatepredicate", "predicatesubject"); Mutation m1, m2, m3, m4, m5, m6; m1 = new Mutation(s1 + DELIM + "3"); m1.put(new Text("count"), new Text(""), new Value("4".getBytes())); m2 = new Mutation(s2 + DELIM + "2"); m2.put(new Text("count"), new Text(""), new Value("0".getBytes())); m3 = new Mutation(s3 + DELIM + "1"); m3.put(new Text("count"), new Text(""), new Value("8".getBytes())); m4 = new Mutation(s4 + DELIM + "1"); m4.put(new Text("count"), new Text(""), new Value("3".getBytes())); m5 = new Mutation(s5 + DELIM + "1"); m5.put(new Text("count"), new Text(""), new Value("0".getBytes())); mList.add(m1); mList.add(m2); mList.add(m3); mList.add(m4); mList.add(m5); bw1.addMutations(mList); bw1.close(); Scanner scan = conn.createScanner("rya_prospects", new Authorizations()); scan.setRange(new Range()); for (Map.Entry<Key,Value> entry : scan) { System.out.println("Key row string is " + entry.getKey().getRow().toString()); System.out.println("Key is " + entry.getKey()); System.out.println("Value is " + (new String(entry.getValue().get()))); } m1 = new Mutation(s1); m2 = new Mutation(s2); m3 = new Mutation(s3); m4 = new Mutation(s4); m5 = new Mutation(s5); m6 = new Mutation(new Text("subjectpredicateobject" + DELIM + "FullTableCardinality")); m6.put(new Text("FullTableCardinality"), new Text("100"), EMPTY_VAL); int i = 2; int j = 3; int k = 4; Long count1; Long count2; Long count3; for (String s : sList) { count1 = (long) i; count2 = (long) j; count3 = (long) k; m1.put(new Text(s), new Text(count1.toString()), EMPTY_VAL); m2.put(new Text(s), new Text(count2.toString()), EMPTY_VAL); m3.put(new Text(s), new Text(count1.toString()), EMPTY_VAL); m4.put(new Text(s), new Text(count3.toString()), EMPTY_VAL); m5.put(new Text(s), new Text(count1.toString()), EMPTY_VAL); i = 2 * i; j = 2 * j; k = 2 * k; } mList2.add(m1); mList2.add(m2); mList2.add(m3); mList2.add(m5); mList2.add(m4); mList2.add(m6); bw2.addMutations(mList2); bw2.close(); scan = conn.createScanner("rya_selectivity", new Authorizations()); scan.setRange(new Range()); for (Map.Entry<Key,Value> entry : scan) { System.out.println("Key row string is " + entry.getKey().getRow().toString()); System.out.println("Key is " + entry.getKey()); System.out.println("Value is " + (new String(entry.getKey().getColumnQualifier().toString()))); } TupleExpr te = getTupleExpr(q2); RdfCloudTripleStoreSelectivityEvaluationStatistics ars = new RdfCloudTripleStoreSelectivityEvaluationStatistics(arc, res, accc); QueryJoinSelectOptimizer qjs = new QueryJoinSelectOptimizer(ars, accc); System.out.println("Originial query is " + te); qjs.optimize(te, null, null); TupleExpr what = getTupleExpr(Q4); System.out.println("lolol: \n" + what); Assert.assertTrue(te.equals(getTupleExpr(Q4))); System.out.print("Optimized query is " + te); }
public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new JoinVisitor()); }
QueryJoinSelectOptimizer implements QueryOptimizer { public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new JoinVisitor()); } }
QueryJoinSelectOptimizer implements QueryOptimizer { public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new JoinVisitor()); } QueryJoinSelectOptimizer(EvaluationStatistics statistics, SelectivityEvalDAO eval); }
QueryJoinSelectOptimizer implements QueryOptimizer { public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new JoinVisitor()); } QueryJoinSelectOptimizer(EvaluationStatistics statistics, SelectivityEvalDAO eval); void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings); }
QueryJoinSelectOptimizer implements QueryOptimizer { public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new JoinVisitor()); } QueryJoinSelectOptimizer(EvaluationStatistics statistics, SelectivityEvalDAO eval); void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings);  }