Exemplo n.º 1
0
  public ObjectExecution(
      Select query,
      @SuppressWarnings("unused") RuntimeMetadata metadata,
      ObjectExecutionFactory factory,
      ObjectConnection connection,
      ExecutionContext executionContext)
      throws TranslatorException {
    this.factory = factory;
    this.query = query;
    this.connection = connection;
    this.executionContext = executionContext;

    projects = new ArrayList<CompiledScript>(query.getDerivedColumns().size());
    for (DerivedColumn dc : query.getDerivedColumns()) {
      ColumnReference cr = (ColumnReference) dc.getExpression();
      String name = null;
      if (cr.getMetadataObject() != null) {
        Column c = cr.getMetadataObject();
        name = getNameInSource(c);
      } else {
        name = cr.getName();
      }
      if (name.equalsIgnoreCase("this")) { // $NON-NLS-1$
        projects.add(null);
      } else {
        try {
          projects.add(scriptEngine.compile(OBJECT_NAME + "." + name)); // $NON-NLS-1$
        } catch (ScriptException e) {
          throw new TranslatorException(e);
        }
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public void visit(Select obj) {
    visitNodes(obj.getFrom());
    visitNodes(obj.getDerivedColumns());
    visitNode(obj.getWhere());
    visitNode(obj.getGroupBy());
    visitNode(obj.getHaving());
    visitNode(obj.getOrderBy());
    visitNode(obj.getLimit());

    if (this.doScanEvaluation) {
      HashMap<String, String> options =
          buildTableMetadata(
              this.scanTable.getName(), this.scanTable.getColumns(), this.ef.getEncoding());
      options.put(EvaluatorIterator.QUERYSTRING, SQLStringVisitor.getSQLString(obj.getWhere()));
      IteratorSetting it = new IteratorSetting(1, EvaluatorIterator.class, options);
      this.scanIterators.add(it);
    }

    if (this.selectColumns.size() < this.scanTable.getColumns().size()) {
      HashMap<String, String> options =
          buildTableMetadata(this.scanTable.getName(), this.selectColumns, this.ef.getEncoding());
      IteratorSetting it =
          new IteratorSetting(iteratorPriority++, LimitProjectionIterator.class, options);
      this.scanIterators.add(it);
    }
  }