Search in sources :

Example 1 with StreamBucket

use of io.crate.executor.transport.StreamBucket in project crate by crate.

the class JobResponse method streamers.

public void streamers(Streamer<?>[] streamers) {
    List<Bucket> directResponse = directResponse();
    for (Bucket bucket : directResponse) {
        if (bucket instanceof StreamBucket) {
            assert streamers != null : "streamers must not be null";
            ((StreamBucket) bucket).streamers(streamers);
        }
    }
    this.streamers = streamers;
}
Also used : Bucket(io.crate.data.Bucket) StreamBucket(io.crate.executor.transport.StreamBucket) StreamBucket(io.crate.executor.transport.StreamBucket)

Example 2 with StreamBucket

use of io.crate.executor.transport.StreamBucket in project crate by crate.

the class FetchCollector method collect.

public StreamBucket collect(IntContainer docIds) throws IOException {
    StreamBucket.Builder builder = new StreamBucket.Builder(streamers);
    for (IntCursor cursor : docIds) {
        int docId = cursor.value;
        int readerIndex = ReaderUtil.subIndex(docId, readerContexts);
        LeafReaderContext subReaderContext = readerContexts.get(readerIndex);
        setNextDocId(subReaderContext, docId - subReaderContext.docBase);
        builder.add(row);
    }
    return builder.build();
}
Also used : IntCursor(com.carrotsearch.hppc.cursors.IntCursor) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) StreamBucket(io.crate.executor.transport.StreamBucket)

Example 3 with StreamBucket

use of io.crate.executor.transport.StreamBucket in project crate by crate.

the class JobResponse method readFrom.

@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    for (int i = 0; i < size; i++) {
        StreamBucket bucket = new StreamBucket(streamers);
        bucket.readFrom(in);
        directResponse.add(bucket);
    }
}
Also used : StreamBucket(io.crate.executor.transport.StreamBucket)

Example 4 with StreamBucket

use of io.crate.executor.transport.StreamBucket in project crate by crate.

the class NodeFetchOperation method doFetch.

private void doFetch(FetchContext fetchContext, SettableFuture<IntObjectMap<StreamBucket>> resultFuture, IntObjectMap<? extends IntContainer> toFetch) throws Exception {
    final IntObjectHashMap<StreamBucket> fetched = new IntObjectHashMap<>(toFetch.size());
    HashMap<TableIdent, TableFetchInfo> tableFetchInfos = getTableFetchInfos(fetchContext);
    final AtomicReference<Throwable> lastThrowable = new AtomicReference<>(null);
    final AtomicInteger threadLatch = new AtomicInteger(toFetch.size());
    for (IntObjectCursor<? extends IntContainer> toFetchCursor : toFetch) {
        final int readerId = toFetchCursor.key;
        final IntContainer docIds = toFetchCursor.value;
        TableIdent ident = fetchContext.tableIdent(readerId);
        final TableFetchInfo tfi = tableFetchInfos.get(ident);
        assert tfi != null : "tfi must not be null";
        CollectRunnable runnable = new CollectRunnable(tfi.createCollector(readerId), docIds, fetched, readerId, lastThrowable, threadLatch, resultFuture, fetchContext.isKilled());
        try {
            executor.execute(runnable);
        } catch (EsRejectedExecutionException | RejectedExecutionException e) {
            runnable.run();
        }
    }
}
Also used : IntObjectHashMap(com.carrotsearch.hppc.IntObjectHashMap) TableIdent(io.crate.metadata.TableIdent) AtomicReference(java.util.concurrent.atomic.AtomicReference) StreamBucket(io.crate.executor.transport.StreamBucket) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) EsRejectedExecutionException(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IntContainer(com.carrotsearch.hppc.IntContainer) EsRejectedExecutionException(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException)

Example 5 with StreamBucket

use of io.crate.executor.transport.StreamBucket in project crate by crate.

the class DistributedResultRequest method readFrom.

@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    jobId = new UUID(in.readLong(), in.readLong());
    executionPhaseId = in.readVInt();
    bucketIdx = in.readVInt();
    isLast = in.readBoolean();
    inputId = in.readByte();
    boolean failure = in.readBoolean();
    if (failure) {
        throwable = in.readThrowable();
        isKilled = in.readBoolean();
    } else {
        StreamBucket bucket = new StreamBucket(streamers);
        bucket.readFrom(in);
        rows = bucket;
    }
}
Also used : UUID(java.util.UUID) StreamBucket(io.crate.executor.transport.StreamBucket)

Aggregations

StreamBucket (io.crate.executor.transport.StreamBucket)5 IntContainer (com.carrotsearch.hppc.IntContainer)1 IntObjectHashMap (com.carrotsearch.hppc.IntObjectHashMap)1 IntCursor (com.carrotsearch.hppc.cursors.IntCursor)1 Bucket (io.crate.data.Bucket)1 TableIdent (io.crate.metadata.TableIdent)1 UUID (java.util.UUID)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 EsRejectedExecutionException (org.elasticsearch.common.util.concurrent.EsRejectedExecutionException)1