diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-09-05 01:31:18 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-09-05 01:31:18 +0000 |
commit | 84a22c3b1003a29344859b8af286e37bbe4c7b21 (patch) | |
tree | 9c0171da5d1d5aab31ebb881e9fc88deb62dc217 /src/test/java/com | |
parent | b3444c71bf298e9c62a8fcd35ee0e83772e0fe82 (diff) |
Added support to get free and unused orderings.
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java b/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java index 83b2364..02f7808 100644 --- a/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java +++ b/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java @@ -596,4 +596,88 @@ public class TestOrderingScore extends TestCase { assertEquals("-intProp", score.getHandledOrderings().get(1).toString());
assertEquals("~longProp", score.getRemainderOrderings().get(0).toString());
}
+
+ public void testFreeOrderings() throws Exception {
+ final StorableIndex<StorableTestBasic> ix;
+ List<OrderedProperty<StorableTestBasic>> ops;
+ OrderingScore score;
+ Filter<StorableTestBasic> filter = null;
+
+ ix = makeIndex(StorableTestBasic.class, "id", "intProp", "doubleProp");
+ ops = makeOrderings(StorableTestBasic.class, "~id");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(1, score.getHandledCount());
+ assertEquals(0, score.getRemainderCount());
+ assertEquals(false, score.shouldReverseOrder());
+ assertEquals(2, score.getFreeOrderings().size());
+ assertEquals("~intProp", score.getFreeOrderings().get(0).toString());
+ assertEquals("~doubleProp", score.getFreeOrderings().get(1).toString());
+ assertEquals(0, score.getUnusedOrderings().size());
+
+ ops = makeOrderings(StorableTestBasic.class, "~id", "-intProp");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(2, score.getHandledCount());
+ assertEquals(0, score.getRemainderCount());
+ assertEquals(true, score.shouldReverseOrder());
+ assertEquals(1, score.getFreeOrderings().size());
+ assertEquals("-doubleProp", score.getFreeOrderings().get(0).toString());
+ assertEquals(0, score.getUnusedOrderings().size());
+
+ ops = makeOrderings(StorableTestBasic.class, "~id", "-intProp", "+doubleProp");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(2, score.getHandledCount());
+ assertEquals(1, score.getRemainderCount());
+ assertEquals("+doubleProp", score.getRemainderOrderings().get(0).toString());
+ assertEquals(true, score.shouldReverseOrder());
+ assertEquals(1, score.getFreeOrderings().size());
+ assertEquals("-doubleProp", score.getFreeOrderings().get(0).toString());
+ assertEquals(0, score.getUnusedOrderings().size());
+ }
+
+ public void testFreeAndUnusedOrderings() throws Exception {
+ final StorableIndex<StorableTestBasic> ix;
+ List<OrderedProperty<StorableTestBasic>> ops;
+ OrderingScore score;
+ Filter<StorableTestBasic> filter;
+
+ ix = makeIndex(StorableTestBasic.class, "stringProp", "id", "intProp", "doubleProp");
+ ops = makeOrderings(StorableTestBasic.class, "~id");
+ filter = Filter.filterFor(StorableTestBasic.class, "stringProp = ?");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(1, score.getHandledCount());
+ assertEquals(0, score.getRemainderCount());
+ assertEquals(false, score.shouldReverseOrder());
+ assertEquals(2, score.getFreeOrderings().size());
+ assertEquals("~intProp", score.getFreeOrderings().get(0).toString());
+ assertEquals("~doubleProp", score.getFreeOrderings().get(1).toString());
+ assertEquals(1, score.getUnusedOrderings().size());
+ assertEquals("~stringProp", score.getUnusedOrderings().get(0).toString());
+
+ ops = makeOrderings(StorableTestBasic.class, "~id", "-intProp");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(2, score.getHandledCount());
+ assertEquals(0, score.getRemainderCount());
+ assertEquals(true, score.shouldReverseOrder());
+ assertEquals(1, score.getFreeOrderings().size());
+ assertEquals("-doubleProp", score.getFreeOrderings().get(0).toString());
+ assertEquals(1, score.getUnusedOrderings().size());
+ assertEquals("~stringProp", score.getUnusedOrderings().get(0).toString());
+
+ ops = makeOrderings(StorableTestBasic.class, "~id", "-intProp", "+doubleProp");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(2, score.getHandledCount());
+ assertEquals(1, score.getRemainderCount());
+ assertEquals("+doubleProp", score.getRemainderOrderings().get(0).toString());
+ assertEquals(true, score.shouldReverseOrder());
+ assertEquals(1, score.getFreeOrderings().size());
+ assertEquals("-doubleProp", score.getFreeOrderings().get(0).toString());
+ assertEquals(1, score.getUnusedOrderings().size());
+ assertEquals("~stringProp", score.getUnusedOrderings().get(0).toString());
+ }
}
|