Example #1
0
 public void visit(OpFilter opFilter) {
   // JoinPlanner.setFilterVars();
   Iterator<Expr> it = opFilter.getExprs().iterator();
   while (it.hasNext()) {
     Expr e = it.next();
     Iterator<Expr> a = e.getFunction().getArgs().iterator();
     System.out.println(e.getFunction().getOpName());
     while (a.hasNext()) {
       Expr temp = a.next();
       if (temp.isVariable()) JoinPlaner.filter(temp.toString(), e.getFunction());
     }
   }
 }
Example #2
0
  public void visit(OpProject opProject) {
    Configuration conf = new Configuration();
    FileSystem fs = null;
    try {
      fs = FileSystem.get(conf);
      Path out = new Path("output");
      if (!fs.exists(out)) {
        fs.delete(out, true);
        fs.mkdirs(out);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    // Iterator<Triple> it = opBGP.getPattern().getList().iterator();
    /*String[] Q1 = new String[opBGP.getPattern().getList().size()];
    int i =0;
    while(it.hasNext()){
    	Triple t = it.next();
    	Q1[i]=t.getSubject().toString(false)+"$^^$"+t.getPredicate().toString(false)+"$^^$"+t.getObject().toString(false);
       	System.out.print(t.getSubject().toString(false));
       	System.out.print(t.getPredicate().toString(false));
       	System.out.print(t.getObject().toString(false));
       	System.out.println();
       	i++;
    }*/

    /*Object[] Qo = opBGP.getPattern().getList().toArray();
      	String[] Q = new String[Qo.length];
      	for (int i = 0; i < Qo.length; i++) {
          	System.out.println(Qo[i].toString());
      		Q[i]=Qo[i].toString();
    }*/

    /*Iterator<Var> it2 = vars.iterator();
    String[] vs = new String[vars.size()];
    i =0;
    while(it2.hasNext()){
    	Var v = it2.next();
    	vs[i]=v.toString();
    	i++;
    	//System.out.println(v.toString());
    }*/

    // Set<Var> vars=query.getQueryPattern().varsMentioned(); deprecated
    /*Object[] v1 = vars.toArray();
      	String[] vs = new String[v1.length];
      	for (int i = 0; i < v1.length; i++) {
          	System.out.println(v1[i].toString());
    	vs[i]=v1[i].toString();
    }*/

    Triple[] Q = new Triple[0];
    Q = opBGP.getPattern().getList().toArray(Q);
    Set<Var> vars = PatternVars.vars(query.getQueryPattern());

    JoinPlaner.setid(id);
    JoinPlaner.newVaRS(vars);
    try {
      JoinPlaner.form(Q);
      JoinPlaner.removeNonJoiningVaribles(Q);
      int i = 0;
      while (!JoinPlaner.isEmpty()) {
        String v = JoinPlaner.getNextJoin();
        System.out.println(v);
        i++;
      }
      if (i == 0) {
        Path outFile = new Path("output/Join_" + id + "_" + 0);
        if (fs.exists(outFile)) {
          fs.delete(outFile, true);
        }
        QueryProcessor.executeSelect(Q[0], fs.create(outFile), "P0");
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }