public LimitExec(TaskAttemptContext context, Schema inSchema, Schema outSchema, PhysicalExec child, LimitNode limit) { super(context, inSchema, outSchema, child); this.fetchFirstNum = limit.getFetchFirstNum(); this.fetchCount = 0; }
public LimitExec(TaskAttemptContext context, Schema inSchema, Schema outSchema, PhysicalExec child, LimitNode limit) { super(context, inSchema, outSchema, child); this.fetchFirstNum = limit.getFetchFirstNum(); this.fetchCount = 0; }
@Override public LogicalNode visitLimit(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, LimitNode node, Stack<LogicalNode> stack) throws TajoException { super.visitLimit(context, plan, block, node, stack); if (node.getFetchFirstNum() < 0) { context.state.addVerification(makeSyntaxError("LIMIT must not be negative")); } return node; }
@Override public LogicalNode visitLimit(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, LimitNode node, Stack<LogicalNode> stack) throws TajoException { super.visitLimit(context, plan, block, node, stack); if (node.getFetchFirstNum() < 0) { context.state.addVerification(makeSyntaxError("LIMIT must not be negative")); } return node; }
@Override public LogicalNode visitLimit(SerializeContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, LimitNode limit, Stack<LogicalNode> stack) throws TajoException { super.visitLimit(context, plan, block, limit, stack); int [] childIds = registerGetChildIds(context, limit); PlanProto.LimitNode.Builder limitBuilder = PlanProto.LimitNode.newBuilder(); limitBuilder.setChildSeq(childIds[0]); limitBuilder.setFetchFirstNum(limit.getFetchFirstNum()); PlanProto.LogicalNode.Builder nodeBuilder = createNodeBuilder(context, limit); nodeBuilder.setLimit(limitBuilder); context.treeBuilder.addNodes(nodeBuilder); return limit; }
@Override public LogicalNode visitLimit(SerializeContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, LimitNode limit, Stack<LogicalNode> stack) throws TajoException { super.visitLimit(context, plan, block, limit, stack); int [] childIds = registerGetChildIds(context, limit); PlanProto.LimitNode.Builder limitBuilder = PlanProto.LimitNode.newBuilder(); limitBuilder.setChildSeq(childIds[0]); limitBuilder.setFetchFirstNum(limit.getFetchFirstNum()); PlanProto.LogicalNode.Builder nodeBuilder = createNodeBuilder(context, limit); nodeBuilder.setLimit(limitBuilder); context.treeBuilder.addNodes(nodeBuilder); return limit; }
public void execQueryOnVirtualTable(QueryContext queryContext, Session session, String query, LogicalPlan plan, SubmitQueryResponse.Builder response) throws Exception { int maxRow = Integer.MAX_VALUE; if (plan.getRootBlock().hasNode(NodeType.LIMIT)) { LimitNode limitNode = plan.getRootBlock().getNode(NodeType.LIMIT); maxRow = (int) limitNode.getFetchFirstNum(); } QueryInfo queryInfo = context.getQueryJobManager().createNewSimpleQuery(queryContext, session, query, (LogicalRootNode) plan.getRootBlock().getRoot()); NonForwardQueryResultScanner queryResultScanner = new NonForwardQueryResultSystemScanner( context, plan, queryInfo.getQueryId(), session.getSessionId(), maxRow); queryResultScanner.init(); session.addNonForwardQueryResultScanner(queryResultScanner); response.setState(OK); response.setQueryId(queryInfo.getQueryId().getProto()); response.setResultType(ResultType.ENCLOSED); response.setMaxRowNum(maxRow); response.setTableDesc(queryResultScanner.getTableDesc().getProto()); }
public void execQueryOnVirtualTable(QueryContext queryContext, Session session, String query, LogicalPlan plan, SubmitQueryResponse.Builder response) throws Exception { int maxRow = Integer.MAX_VALUE; if (plan.getRootBlock().hasNode(NodeType.LIMIT)) { LimitNode limitNode = plan.getRootBlock().getNode(NodeType.LIMIT); maxRow = (int) limitNode.getFetchFirstNum(); } QueryInfo queryInfo = context.getQueryJobManager().createNewSimpleQuery(queryContext, session, query, (LogicalRootNode) plan.getRootBlock().getRoot()); NonForwardQueryResultScanner queryResultScanner = new NonForwardQueryResultSystemScanner( context, plan, queryInfo.getQueryId(), session.getSessionId(), maxRow); queryResultScanner.init(); session.addNonForwardQueryResultScanner(queryResultScanner); response.setState(OK); response.setQueryId(queryInfo.getQueryId().getProto()); response.setResultType(ResultType.ENCLOSED); response.setMaxRowNum(maxRow); response.setTableDesc(queryResultScanner.getTableDesc().getProto()); }
if (plan.getRootBlock().hasNode(NodeType.LIMIT)) { LimitNode limitNode = plan.getRootBlock().getNode(NodeType.LIMIT); maxRow = (int) limitNode.getFetchFirstNum(); scanNode.setLimit(maxRow);
public void execSimpleQuery(QueryContext queryContext, Session session, String query, LogicalPlan plan, SubmitQueryResponse.Builder response) throws Exception { ScanNode scanNode = plan.getRootBlock().getNode(NodeType.SCAN); final TableDesc table = scanNode.getTableDesc(); if (table.hasPartition()) { scanNode = plan.getRootBlock().getNode(NodeType.PARTITIONS_SCAN); } final TableDesc resultDesc = new TableDesc("", scanNode.getOutSchema(), new TableMeta(BuiltinStorages.DRAW, table.getMeta().getOptions()), null); // push down limit int maxRow = Integer.MAX_VALUE; if (plan.getRootBlock().hasNode(NodeType.LIMIT)) { LimitNode limitNode = plan.getRootBlock().getNode(NodeType.LIMIT); maxRow = (int) limitNode.getFetchFirstNum(); scanNode.setLimit(maxRow); } final QueryInfo queryInfo = context.getQueryJobManager().createNewSimpleQuery(queryContext, session, query, (LogicalRootNode) plan.getRootBlock().getRoot()); final NonForwardQueryResultScanner queryResultScanner = new NonForwardQueryResultFileScanner( context.getConf(), session.getSessionId(), queryInfo.getQueryId(), scanNode, maxRow); queryResultScanner.init(); session.addNonForwardQueryResultScanner(queryResultScanner); response.setState(OK); response.setQueryId(queryInfo.getQueryId().getProto()); response.setResultType(ResultType.ENCLOSED); response.setMaxRowNum(maxRow); response.setTableDesc(resultDesc.getProto()); }