Skip to content

Commit

Permalink
Fix sequential paged iterative search for Oracle
Browse files Browse the repository at this point in the history
Also added forgotten SearchIterativeTest to the test suite.

Unfortunately, because of collation issues, the sequentially paged
iterative search still does not work well. Has to be fixed;
see MID-4896.
  • Loading branch information
mederly committed Sep 13, 2018
1 parent e8d1251 commit b0b2cda
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
Expand Up @@ -202,4 +202,8 @@ protected <O extends ObjectType> void display(String message, PrismObject<O> obj
protected <C extends Containerable> S_ItemEntry deltaFor(Class<C> objectClass) throws SchemaException {
return DeltaBuilder.deltaFor(objectClass, prismContext);
}

protected SqlRepositoryConfiguration getRepositoryConfiguration() {
return ((SqlRepositoryServiceImpl) repositoryService).getConfiguration();
}
}
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.MidPointPrismContextFactory;
import com.evolveum.midpoint.schema.ResultHandler;
Expand Down Expand Up @@ -246,17 +247,29 @@ public void test120DeleteHalf() throws Exception {

int count = repositoryService.countObjects(UserType.class, null, null, result);
assertEquals("Wrong # of objects after operation", COUNT/2, count);

ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext)
.asc(UserType.F_NAME)
.build();
List<PrismObject<UserType>> objectsAfter = repositoryService.searchObjects(UserType.class, query, null, result);
objectsAfter.forEach(o -> System.out.println("Exists: " + o.asObjectable().getName()));
}

@Test
public void test130AddOneForOne() throws Exception {

if (getRepositoryConfiguration().isUsingOracle()) {
return; // MID-4896
}

OperationResult result = new OperationResult("test130AddOneForOne");

final List<PrismObject<UserType>> objects = new ArrayList<>();

ResultHandler<UserType> handler = (object, parentResult) -> {
objects.add(object);
System.out.print("Got object " + object.getOid());
LOGGER.info("Got object {} ({})", object.getOid(), object.asObjectable().getName().getOrig());
try {
int number = Integer.parseInt(object.asObjectable().getCostCenter());
if (number >= 0) {
Expand Down
1 change: 1 addition & 0 deletions repo/repo-sql-impl-test/testng-integration.xml
Expand Up @@ -43,6 +43,7 @@
<class name="com.evolveum.midpoint.repo.sql.closure.OrgClosureCorrectnessTest"/>
<class name="com.evolveum.midpoint.repo.sql.closure.OrgClosureOverwriteAddTest"/>
<class name="com.evolveum.midpoint.repo.sql.SearchTest"/>
<class name="com.evolveum.midpoint.repo.sql.SearchIterativeTest"/>
<class name="com.evolveum.midpoint.repo.sql.CleanupTest"/>
<class name="com.evolveum.midpoint.repo.sql.SearchShadowOwnerTest"/>
<class name="com.evolveum.midpoint.repo.sql.CertificationTest"/>
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.repo.sql;

import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.util.DebugUtil;

/**
* @author Pavol
Expand Down Expand Up @@ -50,11 +51,21 @@ public ObjectPagingAfterOid clone() {
return clone;
}

protected void copyTo(ObjectPagingAfterOid clone) {
private void copyTo(ObjectPagingAfterOid clone) {
super.copyTo(clone);
clone.oidGreaterThan = this.oidGreaterThan;
}

@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
sb.append(super.debugDump(indent));
sb.append("\n");
DebugUtil.indentDebugDump(sb, indent + 1);
sb.append("Oid greater than: ").append(oidGreaterThan);
return sb.toString();
}

public boolean equals(Object o, boolean exact) {
if (this == o)
return true;
Expand All @@ -66,7 +77,6 @@ public boolean equals(Object o, boolean exact) {
ObjectPagingAfterOid that = (ObjectPagingAfterOid) o;

return oidGreaterThan != null ? oidGreaterThan.equals(that.oidGreaterThan) : that.oidGreaterThan == null;

}

@Override
Expand Down
Expand Up @@ -371,9 +371,7 @@ private <T> void logSearchInputParameters(Class<T> type, ObjectQuery query, bool
return;
}

LOGGER.trace("Full query\n{}\nFull paging\n{}",
query == null ? "undefined" : query.debugDump(),
paging != null ? paging.debugDump() : "undefined");
LOGGER.trace("Full query\n{}", query == null ? "undefined" : query.debugDump());

if (iterative) {
LOGGER.trace("Iterative search by paging defined by the configuration: {}, batch size {}",
Expand Down
Expand Up @@ -876,7 +876,7 @@ public <T extends ObjectType> void searchObjectsIterativeByPagingStrictlySequent
pagedQuery = new ObjectQuery();
}

String lastOid = "";
String lastOid = null;
final int batchSize = getConfiguration().getIterativeSearchByPagingBatchSize();

ObjectPagingAfterOid paging = new ObjectPagingAfterOid();
Expand Down

0 comments on commit b0b2cda

Please sign in to comment.