Search in sources :

Example 1 with IntObjectMap

use of com.carrotsearch.hppc.IntObjectMap 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 2 with IntObjectMap

use of com.carrotsearch.hppc.IntObjectMap in project crate by crate.

the class NodeFetchOperation method fetch.

public ListenableFuture<IntObjectMap<StreamBucket>> fetch(UUID jobId, int phaseId, @Nullable IntObjectMap<? extends IntContainer> docIdsToFetch, boolean closeContextOnFinish) {
    SettableFuture<IntObjectMap<StreamBucket>> resultFuture = SettableFuture.create();
    logStartAndSetupLogFinished(jobId, phaseId, resultFuture);
    if (docIdsToFetch == null) {
        if (closeContextOnFinish) {
            tryCloseContext(jobId, phaseId);
        }
        return Futures.immediateFuture(new IntObjectHashMap<>(0));
    }
    JobExecutionContext context = jobContextService.getContext(jobId);
    FetchContext fetchContext = context.getSubContext(phaseId);
    if (closeContextOnFinish) {
        Futures.addCallback(resultFuture, new CloseContextCallback(fetchContext));
    }
    try {
        doFetch(fetchContext, resultFuture, docIdsToFetch);
    } catch (Throwable t) {
        resultFuture.setException(t);
    }
    return resultFuture;
}
Also used : IntObjectMap(com.carrotsearch.hppc.IntObjectMap) JobExecutionContext(io.crate.jobs.JobExecutionContext)

Example 3 with IntObjectMap

use of com.carrotsearch.hppc.IntObjectMap in project crate by crate.

the class FetchProjection method generateStreamersGroupedByReaderAndNode.

@SuppressWarnings({ "rawtypes" })
public Map<String, ? extends IntObjectMap<Streamer[]>> generateStreamersGroupedByReaderAndNode() {
    HashMap<String, IntObjectHashMap<Streamer[]>> streamersByReaderByNode = new HashMap<>();
    for (Map.Entry<String, IntSet> entry : nodeReaders.entrySet()) {
        IntObjectHashMap<Streamer[]> streamersByReaderId = new IntObjectHashMap<>();
        String nodeId = entry.getKey();
        streamersByReaderByNode.put(nodeId, streamersByReaderId);
        for (IntCursor readerIdCursor : entry.getValue()) {
            int readerId = readerIdCursor.value;
            String index = readerIndices.floorEntry(readerId).getValue();
            RelationName relationName = indicesToIdents.get(index);
            FetchSource fetchSource = fetchSources.get(relationName);
            if (fetchSource == null) {
                continue;
            }
            streamersByReaderId.put(readerIdCursor.value, Symbols.streamerArray(fetchSource.references()));
        }
    }
    return streamersByReaderByNode;
}
Also used : FetchSource(io.crate.planner.node.fetch.FetchSource) HashMap(java.util.HashMap) IntObjectHashMap(com.carrotsearch.hppc.IntObjectHashMap) IntObjectHashMap(com.carrotsearch.hppc.IntObjectHashMap) IntSet(com.carrotsearch.hppc.IntSet) Streamer(io.crate.Streamer) IntCursor(com.carrotsearch.hppc.cursors.IntCursor) RelationName(io.crate.metadata.RelationName) HashMap(java.util.HashMap) IntObjectMap(com.carrotsearch.hppc.IntObjectMap) TreeMap(java.util.TreeMap) IntObjectHashMap(com.carrotsearch.hppc.IntObjectHashMap) Map(java.util.Map)

Example 4 with IntObjectMap

use of com.carrotsearch.hppc.IntObjectMap in project graphhopper by graphhopper.

the class QueryGraphTest method testFillVirtualEdges.

@Test
public void testFillVirtualEdges() {
    initGraph(g);
    g.getNodeAccess().setNode(3, 0, 1);
    g.edge(1, 3);
    final int baseNode = 1;
    EdgeIterator iter = g.createEdgeExplorer().setBaseNode(baseNode);
    iter.next();
    QueryResult res1 = createLocationResult(2, 1.7, iter, 1, PILLAR);
    QueryGraph queryGraph = new QueryGraph(g) {

        @Override
        void fillVirtualEdges(IntObjectMap<VirtualEdgeIterator> node2Edge, int towerNode, EdgeExplorer mainExpl) {
            super.fillVirtualEdges(node2Edge, towerNode, mainExpl);
            // ignore nodes should include baseNode == 1
            if (towerNode == 3)
                assertEquals("[3->4]", node2Edge.get(towerNode).toString());
            else if (towerNode == 1)
                assertEquals("[1->4, 1 1-0]", node2Edge.get(towerNode).toString());
            else
                throw new IllegalStateException("not allowed " + towerNode);
        }
    };
    queryGraph.lookup(Arrays.asList(res1));
    EdgeIteratorState state = GHUtility.getEdge(queryGraph, 0, 1);
    assertEquals(4, state.fetchWayGeometry(3).size());
    // fetch virtual edge and check way geometry
    state = GHUtility.getEdge(queryGraph, 4, 3);
    assertEquals(2, state.fetchWayGeometry(3).size());
}
Also used : QueryResult(com.graphhopper.storage.index.QueryResult) IntObjectMap(com.carrotsearch.hppc.IntObjectMap) GHPoint(com.graphhopper.util.shapes.GHPoint) Test(org.junit.Test)

Example 5 with IntObjectMap

use of com.carrotsearch.hppc.IntObjectMap in project crate by crate.

the class TransportFetchOperation method fetch.

@Override
public CompletableFuture<IntObjectMap<? extends Bucket>> fetch(String nodeId, IntObjectMap<? extends IntContainer> toFetch, boolean closeContext) {
    FutureActionListener<NodeFetchResponse, IntObjectMap<? extends Bucket>> listener = new FutureActionListener<>(GET_FETCHED);
    transportFetchNodeAction.execute(nodeId, nodeIdToReaderIdToStreamers.get(nodeId), new NodeFetchRequest(jobId, executionPhaseId, closeContext, toFetch), listener);
    return listener;
}
Also used : NodeFetchRequest(io.crate.executor.transport.NodeFetchRequest) IntObjectMap(com.carrotsearch.hppc.IntObjectMap) Bucket(io.crate.data.Bucket) FutureActionListener(io.crate.action.FutureActionListener) NodeFetchResponse(io.crate.executor.transport.NodeFetchResponse)

Aggregations

IntObjectMap (com.carrotsearch.hppc.IntObjectMap)7 IntObjectHashMap (com.carrotsearch.hppc.IntObjectHashMap)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Streamer (io.crate.Streamer)3 RelationName (io.crate.metadata.RelationName)3 IntArrayList (com.carrotsearch.hppc.IntArrayList)2 IntSet (com.carrotsearch.hppc.IntSet)2 IntCursor (com.carrotsearch.hppc.cursors.IntCursor)2 IntObjectCursor (com.carrotsearch.hppc.cursors.IntObjectCursor)2 BlockBasedRamAccounting (io.crate.breaker.BlockBasedRamAccounting)2 ConcurrentRamAccounting (io.crate.breaker.ConcurrentRamAccounting)2 RamAccounting (io.crate.breaker.RamAccounting)2 SQLExceptions (io.crate.exceptions.SQLExceptions)2 JobsLogs (io.crate.execution.engine.collect.stats.JobsLogs)2 StreamBucket (io.crate.execution.engine.distribution.StreamBucket)2 RootTask (io.crate.execution.jobs.RootTask)2 TasksService (io.crate.execution.jobs.TasksService)2 ThreadPools (io.crate.execution.support.ThreadPools)2 LuceneCollectorExpression (io.crate.expression.reference.doc.lucene.LuceneCollectorExpression)2