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