use of io.crate.planner.node.fetch.FetchSource in project crate by crate.
the class FetchBatchAccumulatorTest method buildFetchProjectorContext.
private FetchProjectorContext buildFetchProjectorContext() {
Map<String, IntSet> nodeToReaderIds = new HashMap<>(2);
IntSet nodeReadersNodeOne = new IntHashSet();
nodeReadersNodeOne.add(0);
IntSet nodeReadersNodeTwo = new IntHashSet();
nodeReadersNodeTwo.add(2);
nodeToReaderIds.put("nodeOne", nodeReadersNodeOne);
nodeToReaderIds.put("nodeTwo", nodeReadersNodeTwo);
TreeMap<Integer, String> readerIndices = new TreeMap<>();
readerIndices.put(0, "t1");
Map<String, TableIdent> indexToTable = new HashMap<>(1);
indexToTable.put("t1", USER_TABLE_IDENT);
Map<TableIdent, FetchSource> tableToFetchSource = new HashMap<>(2);
FetchSource fetchSource = new FetchSource(Collections.emptyList(), Collections.singletonList(new InputColumn(0)), Collections.singletonList(ID));
tableToFetchSource.put(USER_TABLE_IDENT, fetchSource);
return new FetchProjectorContext(tableToFetchSource, nodeToReaderIds, readerIndices, indexToTable);
}
use of io.crate.planner.node.fetch.FetchSource in project crate by crate.
the class FetchProjectorContext method nodeIdsToStreamers.
public Map<String, ? extends IntObjectMap<Streamer[]>> nodeIdsToStreamers() {
if (nodeIdToReaderIdToStreamers == null) {
nodeIdToReaderIdToStreamers = new HashMap<>(nodeToReaderIds.size(), 1.0f);
for (Map.Entry<String, IntSet> entry : nodeToReaderIds.entrySet()) {
IntObjectHashMap<Streamer[]> readerIdsToStreamers = new IntObjectHashMap<>();
nodeIdToReaderIdToStreamers.put(entry.getKey(), readerIdsToStreamers);
for (IntCursor readerIdCursor : entry.getValue()) {
FetchSource fetchSource = getFetchSource(readerIdCursor.value);
if (fetchSource == null) {
continue;
}
readerIdsToStreamers.put(readerIdCursor.value, Symbols.streamerArray(fetchSource.references()));
}
}
}
return nodeIdToReaderIdToStreamers;
}
use of io.crate.planner.node.fetch.FetchSource in project crate by crate.
the class FetchProjectorContext method createReaderBucket.
private ReaderBucket createReaderBucket(int readerId) {
String index = readerIdToIndex.floorEntry(readerId).getValue();
TableIdent tableIdent = indexToTable.get(index);
FetchSource fetchSource = tableToFetchSource.get(tableIdent);
assert fetchSource != null : "fetchSource must be available";
return new ReaderBucket(!fetchSource.references().isEmpty(), partitionValues(index, fetchSource.partitionedByColumns()));
}
use of io.crate.planner.node.fetch.FetchSource in project crate by crate.
the class MultiSourceFetchPushDown method allocateFetchedReference.
private void allocateFetchedReference(FetchReference fr, DocTableRelation rel) {
FetchSource fs = fetchSources.get(fr.ref().ident().tableIdent());
if (fs == null) {
fs = new FetchSource(rel.tableInfo().partitionedByColumns());
fetchSources.put(fr.ref().ident().tableIdent(), fs);
}
fs.fetchIdCols().add((InputColumn) fr.fetchId());
if (fr.ref().granularity() == RowGranularity.DOC) {
fs.references().add(fr.ref());
}
}
Aggregations