private boolean processEntity(Function<? super E, Boolean> consumer, Limit lim, TaskContext ctx, RateLimit rateLimit, Set<String> entityDeDuplicator, E entity) { if (!entityDeDuplicator.contains(entity.getId())) { if (lim.nextRow()) { if (!consumer.apply(entity)) { return false; } if (!lim.shouldContinue()) { return false; } } if (rateLimit.check()) { // Check is the user tries to cancel this task if (!ctx.isActive()) { return false; } } } return true; }
scrollResponse = executeScroll(entity -> { if (rateLimit.check() && !ctx.isActive()) { return false;
private boolean processHit(ResultHandler<? super E> handler, EntityDescriptor entityDescriptor, TaskContext ctx, RateLimit rateLimit, Limit lim, SearchHit hit) { try { E entity = clazz.newInstance(); entity.setId(hit.getId()); entity.initSourceTracing(); entity.setVersion(hit.getVersion()); entity.setMatchedNamedQueries(hit.getMatchedQueries()); entityDescriptor.readSource(entity, hit.getSourceAsMap()); if (lim.nextRow()) { if (!handler.handleRow(entity)) { return false; } if (!lim.shouldContinue()) { return false; } } if (rateLimit.check() && !ctx.isActive()) { return false; } } catch (Exception e) { Exceptions.handle().to(IndexAccess.LOG).error(e).handle(); } return true; }