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

Method start

src/java/simpledb/Parser.java:593–688  ·  view source on GitHub ↗
(String[] argv)

Source from the content-addressed store, hash-verified

591 protected boolean interactive = true;
592
593 protected void start(String[] argv) throws IOException {
594 // first add tables to database
595 Database.getCatalog().loadSchema(argv[0]);
596 TableStats.computeStatistics();
597
598 String queryFile = null;
599
600 if (argv.length > 1) {
601 for (int i = 1; i < argv.length; i++) {
602 if (argv[i].equals("-explain")) {
603 explain = true;
604 System.out.println("Explain mode enabled.");
605 } else if (argv[i].equals("-f")) {
606 interactive = false;
607 if (i++ == argv.length) {
608 System.out.println("Expected file name after -f\n"
609 + usage);
610 System.exit(0);
611 }
612 queryFile = argv[i];
613
614 } else {
615 System.out.println("Unknown argument " + argv[i] + "\n "
616 + usage);
617 }
618 }
619 }
620 if (!interactive) {
621 try {
622 // curtrans = new Transaction();
623 // curtrans.start();
624 try {
625 Thread.sleep(SLEEP_TIME);
626 } catch (InterruptedException e) {
627 e.printStackTrace();
628 }
629
630 long startTime = System.currentTimeMillis();
631 processNextStatement(new FileInputStream(queryFile));
632 long time = System.currentTimeMillis() - startTime;
633 System.out.printf("----------------\n%.2f seconds\n\n",
634 ((double) time / 1000.0));
635 System.out.println("Press Enter to exit");
636 System.in.read();
637 this.shutdown();
638 } catch (FileNotFoundException e) {
639 System.out.println("Unable to find query file" + queryFile);
640 e.printStackTrace();
641 }
642 } else { // no query file, run interactive prompt
643 ConsoleReader reader = new ConsoleReader();
644
645 // Add really stupid tab completion for simple SQL
646 ArgumentCompletor completor = new ArgumentCompletor(
647 new SimpleCompletor(SQL_COMMANDS));
648 completor.setStrict(false); // match at any position
649 reader.addCompletor(completor);
650

Callers 11

mainMethod · 0.95
startGrabberMethod · 0.45
grabLockMethod · 0.45
startWriterMethod · 0.45
validateTransactionsMethod · 0.45
startInserterMethod · 0.45
startDeleterMethod · 0.45
processNextStatementMethod · 0.45

Calls 7

getCatalogMethod · 0.95
computeStatisticsMethod · 0.95
processNextStatementMethod · 0.95
shutdownMethod · 0.95
loadSchemaMethod · 0.80
equalsMethod · 0.65
toStringMethod · 0.65

Tested by 8

startGrabberMethod · 0.36
grabLockMethod · 0.36
startWriterMethod · 0.36
validateTransactionsMethod · 0.36
startInserterMethod · 0.36
startDeleterMethod · 0.36