public SetQuery adding( Ordering... orderings ) { List<Ordering> newOrderings = null; if (this.orderings() != null) { newOrderings = new ArrayList<Ordering>(orderings()); for (Ordering ordering : orderings) { newOrderings.add(ordering); } } else { newOrderings = Arrays.asList(orderings); } return new SetQuery(left, operation, right, all, newOrderings, getLimits()); } }
public SetQuery adding( Ordering... orderings ) { List<Ordering> newOrderings = null; if (this.orderings() != null) { newOrderings = new ArrayList<Ordering>(orderings()); for (Ordering ordering : orderings) { newOrderings.add(ordering); } } else { newOrderings = Arrays.asList(orderings); } return new SetQuery(left, operation, right, all, newOrderings, getLimits()); } }
@Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof SetQuery) { SetQuery that = (SetQuery)obj; if (this.hc != that.hc) return false; if (this.operation != that.operation) return false; if (!this.left.equals(that.left)) return false; if (!this.right.equals(that.right)) return false; if (!ObjectUtil.isEqualWithNulls(this.getLimits(), that.getLimits())) return false; if (!ObjectUtil.isEqualWithNulls(this.orderings(), that.orderings())) return false; return true; } return false; }
@Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof SetQuery) { SetQuery that = (SetQuery)obj; if (this.hc != that.hc) return false; if (this.operation != that.operation) return false; if (!this.left.equals(that.left)) return false; if (!this.right.equals(that.right)) return false; if (!ObjectUtil.isEqualWithNulls(this.getLimits(), that.getLimits())) return false; if (!ObjectUtil.isEqualWithNulls(this.orderings(), that.orderings())) return false; return true; } return false; }
@Override public SetQuery withLimit( int rowLimit ) { if (getLimits().getRowLimit() == rowLimit) return this; // nothing to change return new SetQuery(left, operation, right, all, orderings(), getLimits().withRowLimit(rowLimit)); }
@Override public SetQuery withOffset( int offset ) { if (getLimits().getOffset() == offset) return this; // nothing to change return new SetQuery(left, operation, right, all, orderings(), getLimits().withOffset(offset)); }
@Override public SetQuery withOffset( int offset ) { if (getLimits().getOffset() == offset) return this; // nothing to change return new SetQuery(left, operation, right, all, orderings(), getLimits().withOffset(offset)); }
@Override public SetQuery withLimit( int rowLimit ) { if (getLimits().getRowLimit() == rowLimit) return this; // nothing to change return new SetQuery(left, operation, right, all, orderings(), getLimits().withRowLimit(rowLimit)); }
/** * Create a canonical query plan for the given set query. * * @param context the context in which the query is being planned * @param query the set query to be planned * @return the root node of the plan tree representing the canonical plan */ protected PlanNode createCanonicalPlan( QueryContext context, SetQuery query ) { // Process the left and right parts of the query ... PlanNode left = createPlan(context, query.getLeft()); PlanNode right = createPlan(context, query.getRight()); // Wrap in a set operation node ... PlanNode plan = new PlanNode(Type.SET_OPERATION); plan.addChildren(left, right); plan.setProperty(Property.SET_OPERATION, query.operation()); plan.setProperty(Property.SET_USE_ALL, query.isAll()); // Process the orderings and limits ... plan = attachSorting(context, plan, query.orderings()); plan = attachLimits(context, plan, query.getLimits()); // Capture if we're limiting the results to 1 row and no offset and no sorting ... if (query.getLimits().isLimitedToSingleRowWithNoOffset() && query.orderings().isEmpty()) { context.getHints().isExistsQuery = true; } return plan; }
/** * Create a canonical query plan for the given set query. * * @param context the context in which the query is being planned * @param query the set query to be planned * @return the root node of the plan tree representing the canonical plan */ protected PlanNode createCanonicalPlan( QueryContext context, SetQuery query ) { // Process the left and right parts of the query ... PlanNode left = createPlan(context, query.getLeft()); PlanNode right = createPlan(context, query.getRight()); // Wrap in a set operation node ... PlanNode plan = new PlanNode(Type.SET_OPERATION); plan.addChildren(left, right); plan.setProperty(Property.SET_OPERATION, query.operation()); plan.setProperty(Property.SET_USE_ALL, query.isAll()); // Process the orderings and limits ... plan = attachSorting(context, plan, query.orderings()); plan = attachLimits(context, plan, query.getLimits()); // Capture if we're limiting the results to 1 row and no offset and no sorting ... if (query.getLimits().isLimitedToSingleRowWithNoOffset() && query.orderings().isEmpty()) { context.getHints().isExistsQuery = true; } return plan; }