Skip to content

Commit f75edd9

Browse files
committed
Revert "GEODE-9632: Allow INDEX_THRESHOLD_SIZE System property to override CompiledValue.RESULT_LIMIT (#7010)" (#7787)
This reverts commit 67359dc (cherry picked from commit 784327a)
1 parent 90cb26b commit f75edd9

File tree

11 files changed

+18
-252
lines changed

11 files changed

+18
-252
lines changed

geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/LimitClauseJUnitTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ public void testLimitDistinctIterEvaluatedQueryForResultBagWithIndex() {
673673
assertEquals(5, result.size());
674674
SelectResults wrapper = result;
675675
assertEquals(5, wrapper.asSet().size());
676-
assertFalse(observer.limitAppliedAtIndex);
676+
assertTrue(observer.limitAppliedAtIndex);
677677
} catch (Exception e) {
678678
CacheUtils.getLogger().error(e);
679679
fail(e.toString());
@@ -710,7 +710,7 @@ public void testLimitDistinctIterEvaluatedQueryForResultBagWithProjectionAttribu
710710
assertEquals(5, result.size());
711711
SelectResults wrapper = result;
712712
assertEquals(5, wrapper.asSet().size());
713-
assertFalse(observer.limitAppliedAtIndex);
713+
assertTrue(observer.limitAppliedAtIndex);
714714
} catch (Exception e) {
715715
CacheUtils.getLogger().error(e);
716716
fail(e.toString());
@@ -754,7 +754,7 @@ public void testLimitDistinctIterEvaluatedQueryWithDuplicatesInIterationForResul
754754
assertEquals(5, result.size());
755755
SelectResults wrapper = result;
756756
assertEquals(5, wrapper.asSet().size());
757-
assertFalse(observer.limitAppliedAtIndex);
757+
assertTrue(observer.limitAppliedAtIndex);
758758
} catch (Exception e) {
759759
CacheUtils.getLogger().error(e);
760760
fail(e.toString());
@@ -799,7 +799,7 @@ public void testLimitDistinctIterEvaluatedQueryWithDuplicatesInIterationWithProj
799799
assertEquals(5, result.size());
800800
SelectResults wrapper = result;
801801
assertEquals(5, wrapper.asSet().size());
802-
assertFalse(observer.limitAppliedAtIndex);
802+
assertTrue(observer.limitAppliedAtIndex);
803803
} catch (Exception e) {
804804
CacheUtils.getLogger().error(e);
805805
fail(e.toString());
@@ -837,7 +837,7 @@ public void testLimitDistinctIterEvaluatedQueryForStructBagWithProjectionAttribu
837837
SelectResults wrapper = result;
838838
assertEquals(5, wrapper.asSet().size());
839839
assertTrue(wrapper.getCollectionType().getElementType() instanceof StructType);
840-
assertFalse(observer.limitAppliedAtIndex);
840+
assertTrue(observer.limitAppliedAtIndex);
841841
} catch (Exception e) {
842842
CacheUtils.getLogger().error(e);
843843
fail(e.toString());
@@ -919,7 +919,7 @@ public void testLimitDistinctIterEvaluatedQueryWithDuplicatesInIterationWithProj
919919
assertEquals(5, result.size());
920920
SelectResults wrapper = result;
921921
assertEquals(5, wrapper.asSet().size());
922-
assertFalse(observer.limitAppliedAtIndex);
922+
assertTrue(observer.limitAppliedAtIndex);
923923
} catch (Exception e) {
924924
CacheUtils.getLogger().error(e);
925925
fail(e.toString());
@@ -1051,7 +1051,7 @@ public void testLimitDistinctQueryWithTwoCondWithTwoIndex() {
10511051
SelectResults wrapper = result;
10521052
assertEquals(10, wrapper.asSet().size());
10531053
assertFalse(observer.limitAppliedAtIndex && observer.indexName.equals("idIndex"));
1054-
assertFalse(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
1054+
assertTrue(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
10551055
} catch (Exception e) {
10561056
CacheUtils.getLogger().error(e);
10571057
fail(e.toString());
@@ -1130,7 +1130,7 @@ public void testLimitNonDistinctQueryWithTwoCondTwoIndex() {
11301130
query = qs.newQuery(qstr);
11311131
result = (SelectResults) query.execute();
11321132
assertEquals(10, result.size());
1133-
assertFalse(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
1133+
assertTrue(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
11341134
}
11351135
} catch (Exception e) {
11361136
CacheUtils.getLogger().error(e);
@@ -1528,7 +1528,7 @@ public void testLimitOnEqualsCompactRangeIndexedFieldWithAndClauseNonIndexedFiel
15281528

15291529
assertNotNull(idIndex);
15301530
SelectResults resultsWithIndex = (SelectResults) query.execute();
1531-
assertFalse(observer.limitAppliedAtIndex);
1531+
assertTrue(observer.limitAppliedAtIndex);
15321532
assertEquals(5, resultsWithIndex.size());
15331533
}
15341534

@@ -1753,7 +1753,7 @@ public void testLimitOnCompactRangeIndexedFieldWithAndClauseJunctionNonIndexedFi
17531753

17541754
assertNotNull(idIndex);
17551755
SelectResults resultsWithIndex = (SelectResults) query.execute();
1756-
assertFalse(observer.limitAppliedAtIndex);
1756+
assertTrue(observer.limitAppliedAtIndex);
17571757
assertEquals(5, resultsWithIndex.size());
17581758
}
17591759

geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/NonDistinctOrderByReplicatedJUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void testLimitApplicationOnPrimaryKeyIndex() throws Exception {
188188

189189
Region r1 = createRegion("portfolio1", Portfolio.class);
190190

191-
for (int i = 0; i < 200; i++) {
191+
for (int i = 0; i < 50; i++) {
192192
r1.put(i + "", new Portfolio(i));
193193
}
194194

geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/OrderByReplicatedJUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public void testLimitApplicationOnPrimaryKeyIndex() throws Exception {
433433

434434
Region r1 = createRegion("portfolio1", Portfolio.class);
435435

436-
for (int i = 0; i < 200; i++) {
436+
for (int i = 0; i < 50; i++) {
437437
r1.put(i + "", new Portfolio(i));
438438
}
439439

geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@
3535
import org.apache.geode.cache.query.internal.types.StructTypeImpl;
3636
import org.apache.geode.cache.query.types.ObjectType;
3737
import org.apache.geode.internal.Assert;
38+
import org.apache.geode.util.internal.GeodeGlossary;
3839

3940
public abstract class AbstractGroupOrRangeJunction extends AbstractCompiledValue
4041
implements Filter, OQLLexerTokenTypes {
4142
/** left operand */
4243
final CompiledValue[] _operands;
44+
private static final int INDEX_RESULT_THRESHOLD_DEFAULT = 100;
45+
public static final String INDX_THRESHOLD_PROP_STR =
46+
GeodeGlossary.GEMFIRE_PREFIX + "Query.INDEX_THRESHOLD_SIZE";
4347
private static final int indexThresholdSize =
4448
Integer.getInteger(INDX_THRESHOLD_PROP_STR, INDEX_RESULT_THRESHOLD_DEFAULT);
4549
private int _operator = 0;

geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryUtils.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515
package org.apache.geode.cache.query.internal;
1616

17-
import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;
18-
1917
import java.util.ArrayList;
2018
import java.util.Collections;
2119
import java.util.HashSet;
@@ -669,9 +667,6 @@ private static int getLimitValue(ExecutionContext context) {
669667
limit = context.cacheGet(CompiledValue.RESULT_LIMIT) != null
670668
? (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT) : -1;
671669
}
672-
if (limit != -1 && limit < indexThresholdSize) {
673-
limit = indexThresholdSize;
674-
}
675670
return limit;
676671
}
677672

geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515
package org.apache.geode.cache.query.internal.index;
1616

17-
import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;
18-
1917
import java.util.ArrayList;
2018
import java.util.Collection;
2119
import java.util.HashSet;
@@ -95,7 +93,6 @@ public class CompactRangeIndex extends AbstractIndex {
9593

9694
private final IndexStore indexStore;
9795

98-
9996
@MutableForTesting
10097
static boolean TEST_ALWAYS_UPDATE_IN_PROGRESS = false;
10198

@@ -484,9 +481,6 @@ private void lockedQueryPrivate(Object key, int operator, Collection results,
484481
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
485482
if (applyLimit != null && applyLimit) {
486483
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
487-
if (limit < indexThresholdSize) {
488-
limit = indexThresholdSize;
489-
}
490484
}
491485

492486
Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);
@@ -521,9 +515,6 @@ void lockedQuery(Object lowerBoundKey, int lowerBoundOperator, Object upperBound
521515
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
522516
if (applyLimit != null && applyLimit) {
523517
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
524-
if (limit != -1 && limit < indexThresholdSize) {
525-
limit = indexThresholdSize;
526-
}
527518
}
528519
Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);
529520

geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.apache.geode.cache.query.internal.index;
1616

1717
import static java.lang.System.lineSeparator;
18-
import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;
1918

2019
import java.util.ArrayList;
2120
import java.util.Collection;
@@ -494,9 +493,6 @@ private void lockedQueryPrivate(Object key, int operator, Collection results,
494493
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
495494
if (applyLimit != null && applyLimit) {
496495
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
497-
if (limit != -1 && limit < indexThresholdSize) {
498-
limit = indexThresholdSize;
499-
}
500496
}
501497

502498
Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);

geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ public class IndexManager {
8686
public static final int RECREATE_INDEX = 4;
8787
private final InternalCache cache;
8888
protected final Region region;
89-
String indexThresholdSize =
90-
System.getProperty(GeodeGlossary.GEMFIRE_PREFIX + "Query.INDEX_THRESHOLD_SIZE");
9189

9290
private final boolean isOverFlowToDisk;
9391
private final boolean offHeap;

geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PrimaryKeyIndex.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515
package org.apache.geode.cache.query.internal.index;
1616

17-
import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;
18-
1917
import java.util.Collection;
2018
import java.util.Iterator;
2119
import java.util.List;
@@ -107,9 +105,6 @@ void lockedQuery(Object key, int operator, Collection results, Set keysToRemove,
107105
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
108106
if (applyLimit != null && applyLimit) {
109107
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
110-
if (limit != -1 && limit < indexThresholdSize) {
111-
limit = indexThresholdSize;
112-
}
113108
}
114109
QueryObserver observer = QueryObserverHolder.getInstance();
115110
if (limit != -1 && results.size() == limit) {
@@ -186,11 +181,8 @@ void lockedQuery(Object key, int operator, Collection results, CompiledValue ite
186181

187182
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
188183

189-
if (applyLimit != null && applyLimit) {
190-
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
191-
if (limit != -1 && limit < indexThresholdSize) {
192-
limit = indexThresholdSize;
193-
}
184+
if (applyLimit != null && applyLimit.booleanValue()) {
185+
limit = ((Integer) context.cacheGet(CompiledValue.RESULT_LIMIT)).intValue();
194186
}
195187
if (limit != -1 && results.size() == limit) {
196188
observer.limitAppliedAtIndexLevel(this, limit, results);

geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.apache.geode.cache.query.internal.index;
1616

1717
import static java.lang.Integer.MAX_VALUE;
18-
import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;
1918
import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
2019

2120
import java.util.ArrayList;
@@ -1168,9 +1167,6 @@ void lockedQuery(Object key, int operator, Collection results, CompiledValue ite
11681167
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
11691168
if (applyLimit != null && applyLimit) {
11701169
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
1171-
if (limit != -1 && limit < indexThresholdSize) {
1172-
limit = indexThresholdSize;
1173-
}
11741170
}
11751171

11761172
Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);

0 commit comments

Comments
 (0)