Skip to content

Commit

Permalink
Revert "GEODE-9632: Allow INDEX_THRESHOLD_SIZE System property to ove…
Browse files Browse the repository at this point in the history
…rride CompiledValue.RESULT_LIMIT (#7010)" (#7787)

This reverts commit 67359dc

(cherry picked from commit 784327a)
  • Loading branch information
nabarunnag committed Jun 9, 2022
1 parent 90cb26b commit f75edd9
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ public void testLimitDistinctIterEvaluatedQueryForResultBagWithIndex() {
assertEquals(5, result.size());
SelectResults wrapper = result;
assertEquals(5, wrapper.asSet().size());
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
} catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
Expand Down Expand Up @@ -710,7 +710,7 @@ public void testLimitDistinctIterEvaluatedQueryForResultBagWithProjectionAttribu
assertEquals(5, result.size());
SelectResults wrapper = result;
assertEquals(5, wrapper.asSet().size());
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
} catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
Expand Down Expand Up @@ -754,7 +754,7 @@ public void testLimitDistinctIterEvaluatedQueryWithDuplicatesInIterationForResul
assertEquals(5, result.size());
SelectResults wrapper = result;
assertEquals(5, wrapper.asSet().size());
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
} catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
Expand Down Expand Up @@ -799,7 +799,7 @@ public void testLimitDistinctIterEvaluatedQueryWithDuplicatesInIterationWithProj
assertEquals(5, result.size());
SelectResults wrapper = result;
assertEquals(5, wrapper.asSet().size());
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
} catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
Expand Down Expand Up @@ -837,7 +837,7 @@ public void testLimitDistinctIterEvaluatedQueryForStructBagWithProjectionAttribu
SelectResults wrapper = result;
assertEquals(5, wrapper.asSet().size());
assertTrue(wrapper.getCollectionType().getElementType() instanceof StructType);
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
} catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
Expand Down Expand Up @@ -919,7 +919,7 @@ public void testLimitDistinctIterEvaluatedQueryWithDuplicatesInIterationWithProj
assertEquals(5, result.size());
SelectResults wrapper = result;
assertEquals(5, wrapper.asSet().size());
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
} catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
Expand Down Expand Up @@ -1051,7 +1051,7 @@ public void testLimitDistinctQueryWithTwoCondWithTwoIndex() {
SelectResults wrapper = result;
assertEquals(10, wrapper.asSet().size());
assertFalse(observer.limitAppliedAtIndex && observer.indexName.equals("idIndex"));
assertFalse(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
assertTrue(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
} catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
Expand Down Expand Up @@ -1130,7 +1130,7 @@ public void testLimitNonDistinctQueryWithTwoCondTwoIndex() {
query = qs.newQuery(qstr);
result = (SelectResults) query.execute();
assertEquals(10, result.size());
assertFalse(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
assertTrue(observer.limitAppliedAtIndex && observer.indexName.equals("statusIndex"));
}
} catch (Exception e) {
CacheUtils.getLogger().error(e);
Expand Down Expand Up @@ -1528,7 +1528,7 @@ public void testLimitOnEqualsCompactRangeIndexedFieldWithAndClauseNonIndexedFiel

assertNotNull(idIndex);
SelectResults resultsWithIndex = (SelectResults) query.execute();
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
assertEquals(5, resultsWithIndex.size());
}

Expand Down Expand Up @@ -1753,7 +1753,7 @@ public void testLimitOnCompactRangeIndexedFieldWithAndClauseJunctionNonIndexedFi

assertNotNull(idIndex);
SelectResults resultsWithIndex = (SelectResults) query.execute();
assertFalse(observer.limitAppliedAtIndex);
assertTrue(observer.limitAppliedAtIndex);
assertEquals(5, resultsWithIndex.size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void testLimitApplicationOnPrimaryKeyIndex() throws Exception {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public void testLimitApplicationOnPrimaryKeyIndex() throws Exception {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@
import org.apache.geode.cache.query.internal.types.StructTypeImpl;
import org.apache.geode.cache.query.types.ObjectType;
import org.apache.geode.internal.Assert;
import org.apache.geode.util.internal.GeodeGlossary;

public abstract class AbstractGroupOrRangeJunction extends AbstractCompiledValue
implements Filter, OQLLexerTokenTypes {
/** left operand */
final CompiledValue[] _operands;
private static final int INDEX_RESULT_THRESHOLD_DEFAULT = 100;
public static final String INDX_THRESHOLD_PROP_STR =
GeodeGlossary.GEMFIRE_PREFIX + "Query.INDEX_THRESHOLD_SIZE";
private static final int indexThresholdSize =
Integer.getInteger(INDX_THRESHOLD_PROP_STR, INDEX_RESULT_THRESHOLD_DEFAULT);
private int _operator = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/
package org.apache.geode.cache.query.internal;

import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -669,9 +667,6 @@ private static int getLimitValue(ExecutionContext context) {
limit = context.cacheGet(CompiledValue.RESULT_LIMIT) != null
? (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT) : -1;
}
if (limit != -1 && limit < indexThresholdSize) {
limit = indexThresholdSize;
}
return limit;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/
package org.apache.geode.cache.query.internal.index;

import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -95,7 +93,6 @@ public class CompactRangeIndex extends AbstractIndex {

private final IndexStore indexStore;


@MutableForTesting
static boolean TEST_ALWAYS_UPDATE_IN_PROGRESS = false;

Expand Down Expand Up @@ -484,9 +481,6 @@ private void lockedQueryPrivate(Object key, int operator, Collection results,
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
if (applyLimit != null && applyLimit) {
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
if (limit < indexThresholdSize) {
limit = indexThresholdSize;
}
}

Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);
Expand Down Expand Up @@ -521,9 +515,6 @@ void lockedQuery(Object lowerBoundKey, int lowerBoundOperator, Object upperBound
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
if (applyLimit != null && applyLimit) {
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
if (limit != -1 && limit < indexThresholdSize) {
limit = indexThresholdSize;
}
}
Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.apache.geode.cache.query.internal.index;

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

import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -494,9 +493,6 @@ private void lockedQueryPrivate(Object key, int operator, Collection results,
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
if (applyLimit != null && applyLimit) {
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
if (limit != -1 && limit < indexThresholdSize) {
limit = indexThresholdSize;
}
}

Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public class IndexManager {
public static final int RECREATE_INDEX = 4;
private final InternalCache cache;
protected final Region region;
String indexThresholdSize =
System.getProperty(GeodeGlossary.GEMFIRE_PREFIX + "Query.INDEX_THRESHOLD_SIZE");

private final boolean isOverFlowToDisk;
private final boolean offHeap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/
package org.apache.geode.cache.query.internal.index;

import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -107,9 +105,6 @@ void lockedQuery(Object key, int operator, Collection results, Set keysToRemove,
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
if (applyLimit != null && applyLimit) {
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
if (limit != -1 && limit < indexThresholdSize) {
limit = indexThresholdSize;
}
}
QueryObserver observer = QueryObserverHolder.getInstance();
if (limit != -1 && results.size() == limit) {
Expand Down Expand Up @@ -186,11 +181,8 @@ void lockedQuery(Object key, int operator, Collection results, CompiledValue ite

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

if (applyLimit != null && applyLimit) {
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
if (limit != -1 && limit < indexThresholdSize) {
limit = indexThresholdSize;
}
if (applyLimit != null && applyLimit.booleanValue()) {
limit = ((Integer) context.cacheGet(CompiledValue.RESULT_LIMIT)).intValue();
}
if (limit != -1 && results.size() == limit) {
observer.limitAppliedAtIndexLevel(this, limit, results);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.apache.geode.cache.query.internal.index;

import static java.lang.Integer.MAX_VALUE;
import static org.apache.geode.cache.query.internal.CompiledValue.indexThresholdSize;
import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;

import java.util.ArrayList;
Expand Down Expand Up @@ -1168,9 +1167,6 @@ void lockedQuery(Object key, int operator, Collection results, CompiledValue ite
Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);
if (applyLimit != null && applyLimit) {
limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT);
if (limit != -1 && limit < indexThresholdSize) {
limit = indexThresholdSize;
}
}

Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX);
Expand Down
Loading

0 comments on commit f75edd9

Please sign in to comment.