use of io.crate.data.CollectingBatchIterator in project crate by crate.
the class SystemCollectSource method getIterator.
@Override
public CompletableFuture<BatchIterator<Row>> getIterator(TransactionContext txnCtx, CollectPhase phase, CollectTask collectTask, boolean supportMoveToStart) {
RoutedCollectPhase collectPhase = (RoutedCollectPhase) phase;
Map<String, Map<String, IntIndexedContainer>> locations = collectPhase.routing().locations();
String table = Iterables.getOnlyElement(locations.get(clusterService.localNode().getId()).keySet());
RelationName relationName = RelationName.fromIndexName(table);
StaticTableDefinition<?> tableDefinition = tableDefinition(relationName);
User user = requireNonNull(userLookup.findUser(txnCtx.sessionSettings().userName()), "User who invoked a statement must exist");
return CompletableFuture.completedFuture(CollectingBatchIterator.newInstance(() -> {
}, // If data is already local, then `CollectingBatchIterator` takes care of kill handling.
t -> {
}, () -> tableDefinition.retrieveRecords(txnCtx, user).thenApply(records -> recordsToRows(collectPhase, collectTask.txnCtx(), tableDefinition.getReferenceResolver(), supportMoveToStart, records)), tableDefinition.involvesIO()));
}
Aggregations