Examples of QueryInfo


Examples of co.cask.cdap.proto.QueryInfo

    for (Map.Entry<QueryHandle, OperationInfo> entry : activeHandleCache.asMap().entrySet()) {
      try {
        // we use empty query statement for get tables, get schemas, we don't need to return it this method call.
        if (!entry.getValue().getStatement().isEmpty()) {
          QueryStatus status = getStatus(entry.getKey());
          result.add(new QueryInfo(entry.getValue().getTimestamp(), entry.getValue().getStatement(),
                                   entry.getKey(), status, true));
        }
      } catch (HandleNotFoundException e) {
        // ignore the handle not found exception. this method returns all queries and handle, if the
        // handle is removed from the internal cache, then there is no point returning them from here.
      }
    }

    for (Map.Entry<QueryHandle, InactiveOperationInfo> entry : inactiveHandleCache.asMap().entrySet()) {
      try {
        // we use empty query statement for get tables, get schemas, we don't need to return it this method call.
        if (!entry.getValue().getStatement().isEmpty()) {
          QueryStatus status = getStatus(entry.getKey());
          result.add(new QueryInfo(entry.getValue().getTimestamp(),
                                   entry.getValue().getStatement(), entry.getKey(), status, false));
        }
      } catch (HandleNotFoundException e) {
        // ignore the handle not found exception. this method returns all queries and handle, if the
        // handle is removed from the internal cache, then there is no point returning them from here.
View Full Code Here

Examples of com.alibaba.wasp.plan.parser.QueryInfo

      metaEventOperation.checkAndGetFields(table, selectItem);

      // Parse The WHERE clause
      SQLExpr where = sqlSelectQueryBlock.getWhere();
      LOG.debug("SELECT SQL:where " + where);
      QueryInfo actionInfo = parseWhereClause(table, metaEventOperation, where, sqlSelectQueryBlock.isForUpdate());
      LOG.debug("ActionInfo " + actionInfo.toString());

      // Parse The Limit clause
      SQLExpr rowCount = null;
      if (sqlSelectQueryBlock.getLimit() != null) {
        rowCount = sqlSelectQueryBlock.getLimit().getRowCount();
      }
      int limit = -1;
      if (rowCount != null) {
        limit = convertToInt(rowCount);
      }

      // Convert to QueryPlan
      if(aggregateInfo == null) {
        convertToQueryPlan(table, context, actionInfo, metaEventOperation,
            selectItem, limit);
      } else {
        actionInfo.setType(QueryInfo.QueryType.AGGREGATE);
        actionInfo.setAggregateInfo(aggregateInfo);
        convertToQueryPlan(table, context, actionInfo, metaEventOperation);
      }
    } else if (sqlSelectQuery instanceof SQLUnionQuery) {
      throw new UnsupportedException("Union clause Unsupported");
    }
View Full Code Here

Examples of com.alibaba.wasp.plan.parser.QueryInfo

      MetaEventOperation metaEventOperation, SQLExpr where, boolean forUpdate) throws IOException {
    LinkedHashMap<String, Condition> conditions = new LinkedHashMap<String, Condition>();
    LinkedHashMap<String, Condition> ranges = new LinkedHashMap<String, Condition>();
    //List<Condition> ranges = new ArrayList<Condition>(5);
    ParserUtils.parse(where, conditions, ranges);
    return new QueryInfo(null, conditions, ranges, forUpdate);
  }
View Full Code Here

Examples of com.alibaba.wasp.plan.parser.QueryInfo

          if (sqlSelectQuery instanceof SQLSelectQueryBlock) {
            SQLSelectQueryBlock sqlSelectQueryBlock = (SQLSelectQueryBlock) sqlSelectQuery;
            // Parse The WHERE clause
            SQLExpr where = sqlSelectQueryBlock.getWhere();
            LOG.debug("SELECT SQL:where " + where);
            QueryInfo queryInfo = druidParser.parseWhereClause(table,
                metaEventOperation, where, false);
            Index index = metaEventOperation.checkAndGetIndex(table,
                queryInfo.getAllConditionFieldName());
            // Get the right Index
            Assert.assertEquals(indexs[i].getIndexName(), index.getIndexName());
          }
        }
        Assert.assertTrue(true);
View Full Code Here

Examples of com.alibaba.wasp.plan.parser.QueryInfo

    fieldValue.put(index1Condition.getFieldName(), index1Condition);
    fieldValue.put(index2Condition.getFieldName(), index2Condition);

    LinkedHashMap<String, Condition> ranges = new LinkedHashMap<String, Condition>();
    ranges.put(index3Condition.getFieldName(), index3Condition);
    return new QueryInfo(QueryInfo.QueryType.SCAN, fieldValue, ranges);
  }
View Full Code Here

Examples of com.facebook.presto.execution.QueryInfo

            throws Exception
    {
        URI location = client.execute(preparePost().setUri(uriFor("/v1/query")).setBodyGenerator(createStaticBodyGenerator("query", UTF_8)).build(), new CreatedResponseHandler());
        assertQueryStatus(location, QueryState.RUNNING);

        QueryInfo queryInfo = client.execute(prepareGet().setUri(location).build(), createJsonResponseHandler(jsonCodec(QueryInfo.class)));
        TaskInfo taskInfo = queryInfo.getOutputStage().getTasks().get(0);
        URI outputLocation = uriFor("/v1/task/" + taskInfo.getTaskId() + "/results/out");

        long sequenceId = 0;
        PagesResponse response = client.execute(
                prepareGet().setUri(uriBuilderFrom(outputLocation).appendPath(String.valueOf(sequenceId)).build()).build(),
View Full Code Here

Examples of com.facebook.presto.execution.QueryInfo

        JsonResponse<QueryInfo> response = client.execute(prepareGet().setUri(statusUri).build(), createFullJsonResponseHandler(jsonCodec(QueryInfo.class)));
        if (expectedQueryState == QueryState.FINISHED && response.getStatusCode() == HttpStatus.GONE.code()) {
            // when query finishes the server may delete it
            return;
        }
        QueryInfo queryInfo = response.getValue();
        assertEquals(queryInfo.getState(), expectedQueryState);
    }
View Full Code Here

Examples of com.facebook.presto.execution.QueryInfo

                    state = QueryState.FAILED;
                    break;
                default:
                    throw new IllegalStateException("Unknown task state " + outputTask.getState());
            }
            return new QueryInfo(outputTaskId.getQueryId(),
                    TEST_SESSION,
                    state,
                    self,
                    ImmutableList.of("out"),
                    "query",
View Full Code Here

Examples of com.facebook.presto.execution.QueryInfo

            checkNotNull(exchangeClient, "exchangeClient is null");

            this.session = session;
            this.queryManager = queryManager;

            QueryInfo queryInfo = queryManager.createQuery(session, query);
            queryId = queryInfo.getQueryId();
            this.exchangeClient = exchangeClient;
        }
View Full Code Here

Examples of com.facebook.presto.execution.QueryInfo

        {
            Iterable<List<Object>> data = getData(maxWaitTime);

            // get the query info before returning
            // force update if query manager is closed
            QueryInfo queryInfo = queryManager.getQueryInfo(queryId);

            // if we have received all of the output data and the query is not marked as done, wait for the query to finish
            if (exchangeClient.isClosed() && !queryInfo.getState().isDone()) {
                queryManager.waitForStateChange(queryId, queryInfo.getState(), maxWaitTime);
                queryInfo = queryManager.getQueryInfo(queryId);
            }

            // close exchange client if the query has failed
            if (queryInfo.getState().isDone()) {
                if (queryInfo.getState() != QueryState.FINISHED) {
                    exchangeClient.close();
                }
                else if (queryInfo.getOutputStage() == null) {
                    // For simple executions (e.g. drop table), there will never be an output stage,
                    // so close the exchange as soon as the query is done.
                    exchangeClient.close();

                    // this is a hack to suppress the warn message in the client saying that there are no columns.
                    // The reason for this is that the current API definition assumes that everything is a query,
                    // so statements without results produce an error in the client otherwise.
                    //
                    // TODO: add support to the API for non-query statements.
                    columns = ImmutableList.of(new Column("result", "varchar"));
                    data = ImmutableSet.<List<Object>>of(ImmutableList.<Object>of("true"));
                }
            }

            // only return a next if the query is not done or there is more data to send (due to buffering)
            URI nextResultsUri = null;
            if ((!queryInfo.getState().isDone()) || (!exchangeClient.isClosed())) {
                nextResultsUri = createNextResultsUri(uriInfo);
            }

            // first time through, self is null
            QueryResults queryResults = new QueryResults(
                    queryId.toString(),
                    uriInfo.getRequestUriBuilder().replaceQuery("").replacePath(queryInfo.getSelf().getPath()).build(),
                    findCancelableLeafStage(queryInfo),
                    nextResultsUri,
                    columns,
                    data,
                    toStatementStats(queryInfo),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.