protected void processResultSet(Function<Row, Boolean> handler, Limit effectiveLimit, ResultSet resultSet, TaskContext taskContext) throws SQLException { while (resultSet.next() && taskContext.isActive()) { Row row = loadIntoRow(resultSet); if (effectiveLimit.nextRow()) { if (!handler.apply(row)) { return; } } if (!effectiveLimit.shouldContinue()) { return; } } }
@Override protected void processResultSet(Function<Row, Boolean> handler, Limit effectiveLimit, ResultSet resultSet, TaskContext taskContext) throws SQLException { while (resultSet.next() && taskContext.isActive()) { Row row = loadIntoRow(resultSet); if (effectiveLimit.nextRow()) { if (!handler.apply(row)) { return; } } if (!effectiveLimit.shouldContinue()) { return; } } }
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; }
@SuppressWarnings("unchecked") protected void execIterate(Function<E, Boolean> handler, Compiler compiler, Limit limit, boolean nativeLimit, ResultSet rs) throws Exception { TaskContext tc = TaskContext.get(); Set<String> columns = dbs.readColumns(rs); while (rs.next() && tc.isActive()) { if (nativeLimit || limit.nextRow()) { SQLEntity e = makeEntity(descriptor, null, columns, rs); compiler.executeJoinFetches(e, columns, rs); if (!handler.apply((E) e)) { return; } } if (!nativeLimit && !limit.shouldContinue()) { return; } } }
/** * Parses the previously supplied input and calls the given consumer for each row. * <p> * Note that this method will close the given input. * * @param consumer the consume to call for each line * @throws IOException if an IO error occures while reading from the given input */ public void execute(Consumer<Values> consumer) throws IOException { try { this.consumer = consumer; TaskContext tc = TaskContext.get(); read(); while (tc.isActive() && !isEOF() && limit.shouldContinue()) { readRow(); consumeNewLine(); } } finally { input.close(); } }
return effectiveLimit.shouldContinue(); }, scrollResponse); } finally {
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; }