From df422c9673316b6a7ecdb96e314aeabd660985ad Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 29 Jun 2007 05:03:09 +0000 Subject: Fixed IllegalArgumentException with optimized join queries of the form "a.b = ? & (a.c = ? | a.d = ?)". --- .../com/amazon/carbonado/qe/FilteringScore.java | 22 +--------------------- .../amazon/carbonado/qe/JoinedQueryExecutor.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 24 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/qe') 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 { * together produces the original filter. */ static List> split(Filter filter) { - if (filter == null) { - return null; - } - - filter = filter.conjunctiveNormalForm(); - - final List> list = new ArrayList>(); - - filter.accept(new Visitor() { - public Object visit(OrFilter filter, Object param) { - list.add(filter); - return null; - } - - public Object visit(PropertyFilter filter, Object param) { - list.add(filter); - return null; - } - }, null); - - return list; + return filter == null ? null : filter.conjunctiveNormalFormSplit(); } private final OrderedProperty[] 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 private static OrderingList expectedOrdering(StorageAccess access, Filter filter, OrderingList ordering) { + List> split = filter.disjunctiveNormalFormSplit(); + Comparator comparator = CompositeScore.fullComparator(); CompositeScore bestScore = null; for (StorableIndex index : access.getAllIndexes()) { - CompositeScore candidateScore = CompositeScore.evaluate(index, filter, ordering); - if (bestScore == null || comparator.compare(candidateScore, bestScore) < 0) { - bestScore = candidateScore; + for (Filter sub : split) { + CompositeScore candidateScore = CompositeScore.evaluate(index, sub, ordering); + if (bestScore == null || comparator.compare(candidateScore, bestScore) < 0) { + bestScore = candidateScore; + } } } -- cgit v1.2.3