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