コード例 #1
0
 /**
  * Parses a module.
  *
  * @param io input reference
  * @return query parser
  * @throws QueryException query exception
  */
 final QueryParser parseQuery(final IO io) throws QueryException {
   try (final QueryContext qctx = new QueryContext(qc)) {
     final String input = string(io.read());
     // parse query
     final QueryParser qp = new QueryParser(input, io.path(), qctx, null);
     module = QueryProcessor.isLibrary(input) ? qp.parseLibrary(true) : qp.parseMain();
     return qp;
   } catch (final IOException | QueryException ex) {
     throw IOERR_X.get(info, ex);
   }
 }
コード例 #2
0
  /** @param args */
  public static void main(String[] args) throws Exception {

    // read serialised catalogue from file and parse
    String catFile = args[0];
    Catalogue cat = new Catalogue();
    CatalogueParser catParser = new CatalogueParser(catFile, cat);
    catParser.parse();

    // read stdin, parse, and build canonical query plan
    QueryParser queryParser = new QueryParser(cat, new InputStreamReader(System.in));
    Operator plan = queryParser.parse();

    System.out.println("Query Plan: " + plan.toString());

    // create estimator visitor and apply it to canonical plan
    Estimator est = new Estimator();
    // plan.accept(est);

    // create optimised plan
    Optimiser opt = new Optimiser(cat);
    Operator optPlan = opt.optimise(plan);

    System.out.println("Optimised Plan: " + optPlan.toString());
  }