Search in sources :

Example 1 with AsyncFlatMapBatchIterator

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()));
    };
}
Also used : TransactionContext(io.crate.metadata.TransactionContext) ByteSizeUnit(org.elasticsearch.common.unit.ByteSizeUnit) NodeContext(io.crate.metadata.NodeContext) LongSupplier(java.util.function.LongSupplier) BatchIterator(io.crate.data.BatchIterator) RamAccounting(io.crate.breaker.RamAccounting) Projector(io.crate.data.Projector) EstimateCellsSize(io.crate.breaker.EstimateCellsSize) BatchIterators(io.crate.data.BatchIterators) Row(io.crate.data.Row) AsyncFlatMapBatchIterator(io.crate.data.AsyncFlatMapBatchIterator) CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) FetchProjection(io.crate.execution.dsl.projection.FetchProjection) EstimateCellsSize(io.crate.breaker.EstimateCellsSize) BatchIterator(io.crate.data.BatchIterator) AsyncFlatMapBatchIterator(io.crate.data.AsyncFlatMapBatchIterator) Row(io.crate.data.Row)

Aggregations

EstimateCellsSize (io.crate.breaker.EstimateCellsSize)1 RamAccounting (io.crate.breaker.RamAccounting)1 AsyncFlatMapBatchIterator (io.crate.data.AsyncFlatMapBatchIterator)1 BatchIterator (io.crate.data.BatchIterator)1 BatchIterators (io.crate.data.BatchIterators)1 Projector (io.crate.data.Projector)1 Row (io.crate.data.Row)1 FetchProjection (io.crate.execution.dsl.projection.FetchProjection)1 NodeContext (io.crate.metadata.NodeContext)1 TransactionContext (io.crate.metadata.TransactionContext)1 LongSupplier (java.util.function.LongSupplier)1 CircuitBreaker (org.elasticsearch.common.breaker.CircuitBreaker)1 ByteSizeUnit (org.elasticsearch.common.unit.ByteSizeUnit)1