@Override public List<? extends Column> columns() { return left.columns(); // equivalent to right columns }
@Override public void setLimit( long limit ) { if (limit > Integer.MAX_VALUE) limit = Integer.MAX_VALUE; query = query.withLimit((int)limit); // may not actually change if the limit matches the existing query }
@Override public void setOffset( long offset ) { if (offset > Integer.MAX_VALUE) offset = Integer.MAX_VALUE; query = query.withOffset((int)offset); // may not actually change if the offset matches the existing query } }
@Override public void visit( Subquery subquery ) { subqueries.add(subquery); if (includeNestedSubqueries) { // Now look for any subqueries in the subquery ... subquery.getQuery().accept(this); } } });
@Override public void visit( Subquery subquery ) { subqueries.add(subquery); if (includeNestedSubqueries) { // Now look for any subqueries in the subquery ... subquery.getQuery().accept(this); } } });
/** * Validate the supplied query. * * @param context the context in which the query is being planned * @param query the set query to be planned * @param usedSelectors the map of {@link SelectorName}s (aliases or names) used in the query. */ protected void validate( QueryContext context, QueryCommand query, Map<SelectorName, Table> usedSelectors ) { // // Resolve everything ... // Visitors.visitAll(query, new Validator(context, usedSelectors)); // Resolve everything (except subqueries) ... Validator validator = new Validator(context, usedSelectors); query.accept(new WalkAllVisitor(validator) { @Override protected void enqueue( Visitable objectToBeVisited ) { if (objectToBeVisited instanceof Subquery) return; super.enqueue(objectToBeVisited); } }); }
@Override public List<? extends Column> columns() { return left.columns(); // equivalent to right columns }
@Override public void setOffset( long offset ) { if (offset > Integer.MAX_VALUE) offset = Integer.MAX_VALUE; query = query.withOffset((int)offset); // may not actually change if the offset matches the existing query } }
@Override public void setLimit( long limit ) { if (limit > Integer.MAX_VALUE) limit = Integer.MAX_VALUE; query = query.withLimit((int)limit); // may not actually change if the limit matches the existing query }
/** * Validate the supplied query. * * @param context the context in which the query is being planned * @param query the set query to be planned * @param usedSelectors the map of {@link SelectorName}s (aliases or names) used in the query. */ protected void validate( QueryContext context, QueryCommand query, Map<SelectorName, Table> usedSelectors ) { // // Resolve everything ... // Visitors.visitAll(query, new Validator(context, usedSelectors)); // Resolve everything (except subqueries) ... Validator validator = new Validator(context, usedSelectors); query.accept(new WalkAllVisitor(validator) { @Override protected void enqueue( Visitable objectToBeVisited ) { if (objectToBeVisited instanceof Subquery) return; super.enqueue(objectToBeVisited); } }); }
@Override public void visit( Subquery subquery ) { append('('); subquery.getQuery().accept(this); append(')'); }
@Override public void visit( Subquery subquery ) { append('('); subquery.getQuery().accept(this); append(')'); }
/** * Create a set query involving the supplied left- and right-hand-side queries. * * @param left the left-hand-side query being combined * @param operation the set operation * @param right the right-hand-side query being combined * @param all true if all of the results should be included * @throws IllegalArgumentException if the left-hand-side query, right-hand-side query, or operation are null */ public SetQuery( QueryCommand left, Operation operation, QueryCommand right, boolean all ) { CheckArg.isNotNull(left, "left"); CheckArg.isNotNull(right, "right"); CheckArg.isNotNull(operation, "operation"); if (!unionableColumns(left.columns(), right.columns())) { I18n msg = GraphI18n.leftAndRightQueriesInSetQueryMustHaveUnionableColumns; throw new IllegalArgumentException(msg.text(left.columns(), right.columns())); } this.left = left; this.right = right; this.operation = operation; this.all = all; this.orderings = Collections.<Ordering>emptyList(); this.limits = Limit.NONE; this.hc = HashCode.compute(this.left, this.right, this.operation); }
/** * Create a set query involving the supplied left- and right-hand-side queries. * * @param left the left-hand-side query being combined * @param operation the set operation * @param right the right-hand-side query being combined * @param all true if all of the results should be included * @throws IllegalArgumentException if the left-hand-side query, right-hand-side query, or operation are null */ public SetQuery( QueryCommand left, Operation operation, QueryCommand right, boolean all ) { CheckArg.isNotNull(left, "left"); CheckArg.isNotNull(right, "right"); CheckArg.isNotNull(operation, "operation"); if (!unionableColumns(left.columns(), right.columns())) { I18n msg = GraphI18n.leftAndRightQueriesInSetQueryMustHaveUnionableColumns; throw new IllegalArgumentException(msg.text(left.columns(), right.columns())); } this.left = left; this.right = right; this.operation = operation; this.all = all; this.orderings = Collections.<Ordering>emptyList(); this.limits = Limit.NONE; this.hc = HashCode.compute(this.left, this.right, this.operation); }