-
Bug
-
Resolution: Done
-
Critical
-
8.0.0.Beta3
-
None
The hibrid query, mentioned below produces partial or zero results(depending on the data), upon execution.
SELECT p.ID, p.NAME FROM com.testapp.Person p WHERE p.IS_ACTIVE=1 AND p.ID>1000 and p.ID<10000
For the data,
ID | NAME | CITY | IS_ACTIVE
-------------------
2001 person1 city1 0
2002 person1 city1 1
2003 person1 city1 1
2004 person1 city1 0
2005 person1 city2 1
2006 person1 city2 1
2007 person1 city3 0
2008 person1 city3 1
Indexed fields: ID, NAME, CITY
Non-indexed fields: IS_ACTIVE
Query execution returned 0 number of rows, whereas expected result count is 8.
Root cause for the problem is very trivial, and the details are as follows,
As we know, hibrid query execution involves,
- Execution of lucene query that is constructed based on boole shannon expansion
- Applying filter on the results obtained from above operation, in order to cover the conditions that deals with non-indexed fields
In the second step, there is a mismatch between the representation of filter operation return status and the way end of the result list is detected at the outer layer.
As per the current implementation, filter operation returns null, if the filter condition is not satisfied. But, the same is also used for determining whether there are any further results to be retrieved, which is causing the actual problem.
Following changes can resolve the problem,
file: infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java
diff:
Index: infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java
===================================================================
— infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java (revision -----)
+++ infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java (working copy)
@@ -70,12 +70,15 @@
private void update() {
if (!isReady) {
- if (it.hasNext())
{
- Object next = it.next();
- nextResult = objectFilter.filter(next);
- }
else
{ - nextResult = null; - }+ do
Unknown macro: {+ if (it.hasNext()) { + Object next = it.next(); + nextResult = objectFilter.filter(next); + } else { + nextResult = null; + break; + }+ }while (nextResult == null);
isReady = true;
}
}