From 8f791a3e9e36fac4345ebb75ba1d9fe51b4b1b55 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 7 Sep 2006 01:12:04 +0000 Subject: Initial tests and fixes for union query analysis. --- .../java/com/amazon/carbonado/qe/IndexedQueryAnalyzer.java | 10 ++++++++++ src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/qe') diff --git a/src/main/java/com/amazon/carbonado/qe/IndexedQueryAnalyzer.java b/src/main/java/com/amazon/carbonado/qe/IndexedQueryAnalyzer.java index 76fb5f5..d0bd63f 100644 --- a/src/main/java/com/amazon/carbonado/qe/IndexedQueryAnalyzer.java +++ b/src/main/java/com/amazon/carbonado/qe/IndexedQueryAnalyzer.java @@ -431,6 +431,16 @@ public class IndexedQueryAnalyzer { return new Result(this, filter, getRemainderOrderings()); } + public String toString() { + return "IndexedQueryAnalyzer.Result {score=" + + getCompositeScore() + ", localIndex=" + + getLocalIndex() + ", foreignIndex=" + + getForeignIndex() + ", foreignProperty=" + + getForeignProperty() + ", remainderFilter=" + + getRemainderFilter() + ", remainderOrderings=" + + getRemainderOrderings() + '}'; + } + private boolean equals(Object a, Object b) { return a == null ? (b == null) : (a.equals(b)); } diff --git a/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java b/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java index 9ed94fd..5648d21 100644 --- a/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java +++ b/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java @@ -77,9 +77,13 @@ public class UnionQueryAnalyzer { throw new IllegalArgumentException("Filter must be bound"); } + if (orderings == null) { + orderings = Collections.emptyList(); + } + List.Result> subResults = splitIntoSubResults(filter, orderings); - if (subResults.size() < 1) { + if (subResults.size() <= 1) { // Total ordering not required. return new Result(subResults); } @@ -112,7 +116,7 @@ public class UnionQueryAnalyzer { // since one simple change might alter the query plan. subResults = splitIntoSubResults(filter, orderings); - if (subResults.size() < 1) { + if (subResults.size() <= 1) { // Total ordering no longer required. return new Result(subResults); } @@ -183,7 +187,7 @@ public class UnionQueryAnalyzer { orderings.add(OrderedProperty.get(bestProperty, best.getBestDirection())); subResults = splitIntoSubResults(filter, orderings); - if (subResults.size() < 1) { + if (subResults.size() <= 1) { // Total ordering no longer required. break; } -- cgit v1.2.3