Skip to content

Commit

Permalink
Remove predicate caching toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Jul 11, 2024
1 parent 95e9ef8 commit 9037d1e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 deletions.
57 changes: 25 additions & 32 deletions src/main/java/org/javarosa/core/model/FormDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,6 @@

package org.javarosa.core.model;

import static java.util.Collections.emptyList;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.javarosa.core.model.TriggerableDag.EventNotifierAccessor;
import org.javarosa.core.model.actions.ActionController;
import org.javarosa.core.model.actions.Actions;
Expand Down Expand Up @@ -85,6 +66,26 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Collections.emptyList;

/**
* Definition of a form. This has some meta data about the form definition and a
* collection of groups together with question branching or skipping rules.
Expand Down Expand Up @@ -162,7 +163,6 @@ public static IDataReference getAbsRef(IDataReference ref, TreeReference parentR

private TriggerableDag dagImpl;

private boolean predicateCaching = true;
private final FilterStrategy comparisonExpressionCacheFilterStrategy = new ComparisonExpressionCacheFilterStrategy();
private final FilterStrategy equalityExpressionIndexFilterStrategy = new EqualityExpressionIndexFilterStrategy();
private final Queue<FilterStrategy> customFilterStrategies = new LinkedList<>();
Expand Down Expand Up @@ -830,14 +830,12 @@ public boolean realTime() {
evaluationContext.addFunctionHandler(new ChoiceNameFunctionHandler(this) );
}

if (predicateCaching) {
List<FilterStrategy> filters = Stream.concat(
customFilterStrategies.stream(),
Stream.of(equalityExpressionIndexFilterStrategy, comparisonExpressionCacheFilterStrategy)
).collect(Collectors.toList());
List<FilterStrategy> filters = Stream.concat(
customFilterStrategies.stream(),
Stream.of(equalityExpressionIndexFilterStrategy, comparisonExpressionCacheFilterStrategy)
).collect(Collectors.toList());

evaluationContext = new EvaluationContext(evaluationContext, filters);
}
evaluationContext = new EvaluationContext(evaluationContext, filters);

for (IFunctionHandler functionHandler : customFunctionHandlers) {
evaluationContext.addFunctionHandler(functionHandler);
Expand Down Expand Up @@ -1631,11 +1629,6 @@ public Extras<Externalizable> getExtras() {
return extras;
}

public void disablePredicateCaching() {
predicateCaching = false;
dagImpl.disablePredicateCaching();
}

public void addFilterStrategy(FilterStrategy filterStrategy) {
customFilterStrategies.add(filterStrategy);
resetEvaluationContext();
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/javarosa/form/api/FormEntryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@ private static FormIndex getRepeatGroupIndex(FormIndex index, FormDef formDef) {
}
}

public void disablePredicateCaching() {
model.getForm().disablePredicateCaching();
}

public void addFilterStrategy(FilterStrategy filterStrategy) {
model.getForm().addFilterStrategy(filterStrategy);
}
Expand Down

0 comments on commit 9037d1e

Please sign in to comment.