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;
}
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();
}
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);
}
}
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();
}
}
}
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;
}
}
Aggregations