use of com.carrotsearch.hppc.cursors.IntCursor in project crate by crate.
the class BulkShardProcessor method processFailure.
private void processFailure(Throwable e, final ShardId shardId, final Request request, Optional<BulkRetryCoordinator> retryCoordinator) {
trace("execute failure");
e = SQLExceptions.unwrap(e);
// index missing exception on a partition should never bubble, mark all items as failed instead
if (e instanceof IndexNotFoundException && PartitionName.isPartition(request.index())) {
indicesDeleted.add(request.index());
markItemsAsFailedAndReleaseRetryLock(request, retryCoordinator);
return;
}
final BulkRetryCoordinator coordinator;
if (retryCoordinator.isPresent()) {
coordinator = retryCoordinator.get();
} else {
try {
coordinator = bulkRetryCoordinatorPool.coordinator(shardId);
} catch (Throwable coordinatorException) {
setFailure(coordinatorException);
return;
}
}
if (e instanceof EsRejectedExecutionException) {
trace("rejected execution: [%s] - retrying", e.getMessage());
coordinator.retry(request, requestExecutor, new ActionListener<ShardResponse>() {
@Override
public void onResponse(ShardResponse response) {
processResponse(response);
}
@Override
public void onFailure(Throwable e) {
processFailure(e, shardId, request, Optional.of(coordinator));
}
});
} else {
if (retryCoordinator.isPresent()) {
// release failed retry
coordinator.releaseWriteLock();
}
for (IntCursor intCursor : request.itemIndices()) {
synchronized (responsesLock) {
responses.set(intCursor.value, false);
}
}
setFailure(e);
}
}
use of com.carrotsearch.hppc.cursors.IntCursor in project crate by crate.
the class NodeFetchRequest method writeTo.
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeLong(jobId.getMostSignificantBits());
out.writeLong(jobId.getLeastSignificantBits());
out.writeVInt(fetchPhaseId);
out.writeBoolean(closeContext);
if (toFetch == null) {
out.writeVInt(0);
} else {
out.writeVInt(toFetch.size());
for (IntObjectCursor<? extends IntContainer> toFetchCursor : toFetch) {
out.writeVInt(toFetchCursor.key);
out.writeVInt(toFetchCursor.value.size());
for (IntCursor docCursor : toFetchCursor.value) {
out.writeInt(docCursor.value);
}
}
}
}
use of com.carrotsearch.hppc.cursors.IntCursor in project graphhopper by graphhopper.
the class ChangeGraphHelper method applyChange.
private long applyChange(JsonFeature jsonFeature, FlagEncoder encoder) {
long updates = 0;
EdgeFilter filter = new DefaultEdgeFilter(encoder);
GHIntHashSet edges = new GHIntHashSet();
if (jsonFeature.hasGeometry()) {
graphBrowser.fillEdgeIDs(edges, jsonFeature.getGeometry(), filter);
} else if (jsonFeature.getBBox() != null) {
graphBrowser.findEdgesInShape(edges, jsonFeature.getBBox(), filter);
} else
throw new IllegalArgumentException("Feature " + jsonFeature.getId() + " has no geometry and no bbox");
Iterator<IntCursor> iter = edges.iterator();
Map<String, Object> props = jsonFeature.getProperties();
while (iter.hasNext()) {
int edgeId = iter.next().value;
EdgeIteratorState edge = graph.getEdgeIteratorState(edgeId, Integer.MIN_VALUE);
if (props.containsKey("access")) {
boolean value = (boolean) props.get("access");
updates++;
if (enableLogging)
logger.info(encoder.toString() + " - access change via feature " + jsonFeature.getId());
edge.setFlags(encoder.setAccess(edge.getFlags(), value, value));
} else if (props.containsKey("speed")) {
// TODO use different speed for the different directions (see e.g. Bike2WeightFlagEncoder)
double value = ((Number) props.get("speed")).doubleValue();
double oldSpeed = encoder.getSpeed(edge.getFlags());
if (oldSpeed != value) {
updates++;
if (enableLogging)
logger.info(encoder.toString() + " - speed change via feature " + jsonFeature.getId() + ". Old: " + oldSpeed + ", new:" + value);
edge.setFlags(encoder.setSpeed(edge.getFlags(), value));
}
}
}
return updates;
}
use of com.carrotsearch.hppc.cursors.IntCursor in project graphhopper by graphhopper.
the class LocationIndexTree method calcMinDistance.
final double calcMinDistance(double queryLat, double queryLon, GHIntHashSet pointset) {
double min = Double.MAX_VALUE;
Iterator<IntCursor> itr = pointset.iterator();
while (itr.hasNext()) {
int node = itr.next().value;
double lat = nodeAccess.getLat(node);
double lon = nodeAccess.getLon(node);
double dist = distCalc.calcDist(queryLat, queryLon, lat, lon);
if (dist < min) {
min = dist;
}
}
return min;
}
Aggregations