Search in sources :

Example 1 with FetchSource

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);
}
Also used : FetchSource(io.crate.planner.node.fetch.FetchSource) TableIdent(io.crate.metadata.TableIdent) InputColumn(io.crate.analyze.symbol.InputColumn)

Example 2 with FetchSource

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;
}
Also used : FetchSource(io.crate.planner.node.fetch.FetchSource) IntSet(com.carrotsearch.hppc.IntSet) IntObjectHashMap(com.carrotsearch.hppc.IntObjectHashMap) IntCursor(com.carrotsearch.hppc.cursors.IntCursor) HashMap(java.util.HashMap) IntObjectMap(com.carrotsearch.hppc.IntObjectMap) TreeMap(java.util.TreeMap) IntObjectHashMap(com.carrotsearch.hppc.IntObjectHashMap) Map(java.util.Map)

Example 3 with FetchSource

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()));
}
Also used : FetchSource(io.crate.planner.node.fetch.FetchSource) TableIdent(io.crate.metadata.TableIdent)

Example 4 with FetchSource

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());
    }
}
Also used : FetchSource(io.crate.planner.node.fetch.FetchSource)

Aggregations

FetchSource (io.crate.planner.node.fetch.FetchSource)4 TableIdent (io.crate.metadata.TableIdent)2 IntObjectHashMap (com.carrotsearch.hppc.IntObjectHashMap)1 IntObjectMap (com.carrotsearch.hppc.IntObjectMap)1 IntSet (com.carrotsearch.hppc.IntSet)1 IntCursor (com.carrotsearch.hppc.cursors.IntCursor)1 InputColumn (io.crate.analyze.symbol.InputColumn)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1