@Override public boolean canContainResults() { return status.hasResults(); } }
@Override public boolean canContainResults() { return status.hasResults(); } }
public QueryInfo(long timestamp, String query, QueryHandle handle, QueryStatus status, boolean isActive) { this.timestamp = timestamp; this.statement = query; this.queryHandle = handle.getHandle(); this.status = status.getStatus(); this.hasResults = status.hasResults(); this.isActive = isActive; }
public QueryInfo(long timestamp, String query, QueryHandle handle, QueryStatus status, boolean isActive) { this.timestamp = timestamp; this.statement = query; this.queryHandle = handle.getHandle(); this.status = status.getStatus(); this.hasResults = status.hasResults(); this.isActive = isActive; }
@Override protected QueryResult computeNext() { if (!status.hasResults()) { return endOfData(); } if (delegate != null && delegate.hasNext()) { return delegate.next(); } try { // call the endpoint 'next' to get more results and set delegate List<QueryResult> nextResults = convertRows(exploreClient.nextResults(handle, fetchSize)); delegate = nextResults.iterator(); // At this point, if delegate has no result, there are no more results at all if (!delegate.hasNext()) { return endOfData(); } return delegate.next(); } catch (ExploreException e) { LOG.error("Exception while iterating through the results of query {}", handle.getHandle(), e); throw Throwables.propagate(e); } catch (HandleNotFoundException e) { // Handle may have timed out, or the handle given is just unknown LOG.debug("Received exception", e); return endOfData(); } }
@Override protected QueryResult computeNext() { if (!status.hasResults()) { return endOfData(); } if (delegate != null && delegate.hasNext()) { return delegate.next(); } try { // call the endpoint 'next' to get more results and set delegate List<QueryResult> nextResults = convertRows(exploreClient.nextResults(handle, fetchSize)); delegate = nextResults.iterator(); // At this point, if delegate has no result, there are no more results at all if (!delegate.hasNext()) { return endOfData(); } return delegate.next(); } catch (ExploreException e) { LOG.error("Exception while iterating through the results of query {}", handle.getHandle(), e); throw Throwables.propagate(e); } catch (HandleNotFoundException e) { // Handle may have timed out, or the handle given is just unknown LOG.debug("Received exception", e); return endOfData(); } }
@Override public QueryStatus getStatus(QueryHandle handle) throws ExploreException, HandleNotFoundException, SQLException { startAndWait(); InactiveOperationInfo inactiveOperationInfo = inactiveHandleCache.getIfPresent(handle); if (inactiveOperationInfo != null) { // Operation has been made inactive, so return the saved status. LOG.trace("Returning saved status for inactive handle {}", handle); return inactiveOperationInfo.getStatus(); } try { // Fetch status from Hive QueryStatus status = fetchStatus(getActiveOperationInfo(handle)); LOG.trace("Status of handle {} is {}", handle, status); // No results or error, so can be timed out aggressively if (status.getStatus() == QueryStatus.OpStatus.FINISHED && !status.hasResults()) { // In case of a query that writes to a Dataset, we will always fall into this condition, // and timing out aggressively will also close the transaction and make the writes visible timeoutAggressively(handle, getResultSchema(handle), status); } else if (status.getStatus() == QueryStatus.OpStatus.ERROR) { // getResultSchema will fail if the query is in error timeoutAggressively(handle, ImmutableList.<ColumnDesc>of(), status); } return status; } catch (HiveSQLException e) { throw getSqlException(e); } }
@Override public QueryStatus getStatus(QueryHandle handle) throws ExploreException, HandleNotFoundException, SQLException { startAndWait(); InactiveOperationInfo inactiveOperationInfo = inactiveHandleCache.getIfPresent(handle); if (inactiveOperationInfo != null) { // Operation has been made inactive, so return the saved status. LOG.trace("Returning saved status for inactive handle {}", handle); return inactiveOperationInfo.getStatus(); } try { // Fetch status from Hive QueryStatus status = fetchStatus(getActiveOperationInfo(handle)); LOG.trace("Status of handle {} is {}", handle, status); // No results or error, so can be timed out aggressively if (status.getStatus() == QueryStatus.OpStatus.FINISHED && !status.hasResults()) { // In case of a query that writes to a Dataset, we will always fall into this condition, // and timing out aggressively will also close the transaction and make the writes visible timeoutAggressively(handle, getResultSchema(handle), status); } else if (status.getStatus() == QueryStatus.OpStatus.ERROR) { // getResultSchema will fail if the query is in error timeoutAggressively(handle, ImmutableList.<ColumnDesc>of(), status); } return status; } catch (HiveSQLException e) { throw getSqlException(e); } }
mustCloseHandle = !resultFuture.set(result) || !status.hasResults(); } catch (Exception e) { mustCloseHandle = true;
mustCloseHandle = !resultFuture.set(result) || !status.hasResults(); } catch (Exception e) { mustCloseHandle = true;