use of io.crate.data.AsyncFlatMapBatchIterator in project crate by crate.
the class FetchProjector method create.
public static Projector create(FetchProjection projection, RamAccounting ramAccounting, LongSupplier getBucketsBytesThreshold, TransactionContext txnCtx, NodeContext nodeCtx, FetchOperation fetchOperation) {
final FetchRows fetchRows = FetchRows.create(txnCtx, nodeCtx, projection.fetchSources(), projection.outputSymbols());
EstimateCellsSize estimateRowSize = new EstimateCellsSize(projection.inputTypes());
return (BatchIterator<Row> source) -> {
final long maxBucketsSizeInBytes = getBucketsBytesThreshold.getAsLong();
BatchIterator<ReaderBuckets> buckets = BatchIterators.partition(source, projection.getFetchSize(), () -> new ReaderBuckets(fetchRows, projection::getFetchSourceByReader, estimateRowSize, ramAccounting), ReaderBuckets::add, readerBuckets -> readerBuckets.ramBytesUsed() > maxBucketsSizeInBytes);
return new AsyncFlatMapBatchIterator<>(buckets, new FetchMapper(fetchOperation, projection.nodeReaders()));
};
}
Aggregations