/** * Registers the input {@link CursorResult} and generates a new <code>scrollId</code> to associate with. * * @return the scrollId associated to the cursor result. */ public String registerCursorResult(CursorResult<C, O> cursorResult) { String scrollId = UUID.randomUUID().toString(); return registerCursorResult(scrollId, cursorResult); }
/** * Registers the input {@link C} and generates a new <code>scrollId</code> to associate with. * * @return the scrollId associated to the cursor. */ public String registerCursor(C cursor, int batchSize, int keepAliveSeconds) { return registerCursorResult(new CursorResult<>(cursor, batchSize, keepAliveSeconds)); }
/** * Registers the input {@link C} associated to the input <code>scrollId</code>. * * @return the scrollId associated to the cursor. */ public String registerCursor(String scrollId, C cursor, int batchSize, int keepAliveSeconds) { return registerCursorResult(scrollId, new CursorResult<>(cursor, batchSize, keepAliveSeconds)); }
@Override public ScrollResult<String> scroll(QueryBuilder builder, int batchSize, int keepAliveSeconds) { // as we're using pages to scroll audit, we need to add an order to make results across pages deterministic builder.orders(OrderByExprs.asc(LOG_ID), builder.orders().toArray(new OrderByExpr[0])); String scrollId = cursorService.registerCursorResult( new SQLAuditCursorResult(builder, batchSize, keepAliveSeconds)); return scroll(scrollId); }
@Override public ScrollResult<String> scroll(org.nuxeo.ecm.core.query.sql.model.QueryBuilder builder, int batchSize, int keepAliveSeconds) { // prepare parameters MultiExpression predicate = builder.predicate(); OrderByList orders = builder.orders(); // create source SearchSourceBuilder source = createSearchRequestSource(predicate, orders); source.size(batchSize); // create request SearchRequest request = createSearchRequest(); request.source(source).scroll(TimeValue.timeValueSeconds(keepAliveSeconds)); SearchResponse response = runRequest(request); // register cursor String scrollId = cursorService.registerCursorResult(new ESCursorResult(response, batchSize, keepAliveSeconds)); return scroll(scrollId); }