Search in sources :

Example 1 with IntArrayList

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

the class NodeFetchRequest method readFrom.

@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    jobId = new UUID(in.readLong(), in.readLong());
    fetchPhaseId = in.readVInt();
    closeContext = in.readBoolean();
    int numReaders = in.readVInt();
    if (numReaders > 0) {
        IntObjectHashMap<IntArrayList> toFetch = new IntObjectHashMap<>(numReaders);
        for (int i = 0; i < numReaders; i++) {
            int readerId = in.readVInt();
            int numDocs = in.readVInt();
            IntArrayList docs = new IntArrayList(numDocs);
            toFetch.put(readerId, docs);
            for (int j = 0; j < numDocs; j++) {
                docs.add(in.readInt());
            }
            this.toFetch = toFetch;
        }
    }
}
Also used : IntObjectHashMap(com.carrotsearch.hppc.IntObjectHashMap) UUID(java.util.UUID) IntArrayList(com.carrotsearch.hppc.IntArrayList)

Example 2 with IntArrayList

use of com.carrotsearch.hppc.IntArrayList in project elasticsearch by elastic.

the class PortsRange method ports.

public int[] ports() throws NumberFormatException {
    final IntArrayList ports = new IntArrayList();
    iterate(new PortCallback() {

        @Override
        public boolean onPortNumber(int portNumber) {
            ports.add(portNumber);
            return false;
        }
    });
    return ports.toArray();
}
Also used : IntArrayList(com.carrotsearch.hppc.IntArrayList)

Example 3 with IntArrayList

use of com.carrotsearch.hppc.IntArrayList in project elasticsearch by elastic.

the class MultiGetShardRequest method readFrom.

@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    locations = new IntArrayList(size);
    items = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        locations.add(in.readVInt());
        items.add(MultiGetRequest.Item.readItem(in));
    }
    preference = in.readOptionalString();
    refresh = in.readBoolean();
    realtime = in.readBoolean();
}
Also used : IntArrayList(com.carrotsearch.hppc.IntArrayList)

Example 4 with IntArrayList

use of com.carrotsearch.hppc.IntArrayList in project elasticsearch by elastic.

the class SearchScrollQueryThenFetchAsyncAction method executeFetchPhase.

private void executeFetchPhase() throws Exception {
    sortedShardDocs = searchPhaseController.sortDocs(true, queryResults);
    if (sortedShardDocs.length == 0) {
        finishHim(searchPhaseController.reducedQueryPhase(queryResults.asList()));
        return;
    }
    final IntArrayList[] docIdsToLoad = searchPhaseController.fillDocIdsToLoad(queryResults.length(), sortedShardDocs);
    SearchPhaseController.ReducedQueryPhase reducedQueryPhase = searchPhaseController.reducedQueryPhase(queryResults.asList());
    final ScoreDoc[] lastEmittedDocPerShard = searchPhaseController.getLastEmittedDocPerShard(reducedQueryPhase, sortedShardDocs, queryResults.length());
    final AtomicInteger counter = new AtomicInteger(docIdsToLoad.length);
    for (int i = 0; i < docIdsToLoad.length; i++) {
        final int index = i;
        final IntArrayList docIds = docIdsToLoad[index];
        if (docIds != null) {
            final QuerySearchResult querySearchResult = queryResults.get(index);
            ScoreDoc lastEmittedDoc = lastEmittedDocPerShard[index];
            ShardFetchRequest shardFetchRequest = new ShardFetchRequest(querySearchResult.id(), docIds, lastEmittedDoc);
            DiscoveryNode node = nodes.get(querySearchResult.shardTarget().getNodeId());
            searchTransportService.sendExecuteFetchScroll(node, shardFetchRequest, task, new ActionListener<FetchSearchResult>() {

                @Override
                public void onResponse(FetchSearchResult result) {
                    result.shardTarget(querySearchResult.shardTarget());
                    fetchResults.set(index, result);
                    if (counter.decrementAndGet() == 0) {
                        finishHim(reducedQueryPhase);
                    }
                }

                @Override
                public void onFailure(Exception t) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Failed to execute fetch phase", t);
                    }
                    successfulOps.decrementAndGet();
                    if (counter.decrementAndGet() == 0) {
                        finishHim(reducedQueryPhase);
                    }
                }
            });
        } else {
            // the counter is set to the total size of docIdsToLoad which can have null values so we have to count them down too
            if (counter.decrementAndGet() == 0) {
                finishHim(reducedQueryPhase);
            }
        }
    }
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) FetchSearchResult(org.elasticsearch.search.fetch.FetchSearchResult) ShardFetchRequest(org.elasticsearch.search.fetch.ShardFetchRequest) ScoreDoc(org.apache.lucene.search.ScoreDoc) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ScrollQuerySearchResult(org.elasticsearch.search.query.ScrollQuerySearchResult) QuerySearchResult(org.elasticsearch.search.query.QuerySearchResult) IntArrayList(com.carrotsearch.hppc.IntArrayList)

Example 5 with IntArrayList

use of com.carrotsearch.hppc.IntArrayList in project elasticsearch by elastic.

the class SearchPhaseController method fillDocIdsToLoad.

/**
     * Builds an array, with potential null elements, with docs to load.
     */
public IntArrayList[] fillDocIdsToLoad(int numShards, ScoreDoc[] shardDocs) {
    IntArrayList[] docIdsToLoad = new IntArrayList[numShards];
    for (ScoreDoc shardDoc : shardDocs) {
        IntArrayList shardDocIdsToLoad = docIdsToLoad[shardDoc.shardIndex];
        if (shardDocIdsToLoad == null) {
            shardDocIdsToLoad = docIdsToLoad[shardDoc.shardIndex] = new IntArrayList();
        }
        shardDocIdsToLoad.add(shardDoc.doc);
    }
    return docIdsToLoad;
}
Also used : IntArrayList(com.carrotsearch.hppc.IntArrayList) ScoreDoc(org.apache.lucene.search.ScoreDoc)

Aggregations

IntArrayList (com.carrotsearch.hppc.IntArrayList)94 Test (org.junit.jupiter.api.Test)16 RepeatedTest (org.junit.jupiter.api.RepeatedTest)13 GHPoint (com.graphhopper.util.shapes.GHPoint)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)7 IntObjectHashMap (com.carrotsearch.hppc.IntObjectHashMap)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 IntIndexedContainer (com.carrotsearch.hppc.IntIndexedContainer)5 HashMap (java.util.HashMap)5 UUID (java.util.UUID)5 GHIntArrayList (com.graphhopper.coll.GHIntArrayList)4 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)4 RelationName (io.crate.metadata.RelationName)4 IOException (java.io.IOException)4 IntObjectMap (com.carrotsearch.hppc.IntObjectMap)3 IntCursor (com.carrotsearch.hppc.cursors.IntCursor)3 PrepEdgeFilter (com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter)3 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)3