private boolean isTableEmpty(Op op) { if (op instanceof OpTable) { return ((OpTable) op).getTable().isEmpty(); } else { return false; } }
@Override public Table condition(Table left, Table right) { if ( left.isEmpty() ) { left.close(); return right ; } right.close(); return left ; }
@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); }
public static Element createElement(Tables tables) { Table defaultGraphTable = tables.getDefaultGraphTable(); Table namedGraphTable = tables.getNamedGraphTable(); boolean isDefaultGraph = !defaultGraphTable.isEmpty(); boolean isNamedGraph = !namedGraphTable.isEmpty(); //boolean useUnion = ! && !defaultGraphTable.isEmpty(); Element e1 = isDefaultGraph ? createElementDefaultGraph(defaultGraphTable) : null; Element e2 = isNamedGraph ? createElementNamedGraph(namedGraphTable) : null; Element result; if(e1 != null && e2 != null) { ElementUnion tmp = new ElementUnion(); tmp.addElement(e1); tmp.addElement(e2); result = tmp; } else if(e1 != null) { result = e1; } else if(e2 != null) { result = e2; } else { result = null; } return result; }
public static QueryIterator joinWorker(QueryIterator left, Table right, JoinType joinType, ExprList conditions, ExecutionContext execCxt) { if ( right.isEmpty() ) { if ( joinType == INNER ) { // No rows - no match left.close() ; return QueryIterNullIterator.create(execCxt) ; } else // Left join - pass out left rows regardless of conditions. return left ; } if ( TableUnit.isTableUnit(right) ) return applyConditions(left, conditions, execCxt) ; return joinWorkerN(left, right, joinType, conditions, execCxt) ; }
public static Query createQueryCheckExistenceValues(Iterator<Quad> it) { Tables tables = createTablesForQuads(it); boolean useG = !tables.getNamedGraphTable().isEmpty(); Element element = createElement(tables); Query result = new Query(); result.setQuerySelectType(); if(useG) { result.getProject().add(Vars.g); } result.getProject().add(Vars.s); result.getProject().add(Vars.p); result.getProject().add(Vars.o); result.setQueryPattern(element); return result; }
@Override public void visit(OpTable opTable) { if ( TableUnit.isTableUnit(opTable.getTable()) ) { start(opTable, NoNL) ; out.print("unit") ; finish(opTable) ; return ; } if ( TableEmpty.isTableEmpty(opTable.getTable()) ) { start(opTable, NoNL) ; out.print("empty") ; finish(opTable) ; return ; } start(opTable, NoNL) ; WriterNode.outputVars(out, opTable.getTable().getVars(), sContext) ; if ( ! opTable.getTable().isEmpty() ) { out.println(); WriterTable.outputPlain(out, opTable.getTable(), sContext) ; } finish(opTable) ; }