summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2006-09-07 02:14:11 +0000
committerBrian S. O'Neill <bronee@gmail.com>2006-09-07 02:14:11 +0000
commit5746b6ef0b4eff0ff8f9eeb448e3de5f759b916d (patch)
tree0027a4afa134b98f13fcffb53e2ec11253a4d54f /src/test
parent8f791a3e9e36fac4345ebb75ba1d9fe51b4b1b55 (diff)
Add tests for full scans.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/amazon/carbonado/qe/TestUnionQueryAnalyzer.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/qe/TestUnionQueryAnalyzer.java b/src/test/java/com/amazon/carbonado/qe/TestUnionQueryAnalyzer.java
index cb5477f..2ce00c8 100644
--- a/src/test/java/com/amazon/carbonado/qe/TestUnionQueryAnalyzer.java
+++ b/src/test/java/com/amazon/carbonado/qe/TestUnionQueryAnalyzer.java
@@ -274,4 +274,80 @@ public class TestUnionQueryAnalyzer extends TestCase {
assertEquals(Filter.filterFor(Shipment.class, "shipmentID = ? | orderID = ?"),
res_0.getRemainderFilter().unbind());
}
+
+ public void testFullScan() throws Exception {
+ // Because no indexes were selected, there's no union to perform.
+ UnionQueryAnalyzer uqa =
+ new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.IxProvider.INSTANCE);
+ Filter<Shipment> filter = Filter.filterFor
+ (Shipment.class, "shipmentNotes = ? | shipperID = ?");
+ filter = filter.bind();
+ UnionQueryAnalyzer.Result result = uqa.analyze(filter, null);
+ List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults();
+
+ assertEquals(1, subResults.size());
+ IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0);
+
+ assertFalse(res_0.handlesAnything());
+ assertEquals(null, res_0.getForeignIndex());
+ assertEquals(null, res_0.getForeignProperty());
+ assertEquals(0, res_0.getRemainderOrderings().size());
+ assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ? | shipperID = ?").bind(),
+ res_0.getRemainderFilter());
+ }
+
+ public void testFullScanFallback() throws Exception {
+ // Because not all sub-results of union use an index, just fallback to
+ // doing a full scan.
+ UnionQueryAnalyzer uqa =
+ new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.IxProvider.INSTANCE);
+ Filter<Shipment> filter = Filter.filterFor
+ (Shipment.class, "shipmentNotes = ? | orderID = ?");
+ filter = filter.bind();
+ UnionQueryAnalyzer.Result result = uqa.analyze(filter, null);
+ List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults();
+
+ assertEquals(1, subResults.size());
+ IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0);
+
+ assertFalse(res_0.handlesAnything());
+ assertEquals(null, res_0.getForeignIndex());
+ assertEquals(null, res_0.getForeignProperty());
+ assertEquals(0, res_0.getRemainderOrderings().size());
+ assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ? | orderID = ?").bind(),
+ res_0.getRemainderFilter());
+ }
+
+ public void testFullScanExempt() throws Exception {
+ // Although not all sub-results use an index, one that does has a join
+ // so it is exempt from folding into the full scan.
+ UnionQueryAnalyzer uqa =
+ new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.IxProvider.INSTANCE);
+ Filter<Shipment> filter = Filter.filterFor
+ (Shipment.class, "shipmentNotes = ? | orderID = ? & order.orderTotal > ?");
+ filter = filter.bind();
+ UnionQueryAnalyzer.Result result = uqa.analyze(filter, null);
+ List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults();
+
+ assertEquals(2, subResults.size());
+ IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0);
+ IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1);
+
+ assertTrue(res_0.handlesAnything());
+ assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex());
+ assertEquals(null, res_0.getForeignIndex());
+ assertEquals(null, res_0.getForeignProperty());
+ assertEquals(0, res_0.getRemainderOrderings().size());
+ assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ?").bind(),
+ res_0.getRemainderFilter());
+
+ assertTrue(res_1.handlesAnything());
+ assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex());
+ assertEquals(null, res_1.getForeignIndex());
+ assertEquals(null, res_1.getForeignProperty());
+ assertEquals(1, res_1.getRemainderOrderings().size());
+ assertEquals("+shipmentID", res_1.getRemainderOrderings().get(0).toString());
+ assertEquals(Filter.filterFor(Shipment.class, "order.orderTotal > ?").bind(),
+ res_1.getRemainderFilter());
+ }
}