diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-09-04 06:01:19 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-09-04 06:01:19 +0000 |
commit | d88b8c7708cdf8c4fb1ec78371490f282d5f945e (patch) | |
tree | 4232a03882ef2e93bc85c0a70f4be7e66e8b158c /src | |
parent | 875031b6075b484ca7fea2ed410d610d787c44d6 (diff) |
Test to ensure redundant orderings are eliminated.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/amazon/carbonado/qe/OrderingScore.java | 13 | ||||
-rw-r--r-- | src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java | 23 |
2 files changed, 31 insertions, 5 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/OrderingScore.java b/src/main/java/com/amazon/carbonado/qe/OrderingScore.java index 843e22d..ed52cfc 100644 --- a/src/main/java/com/amazon/carbonado/qe/OrderingScore.java +++ b/src/main/java/com/amazon/carbonado/qe/OrderingScore.java @@ -272,14 +272,16 @@ public class OrderingScore<S extends Storable> { }
/**
- * Returns the number of desired orderings the evaluated index supports.
+ * Returns the number of desired orderings the evaluated index
+ * supports. The number of orderings is reduced to eliminate redundancies.
*/
public int getHandledCount() {
return mHandledOrderings.size();
}
/**
- * Returns the ordering properties that the evaluated index supports.
+ * Returns the ordering properties that the evaluated index supports. The
+ * list of orderings is reduced to eliminate redundancies.
*
* @return handled orderings, never null
*/
@@ -289,8 +291,9 @@ public class OrderingScore<S extends Storable> { /**
* Returns the number of desired orderings the evaluated index does not
- * support. When non-zero, a query plan which uses the evaluated index must
- * perform a sort.
+ * support. The number of orderings is reduced to eliminate redundancies.
+ * When the remainder count is non-zero, a query plan which uses the
+ * evaluated index must perform a sort.
*/
public int getRemainderCount() {
return mRemainderOrderings.size();
@@ -298,7 +301,7 @@ public class OrderingScore<S extends Storable> { /**
* Returns the ordering properties that the evaluated index does not
- * support.
+ * support. The list of orderings is reduced to eliminate redundancies.
*
* @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 ac407ec..91b5676 100644 --- a/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java +++ b/src/test/java/com/amazon/carbonado/qe/TestOrderingScore.java @@ -520,4 +520,27 @@ public class TestOrderingScore extends TestCase { assertEquals(0, score.getRemainderCount());
assertEquals(false, score.shouldReverseOrder());
}
+
+ public void testReduce() throws Exception {
+ // Tests that redundant ordering properties are removed.
+ final StorableIndex<StorableTestBasic> ix;
+ List<OrderedProperty<StorableTestBasic>> ops;
+ OrderingScore score;
+ Filter<StorableTestBasic> filter;
+
+ ix = makeIndex(StorableTestBasic.class, "id", "intProp", "doubleProp");
+ ops = makeOrderings(StorableTestBasic.class,
+ "intProp", "intProp", "id", "doubleProp", "intProp", "doubleProp",
+ "longProp", "longProp", "id", "intProp", "doubleProp");
+ filter = Filter.filterFor(StorableTestBasic.class, "id = ?");
+
+ score = OrderingScore.evaluate(ix, filter, ops);
+ assertEquals(2, score.getHandledCount());
+ assertEquals(1, score.getRemainderCount());
+ assertEquals(false, score.shouldReverseOrder());
+
+ assertEquals("+intProp", score.getHandledOrderings().get(0).toString());
+ assertEquals("+doubleProp", score.getHandledOrderings().get(1).toString());
+ assertEquals("+longProp", score.getRemainderOrderings().get(0).toString());
+ }
}
|