diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-09-04 23:29:27 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-09-04 23:29:27 +0000 |
commit | 49d0e32955c647f33dbfbec592cd77fba3c7d8fa (patch) | |
tree | 7dbeda50d1219fc512d4b788730ef1b88648eca0 /src | |
parent | 1e814b1df1670f0a19a77d55848fe6f836fa4e6b (diff) |
Ensure remainder orderings have a specified direction.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/amazon/carbonado/qe/OrderingScore.java | 11 | ||||
-rw-r--r-- | src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java | 11 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/OrderingScore.java b/src/main/java/com/amazon/carbonado/qe/OrderingScore.java index ce85cb6..a2b46b9 100644 --- a/src/main/java/com/amazon/carbonado/qe/OrderingScore.java +++ b/src/main/java/com/amazon/carbonado/qe/OrderingScore.java @@ -224,6 +224,13 @@ public class OrderingScore<S extends Storable> { }
// Property not handled and not an identity filter.
+
+ if (property.getDirection() == UNSPECIFIED) {
+ // Specify a direction in order for a comparator to be later
+ // created from remainder orderings.
+ property = property.direction(ASCENDING);
+ }
+
remainderProperties.add(property);
indexPos = Integer.MAX_VALUE;
}
@@ -317,7 +324,9 @@ public class OrderingScore<S extends Storable> { /**
* Returns the ordering properties that the evaluated index does not
- * support. The list of orderings is reduced to eliminate redundancies.
+ * support. The list of orderings is reduced to eliminate redundancies. If
+ * any remainder ordering properties originally had an unspecified
+ * direction, the direction in this list is specified as ascending.
*
* @return remainder orderings, never null
*/
diff --git a/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java b/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java index ecacf9a..25e9489 100644 --- a/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java +++ b/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java @@ -584,5 +584,16 @@ public class TestOrderingScore extends TestCase { assertEquals("-id", score.getHandledOrderings().get(0).toString());
assertEquals("-intProp", score.getHandledOrderings().get(1).toString());
assertEquals("-doubleProp", score.getHandledOrderings().get(2).toString());
+
+ ops = makeOrderings(StorableTestBasic.class, "~id", "-intProp", "~longProp");
+
+ score = OrderingScore.evaluate(ix, null, ops);
+ assertEquals(2, score.getHandledCount());
+ assertEquals(1, score.getRemainderCount());
+ assertEquals(true, score.shouldReverseOrder());
+
+ assertEquals("-id", score.getHandledOrderings().get(0).toString());
+ assertEquals("-intProp", score.getHandledOrderings().get(1).toString());
+ assertEquals("+longProp", score.getRemainderOrderings().get(0).toString());
}
}
|