protected Op compileElementData(ElementData elt) { return OpTable.create(elt.getTable()) ; }
@Override public Op transform(OpTable opTable) { if ( opTable.isJoinIdentity() ) return opTable; Table table = opTable.getTable(); if ( table.isEmpty() ) return opTable; if ( TableUnit.isTableUnit(table) ) return opTable; if ( table.getVars().size() == 0 ) return opTable; Table table2 = NodeTransformLib.transform(table, transform); return OpTable.create(table2); }
private static Op rebuild(Op2 subOp, List<Op> ops) { Op chain = OpTable.unit(); for (Op op : ops) { chain = subOp.copy(chain, op); } return chain; }
protected QueryIterator execute(OpTable opTable, QueryIterator input) { if (opTable.isJoinIdentity()) return input ; if (input.isJoinIdentity() ) { input.close() ; return opTable.getTable().iterator(execCxt); } QueryIterator qIterT = opTable.getTable().iterator(execCxt) ; QueryIterator qIter = Join.join(input, qIterT, execCxt) ; return qIter ; }
@Override public void visit(OpTable opTable) { push(opTable.getTable()) ; }
@Override public Op transform(OpLeftJoin opLeftJoin, Op left, Op right) { // If LHS is table empty return table empty // If RHS is table empty can eliminate left join and just leave LHS if (isTableEmpty(left)) { return OpTable.empty(); } else if (isTableEmpty(right)) { return left; } return super.transform(opLeftJoin, left, right); }
private static boolean isUnitTable(Op op) { if (op instanceof OpTable) { if (((OpTable) op).isJoinIdentity()) return true; } return false; }
public static OpTable create(Table table) // Check for Unit-ness? { return new OpTable(table) ; }
@Override public void visit(OpTable opTable) { Table tbl = opTable.getTable(); boolean process = false; for (Var v : tbl.getVars()) { process = process | values.keySet().contains(v); } if (!process) { push(opTable); } else { TableN retTbl = new TableN(tbl.getVars()); Iterator<Binding> iter = tbl.rows(); while (iter.hasNext()) { retTbl.addBinding(rewrite(iter.next())); } push(OpTable.create(retTbl)); } }
@Override public void visit(OpTable opTable) { // Only the variables with values in the tables // (When building, undefs didn't get into bindings so no variable // mentioned) Table t = opTable.getTable() ; // Treat as unknown position unknownAcc.addAll(t.getVars()) ; }
@Override public void visit(OpTable opTable) { // This will go in a group so simply forget it. if ( opTable.isJoinIdentity() ) return ; // Put in a VALUES // This may be related to the grpup of the overall query. ElementData el = new ElementData() ; el.getVars().addAll(opTable.getTable().getVars()) ; QueryIterator qIter = opTable.getTable().iterator(null) ; while (qIter.hasNext()) el.getRows().add(qIter.next()) ; qIter.close() ; currentGroup().addElement(el) ; }
@Override public Op transform(OpJoin opJoin, Op left, Op right) { // If either side is table empty return table empty if (isTableEmpty(left) || isTableEmpty(right)) { return OpTable.empty(); } return super.transform(opJoin, left, right); }
private static boolean isUnitTable(Op op) { if (op instanceof OpTable) { if (((OpTable) op).isJoinIdentity()) return true; } return false; }
@Override public Op0 copy() { return new OpTable(table) ; }
@Override public Op make(ItemList list) { Item t = Item.createList(list) ; Table table = BuilderTable.build(t) ; return OpTable.create(table) ; } } ;
@Override public void visit(OpTable opTable) { Table tbl = opTable.getTable(); boolean process = false; for (Var v : tbl.getVars()) { process = process | values.keySet().contains(v); } if (!process) { push(opTable); } else { TableN retTbl = new TableN(tbl.getVars()); Iterator<Binding> iter = tbl.rows(); while (iter.hasNext()) { retTbl.addBinding(rewrite(iter.next())); } push(OpTable.create(retTbl)); } }
private static Op rebuild(Op2 subOp, List<Op> ops) { Op chain = OpTable.unit(); for (Op op : ops) { chain = subOp.copy(chain, op); } return chain; }
public static boolean isJoinIdentify(Op op) { if ( ! ( op instanceof OpTable ) ) return false ; Table t = ((OpTable)op).getTable() ; // Safe answer. return TableUnit.isTableUnit(t) ; }
@Override public Op transform(OpMinus opMinus, Op left, Op right) { // If LHS is table empty return table empty // If RHS is table empty can eliminate minus and just leave LHS since no // shared variables means no effect if (isTableEmpty(left)) { return OpTable.empty(); } else if (isTableEmpty(right)) { return left; } return super.transform(opMinus, left, right); }