Skip to content

Commit

Permalink
Fix strictly sequential iterative search
Browse files Browse the repository at this point in the history
However, using cookie here seems more a hack than a solution.
  • Loading branch information
mederly committed Dec 4, 2018
1 parent f94da6c commit 743b74f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Expand Up @@ -177,9 +177,9 @@ public Integer getOffset() {
if (paging == null) {
return null;
}
if (paging.getCookie() != null) {
throw new UnsupportedOperationException("Paging cookie is not supported here.");
}
// if (paging.getCookie() != null) {
// throw new UnsupportedOperationException("Paging cookie is not supported here.");
// }
return paging.getOffset();
}

Expand All @@ -188,9 +188,9 @@ public Integer getMaxSize() {
if (paging == null) {
return null;
}
if (paging.getCookie() != null) {
throw new UnsupportedOperationException("Paging cookie is not supported here.");
}
// if (paging.getCookie() != null) {
// throw new UnsupportedOperationException("Paging cookie is not supported here.");
// }
return paging.getMaxSize();
}

Expand Down
Expand Up @@ -950,7 +950,7 @@ public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(final
filter.checkConsistence(false);
}

if (filter != null && filter instanceof NoneFilter) {
if (filter instanceof NoneFilter) {
result.recordSuccessIfUnknown();
result.cleanupResult();
SearchResultMetadata metadata = new SearchResultMetadata();
Expand Down
Expand Up @@ -78,6 +78,8 @@ public class ObjectRetriever {
private static final Trace LOGGER = TraceManager.getTrace(ObjectRetriever.class);
private static final Trace LOGGER_PERFORMANCE = TraceManager.getTrace(SqlRepositoryServiceImpl.PERFORMANCE_LOG_NAME);

public static final String NULL_OID_MARKER = "###null-oid###"; // brutal hack (TODO)

@Autowired private LookupTableHelper lookupTableHelper;
@Autowired private CertificationCaseHelper caseHelper;
@Autowired private CaseManagementHelper caseManagementHelper;
Expand Down Expand Up @@ -881,7 +883,7 @@ public <T extends ObjectType> void searchObjectsIterativeByPagingStrictlySequent
ObjectPaging paging = prismContext.queryFactory().createPaging();
pagedQuery.setPaging(paging);
main: for (;;) {
paging.setCookie(lastOid);
paging.setCookie(lastOid != null ? lastOid : NULL_OID_MARKER);
paging.setMaxSize(Math.min(batchSize, defaultIfNull(maxSize, Integer.MAX_VALUE)));

List<PrismObject<T>> objects = repositoryService.searchObjects(type, pagedQuery, options, result);
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration;
import com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary;
import com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString;
import com.evolveum.midpoint.repo.sql.helpers.ObjectRetriever;
import com.evolveum.midpoint.repo.sql.query.QueryException;
import com.evolveum.midpoint.repo.sql.query2.definition.*;
import com.evolveum.midpoint.repo.sql.query2.hqm.CountProjectionElement;
Expand Down Expand Up @@ -304,7 +305,8 @@ private void interpretPagingAndSorting(InterpretationContext context, ObjectQuer
RootHibernateQuery hibernateQuery = context.getHibernateQuery();
String rootAlias = hibernateQuery.getPrimaryEntityAlias();

if (query != null && query.getPaging() != null && query.getPaging().hasCookie()) {
//noinspection StringEquality
if (query != null && query.getPaging() != null && query.getPaging().hasCookie() && query.getPaging().getCookie() != ObjectRetriever.NULL_OID_MARKER) {
ObjectPaging paging = query.getPaging();
Condition c = hibernateQuery.createSimpleComparisonCondition(rootAlias + ".oid", paging.getCookie(), ">");
hibernateQuery.addCondition(c);
Expand Down

0 comments on commit 743b74f

Please sign in to comment.