()
| 36 | } |
| 37 | |
| 38 | @Test(timeout=20000) public void queryTest() throws IOException { |
| 39 | // This test is intended to approximate the join described in the |
| 40 | // "Query Planning" section of 2009 Quiz 1, |
| 41 | // though with some minor variation due to limitations in simpledb |
| 42 | // and to only test your integer-heuristic code rather than |
| 43 | // string-heuristic code. |
| 44 | final int IO_COST = 101; |
| 45 | |
| 46 | // Create all of the tables, and add them to the catalog |
| 47 | List<List<Integer>> empTuples = new ArrayList<>(); |
| 48 | HeapFile emp = SystemTestUtil.createRandomHeapFile(6, 100000, null, empTuples, "c"); |
| 49 | Database.getCatalog().addTable(emp, "emp"); |
| 50 | |
| 51 | List<List<Integer>> deptTuples = new ArrayList<>(); |
| 52 | HeapFile dept = SystemTestUtil.createRandomHeapFile(3, 1000, null, deptTuples, "c"); |
| 53 | Database.getCatalog().addTable(dept, "dept"); |
| 54 | |
| 55 | List<List<Integer>> hobbyTuples = new ArrayList<>(); |
| 56 | HeapFile hobby = SystemTestUtil.createRandomHeapFile(6, 1000, null, hobbyTuples, "c"); |
| 57 | Database.getCatalog().addTable(hobby, "hobby"); |
| 58 | |
| 59 | List<List<Integer>> hobbiesTuples = new ArrayList<>(); |
| 60 | HeapFile hobbies = SystemTestUtil.createRandomHeapFile(2, 200000, null, hobbiesTuples, "c"); |
| 61 | Database.getCatalog().addTable(hobbies, "hobbies"); |
| 62 | |
| 63 | // Get TableStats objects for each of the tables that we just generated. |
| 64 | TableStats.setTableStats("emp", new TableStats(Database.getCatalog().getTableId("emp"), IO_COST)); |
| 65 | TableStats.setTableStats("dept", new TableStats(Database.getCatalog().getTableId("dept"), IO_COST)); |
| 66 | TableStats.setTableStats("hobby", new TableStats(Database.getCatalog().getTableId("hobby"), IO_COST)); |
| 67 | TableStats.setTableStats("hobbies", new TableStats(Database.getCatalog().getTableId("hobbies"), IO_COST)); |
| 68 | |
| 69 | // Parser.setStatsMap(stats); |
| 70 | |
| 71 | Transaction t = new Transaction(); |
| 72 | t.start(); |
| 73 | Parser p = new Parser(); |
| 74 | p.setTransaction(t); |
| 75 | |
| 76 | // Each of these should return around 20,000 |
| 77 | // This Parser implementation currently just dumps to stdout, so checking that isn't terribly clean. |
| 78 | // So, don't bother for now; future TODO. |
| 79 | // Regardless, each of the following should be optimized to run quickly, |
| 80 | // even though the worst case takes a very long time. |
| 81 | p.processNextStatement("SELECT * FROM emp,dept,hobbies,hobby WHERE emp.c1 = dept.c0 AND hobbies.c0 = emp.c2 AND hobbies.c1 = hobby.c0 AND emp.c3 < 1000;"); |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | Build a large series of tables; then run the command-line query code and execute a query. |
nothing calls this directly
no test coverage detected