Package com.odiago.flumebase.exec

Examples of com.odiago.flumebase.exec.SymbolTable


  @Test
  public void testLengthFn() throws Exception {
    FnCallExpr fnCallExpr;
    TypeChecker checker;
    Object value;
    SymbolTable symbols = new HashSymbolTable(new BuiltInSymbolTable());

    // This is expected to succeed.
    fnCallExpr = new FnCallExpr("length");
    fnCallExpr.addArg(new ConstExpr(Type.getPrimitive(Type.TypeName.STRING), "meep"));
    checker = new TypeChecker(symbols);
View Full Code Here


    flowSpec.attachToLastLayer(joinNode);

    // Create an output context defining our fields, etc.
    PlanContext outContext = new PlanContext(planContext);

    SymbolTable outTable = SymbolTable.mergeSymbols(leftContext.getSymbolTable(),
        rightContext.getSymbolTable(), planContext.getSymbolTable());
    outContext.setSymbolTable(outTable);

    List<TypedField> outputFields = new ArrayList<TypedField>();
    outputFields.addAll(leftContext.getOutFields());
View Full Code Here

   * <p>Modifies nextFieldId to contain the next id after applying ids to all
   * fields of this stream.</p>
   */
  public SymbolTable getFieldsSymbolTable(SymbolTable inTable, Ref<Integer> nextFieldId) {
    int nextId = nextFieldId.item.intValue();
    SymbolTable outTable = new HashSymbolTable(inTable);

    // Guaranteed non-null by our typechecker.
    StreamSymbol streamSym = (StreamSymbol) inTable.resolve(getName()).resolveAliases();

    String streamAlias = getAlias();
    if (null == streamAlias) {
      streamAlias = getName();
    }

    for (TypedField field : streamSym.getFields()) {
      String fieldName = field.getUserAlias();

      // This field is available as 'streamName.fieldName'.
      String fullName = streamAlias + "." + fieldName;
      AssignedSymbol sym = new AssignedSymbol(fullName, field.getType(), "__f_" + nextId + "_",
          IdentifierExpr.AccessType.FIELD);
      sym.setParentName(streamAlias);
      nextId++;
      outTable.addSymbol(sym);

      // And also as an alias of just the fieldName.
      outTable.addSymbol(new AliasSymbol(fieldName, sym));
    }

    nextFieldId.item = Integer.valueOf(nextId);
    mSymbols = outTable;
    return outTable;
View Full Code Here

    // The output PlanContext contains a new symbol table defining the fields
    // of this source.

    PlanContext outContext = new PlanContext(planContext);
    SymbolTable inTable = planContext.getSymbolTable();
    SymbolTable outTable = mSymbols;
    outContext.setSymbolTable(outTable);

    // streamSym is guaranteed to be a non-null StreamSymbol by the typechecker.
    StreamSymbol streamSym = (StreamSymbol) inTable.resolve(mSourceName).resolveAliases();
    List<TypedField> fields = streamSym.getFields();
    List<String> fieldNames = new ArrayList<String>();
    for (TypedField field : fields) {
      String fieldName = field.getAvroName();
      if (!fieldNames.contains(fieldName)) {
        fieldNames.add(fieldName);
      }
    }

    // Create an Avro output schema for this node, specifying all the fields
    // we can emit.  Use our internal symbol (mSymbols a.k.a. outTable) to
    // create more precise TypedFields that use the proper avro names.
    List<TypedField> outFields = new ArrayList<TypedField>();
    for (String fieldName : fieldNames) {
      AssignedSymbol sym = (AssignedSymbol) outTable.resolve(fieldName).resolveAliases();
      outFields.add(new TypedField(fieldName, sym.getType(), sym.getAssignedName(), fieldName));
    }

    PlanNode node = new NamedSourceNode(mSourceName, outFields);
    planContext.getFlowSpec().addRoot(node);
View Full Code Here

    SQLStatement source = getSource();
    Expr where = getWhereConditions();

    // Create an execution plan for the source(s) of this SELECT stream.
    PlanContext sourceOutCtxt = getSubPlan(source, planContext);
    SymbolTable srcOutSymbolTable = sourceOutCtxt.getSymbolTable();

    // Now incorporate that entire plan into our plan.
    FlowSpecification flowSpec = planContext.getFlowSpec();
    flowSpec.addNodesFromDAG(sourceOutCtxt.getFlowSpec());
View Full Code Here

      // SELECT as a sub-query needs to create an output context with a
      // symbol table that contains the fields we expose through projection.
      // We also need to set the output field names and output schema in our
      // returned context.
      outContext = new PlanContext(planContext);
      SymbolTable inTable = planContext.getSymbolTable();
      SymbolTable outTable = new HashSymbolTable(inTable);
      outputFields = distinctFields(outputFields);
      outTable.addAll(mFieldSymbols);
      Schema outputSchema = createFieldSchema(outputFields);
      ProjectionNode cleanupProjection = new ProjectionNode(outputFields, outputFields);
      cleanupProjection.setAttr(PlanNode.OUTPUT_SCHEMA_ATTR, outputSchema);
      flowSpec.attachToLastLayer(cleanupProjection);
View Full Code Here

    String e2Ident = ((IdentifierExpr) e2).getIdentifier();

    assert e1Ident != null;
    assert e2Ident != null;

    SymbolTable symTab = src.getFieldSymbols();

    Symbol e1Sym = symTab.resolve(e1Ident);
    Symbol e2Sym = symTab.resolve(e2Ident);

    assert e1Sym != null;
    assert e2Sym != null;

    e1Sym = e1Sym.resolveAliases();
View Full Code Here

  }

  @Test
  public void testIdentifier() throws VisitException {
    // Test that we can look up an identifier in the symbol table.
    SymbolTable symbols = new HashSymbolTable();
    symbols.addSymbol(new AssignedSymbol("x", Type.getPrimitive(Type.TypeName.INT), "x",
        IdentifierExpr.AccessType.FIELD));

    Expr binopExpr = new BinExpr(
      new ConstExpr(Type.getPrimitive(Type.TypeName.INT), Integer.valueOf(2)),
      BinOp.Add, new IdentifierExpr("x"));
View Full Code Here

  }

  @Test
  public void testIdentifierPromotion() throws VisitException {
    // Test that an identifier's type can promote to a constant.
    SymbolTable symbols = new HashSymbolTable();
    symbols.addSymbol(new AssignedSymbol("x", Type.getPrimitive(Type.TypeName.INT), "x",
        IdentifierExpr.AccessType.FIELD));

    Expr binopExpr = new BinExpr(
      new ConstExpr(Type.getPrimitive(Type.TypeName.BIGINT), Integer.valueOf(2)),
      BinOp.Add, new IdentifierExpr("x"));
View Full Code Here

  }

  @Test
  public void testIdentifierPromotion2() throws VisitException {
    // Test that a const's type can promote to an identifier's.
    SymbolTable symbols = new HashSymbolTable();
    symbols.addSymbol(new AssignedSymbol("x", Type.getPrimitive(Type.TypeName.BIGINT), "x",
        IdentifierExpr.AccessType.FIELD));

    Expr binopExpr = new BinExpr(
      new ConstExpr(Type.getPrimitive(Type.TypeName.INT), Integer.valueOf(2)),
      BinOp.Add, new IdentifierExpr("x"));
View Full Code Here

TOP

Related Classes of com.odiago.flumebase.exec.SymbolTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.