private void addImplicitLimit(SubqueryContainer<QueryCommand> container, int rowLimit) { if (container.getCommand().getLimit() != null) { Limit lim = container.getCommand().getLimit(); if (lim.getRowLimit() instanceof Constant) { Constant c = (Constant)lim.getRowLimit(); if (!c.isMultiValued() && Integer.valueOf(rowLimit).compareTo((Integer) c.getValue()) <= 0) { lim.setRowLimit(new Constant(rowLimit)); if (lim.getRowLimit() == null) { lim.setImplicit(true); container.getCommand().setOrderBy(null); } } } return; } boolean addLimit = true; if (container.getCommand() instanceof Query) { Query query = (Query)container.getCommand(); addLimit = !(query.hasAggregates() && query.getGroupBy() == null); } if (addLimit) { Limit lim = new Limit(null, new Constant(rowLimit)); lim.setImplicit(true); container.getCommand().setLimit(lim); } }
private void addImplicitLimit(SubqueryContainer<QueryCommand> container, int rowLimit) { if (container.getCommand().getLimit() != null) { Limit lim = container.getCommand().getLimit(); if (lim.getRowLimit() instanceof Constant) { Constant c = (Constant)lim.getRowLimit(); if (!c.isMultiValued() && Integer.valueOf(rowLimit).compareTo((Integer) c.getValue()) <= 0) { lim.setRowLimit(new Constant(rowLimit)); if (lim.getRowLimit() == null) { lim.setImplicit(true); container.getCommand().setOrderBy(null); } } } return; } boolean addLimit = true; if (container.getCommand() instanceof Query) { Query query = (Query)container.getCommand(); addLimit = !(query.hasAggregates() && query.getGroupBy() == null); } if (addLimit) { Limit lim = new Limit(null, new Constant(rowLimit)); lim.setImplicit(true); container.getCommand().setLimit(lim); } }
private void addImplicitLimit(SubqueryContainer<QueryCommand> container, int rowLimit) { if (container.getCommand().getLimit() != null) { Limit lim = container.getCommand().getLimit(); if (lim.getRowLimit() instanceof Constant) { Constant c = (Constant)lim.getRowLimit(); if (!c.isMultiValued() && Integer.valueOf(rowLimit).compareTo((Integer) c.getValue()) <= 0) { lim.setRowLimit(new Constant(rowLimit)); if (lim.getRowLimit() == null) { lim.setImplicit(true); container.getCommand().setOrderBy(null); } } } return; } boolean addLimit = true; if (container.getCommand() instanceof Query) { Query query = (Query)container.getCommand(); addLimit = !(query.hasAggregates() && query.getGroupBy() == null); } if (addLimit) { Limit lim = new Limit(null, new Constant(rowLimit)); lim.setImplicit(true); container.getCommand().setLimit(lim); } }
private void processLimit(PlanNode node, QueryCommand query, QueryMetadataInterface metadata) { Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); Expression childLimit = null; Expression childOffset = null; if (query.getLimit() != null) { childLimit = query.getLimit().getRowLimit(); childOffset = query.getLimit().getOffset(); } RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset); Limit lim = new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); lim.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT) && (query.getLimit() == null || query.getLimit().isImplicit())); query.setLimit(lim); }
private void processLimit(PlanNode node, QueryCommand query, QueryMetadataInterface metadata) { Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); Expression childLimit = null; Expression childOffset = null; if (query.getLimit() != null) { childLimit = query.getLimit().getRowLimit(); childOffset = query.getLimit().getOffset(); } RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset); Limit lim = new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); lim.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT) && (query.getLimit() == null || query.getLimit().isImplicit())); query.setLimit(lim); }
private void processLimit(PlanNode node, QueryCommand query, QueryMetadataInterface metadata) { Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT); Expression childLimit = null; Expression childOffset = null; if (query.getLimit() != null) { childLimit = query.getLimit().getRowLimit(); childOffset = query.getLimit().getOffset(); } RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset); Limit lim = new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)); lim.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT) && (query.getLimit() == null || query.getLimit().isImplicit())); query.setLimit(lim); }