summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/qe
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/amazon/carbonado/qe')
-rw-r--r--src/main/java/com/amazon/carbonado/qe/FilteringScore.java22
-rw-r--r--src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java11
2 files changed, 9 insertions, 24 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/FilteringScore.java b/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
index 7722873..2a9f354 100644
--- a/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
+++ b/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
@@ -270,27 +270,7 @@ public class FilteringScore<S extends Storable> {
* together produces the original filter.
*/
static <S extends Storable> List<Filter<S>> split(Filter<S> filter) {
- if (filter == null) {
- return null;
- }
-
- filter = filter.conjunctiveNormalForm();
-
- final List<Filter<S>> list = new ArrayList<Filter<S>>();
-
- filter.accept(new Visitor<S, Object, Object>() {
- public Object visit(OrFilter<S> filter, Object param) {
- list.add(filter);
- return null;
- }
-
- public Object visit(PropertyFilter<S> filter, Object param) {
- list.add(filter);
- return null;
- }
- }, null);
-
- return list;
+ return filter == null ? null : filter.conjunctiveNormalFormSplit();
}
private final OrderedProperty<S>[] mIndexProperties;
diff --git a/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java b/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
index 0f4e64d..d947ed7 100644
--- a/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
+++ b/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
@@ -21,6 +21,7 @@ package com.amazon.carbonado.qe;
import java.io.IOException;
import java.util.Comparator;
+import java.util.List;
import java.util.Map;
import org.cojen.classfile.ClassFile;
@@ -394,13 +395,17 @@ public class JoinedQueryExecutor<S extends Storable, T extends Storable>
private static <T extends Storable> OrderingList<T>
expectedOrdering(StorageAccess<T> access, Filter<T> filter, OrderingList<T> ordering)
{
+ List<Filter<T>> split = filter.disjunctiveNormalFormSplit();
+
Comparator comparator = CompositeScore.fullComparator();
CompositeScore bestScore = null;
for (StorableIndex<T> index : access.getAllIndexes()) {
- CompositeScore candidateScore = CompositeScore.evaluate(index, filter, ordering);
- if (bestScore == null || comparator.compare(candidateScore, bestScore) < 0) {
- bestScore = candidateScore;
+ for (Filter<T> sub : split) {
+ CompositeScore candidateScore = CompositeScore.evaluate(index, sub, ordering);
+ if (bestScore == null || comparator.compare(candidateScore, bestScore) < 0) {
+ bestScore = candidateScore;
+ }
}
}