MCPcopy Create free account
hub / github.com/1345414527/MIT6.830 / main

Method main

src/java/simpledb/optimizer/LogicalPlan.java:481–541  ·  view source on GitHub ↗
(String[] argv)

Source from the content-addressed store, hash-verified

479 }
480
481 public static void main(String[] argv) {
482 // construct a 3-column table schema
483 Type[] types = new Type[]{ Type.INT_TYPE, Type.INT_TYPE, Type.INT_TYPE };
484 String[] names = new String[]{ "field0", "field1", "field2" };
485
486 TupleDesc td = new TupleDesc(types, names);
487 TableStats ts;
488 Map<String, TableStats> tableMap = new HashMap<>();
489
490 // create the tables, associate them with the data files
491 // and tell the catalog about the schema the tables.
492 HeapFile table1 = new HeapFile(new File("some_data_file1.dat"), td);
493 Database.getCatalog().addTable(table1, "t1");
494 ts = new TableStats(table1.getId(), 1);
495 tableMap.put("t1", ts);
496
497 TransactionId tid = new TransactionId();
498
499 LogicalPlan lp = new LogicalPlan();
500
501 lp.addScan(table1.getId(), "t1");
502
503 try {
504 lp.addFilter("t1.field0", Predicate.Op.GREATER_THAN, "1");
505 } catch (Exception ignored) {
506 }
507
508 /*
509 SeqScan ss1 = new SeqScan(tid, table1.getId(), "t1");
510 SeqScan ss2 = new SeqScan(tid, table2.getId(), "t2");
511
512 // create a filter for the where condition
513 Filter sf1 = new Filter(
514 new Predicate(0,
515 Predicate.Op.GREATER_THAN, new IntField(1)), ss1);
516
517 JoinPredicate p = new JoinPredicate(1, Predicate.Op.EQUALS, 1);
518 Join j = new Join(p, sf1, ss2);
519 */
520 OpIterator j = null;
521 try {
522 j = lp.physicalPlan(tid,tableMap, false);
523 } catch (ParsingException e) {
524 e.printStackTrace();
525 System.exit(0);
526 }
527 // and run it
528 try {
529 j.open();
530 while (j.hasNext()) {
531 Tuple tup = j.next();
532 System.out.println(tup);
533 }
534 j.close();
535 Database.getBufferPool().transactionComplete(tid);
536
537 } catch (Exception e) {
538 e.printStackTrace();

Callers

nothing calls this directly

Calls 13

getCatalogMethod · 0.95
getIdMethod · 0.95
addScanMethod · 0.95
addFilterMethod · 0.95
physicalPlanMethod · 0.95
openMethod · 0.95
hasNextMethod · 0.95
nextMethod · 0.95
closeMethod · 0.95
getBufferPoolMethod · 0.95
putMethod · 0.80
addTableMethod · 0.45

Tested by

no test coverage detected