private void waitForQuery() { while (client.isValid()) { if (Thread.currentThread().isInterrupted()) { client.close(); throw new RakamException("Query executor thread was interrupted", INTERNAL_SERVER_ERROR); } transformAndAdd(); client.advance(); } }
public QueryResults current() { checkState(isValid(), "current position is not valid (cursor past end)"); return currentResults.get(); }
public QueryResults finalResults() { checkState((!isValid()) || isFailed(), "current position is still valid"); return currentResults.get(); }
private List<String> queryMetadata(String query) { ImmutableList.Builder<String> cache = ImmutableList.builder(); try (StatementClient client = queryRunner.startInternalQuery(query)) { while (client.isValid() && !Thread.currentThread().isInterrupted()) { QueryResults results = client.current(); if (results.getData() != null) { for (List<Object> row : results.getData()) { cache.add((String) row.get(0)); } } client.advance(); } } return cache.build(); }
private void waitForData() { while (client.isValid() && (client.current().getData() == null)) { client.advance(); } }
public void processRows(StatementClient client) throws IOException { while (client.isValid()) { Iterable<List<Object>> data = client.current().getData(); if (data != null) { for (List<Object> row : data) { processRow(unmodifiableList(row)); } } if (nanosSince(bufferStart).compareTo(MAX_BUFFER_TIME) >= 0) { flush(false); } client.advance(); } }
@Override protected Iterable<List<Object>> computeNext() { while (client.isValid()) { Iterable<List<Object>> data = client.current().getData(); client.advance(); if (data != null) { return data; } } if (client.isFailed()) { throw internalServerError(failureMessage(client.finalResults())); } return endOfData(); } }
private static List<Column> getColumns(StatementClient client) { while (client.isValid()) { List<Column> columns = client.current().getColumns(); if (columns != null) { return columns; } client.advance(); } if (!client.isFailed()) { throw internalServerError("No columns"); } throw internalServerError(failureMessage(client.finalResults())); }
while (client.isValid()) { try {
QueryResults results = client.isValid() ? client.current() : client.finalResults(); if (results.getUpdateType() != null) { renderUpdate(errorChannel, results);