Package com.odiago.flumebase.exec

Examples of com.odiago.flumebase.exec.Symbol


    if (null != mType) {
      LOG.debug("Returning cached type: " + mType);
      return mType;
    }

    Symbol sym = symTab.resolve(mIdentifier);
    if (null == sym) {
      return null;
    } else {
      return sym.getType();
    }
  }
View Full Code Here


    return mAssignedSym;
  }

  @Override
  public List<TypedField> getRequiredFields(SymbolTable symTab) {
    Symbol sym = symTab.resolve(mIdentifier);
    if (null == sym) {
      // Magic field or attribute.
      return Collections.singletonList(new TypedField("_" + mAssignedName, mType));
    } else {
      sym = sym.resolveAliases();
      String canonicalName = sym.getName();
      TypedField field = new TypedField(canonicalName, sym.getType(), mAssignedName, canonicalName);
      return Collections.singletonList(field);
    }
  }
View Full Code Here

      // Already resolved this expression instance.
      return;
    }

    // Get a handle to the symbol defining the function.
    Symbol fnSymbol = symTab.resolve(mFunctionName);
    if (null == fnSymbol) {
      throw new TypeCheckException("No such function: " + mFunctionName);
    }

    fnSymbol = fnSymbol.resolveAliases();

    if (!(fnSymbol instanceof FnSymbol)) {
      // This symbol isn't a function call?
      throw new TypeCheckException("Symbol " + mFunctionName + " is not a function");
    }
View Full Code Here

    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();
    e2Sym = e2Sym.resolveAliases();

    // We now have the symbols for the e1 and e2 sides of the BinExpr.
    // Determine which of these is from the left source and the right source.
    // Verify that both sources are represented here.
View Full Code Here

  @Override
  protected void visit(DropStmt s) throws VisitException {
    // Check that the DROP ____ type matches the type of the object to be dropped.
    SymbolTable symtab = mSymTableContext.top();
    String name = s.getName();
    Symbol sym = symtab.resolve(name);
    if (null == sym) {
      throw new TypeCheckException("No such object at top level: " + name);
    }
    EntityTarget targetType = s.getType();
    Type.TypeName symType = sym.getType().getTypeName();
    // Check that the DROP ___ type matches the symbol type.
    if (EntityTarget.Stream.equals(targetType)
        && !Type.TypeName.STREAM.equals(symType)) {
      throw new TypeCheckException("Entity " + name + " has incorrect type: " + symType);
    } else if (EntityTarget.Flow.equals(targetType)
View Full Code Here

  protected void visit(LiteralSource s) throws VisitException {
    SymbolTable symtab = mSymTableContext.top();

    String name = s.getName();
    LOG.debug("Visiting literalsrc " + name);
    Symbol symbol = symtab.resolve(name);
    if (null == symbol) {
      throw new TypeCheckException("No such identifier: " + name);
    } else if (symbol.getType().getTypeName() != Type.TypeName.STREAM) {
      throw new TypeCheckException("Identifier " + name + " is not a stream (type="
          + symbol.getType());
    }

    // Add a new symbol table layer containing the named stream's symbols.
    SymbolTable sourceTable = s.getFieldsSymbolTable(symtab, mNextFieldId);
View Full Code Here

          // to add fields pulled in by the "*" operator.
          // Resolve away all aliased symbols to their final version, and rename
          // any "qualifier.field" -> "field".
          Iterator<Symbol> sourceSymbols = exprTable.levelIterator();
          while (sourceSymbols.hasNext()) {
            Symbol srcSym = sourceSymbols.next().resolveAliases();
            String symName = StringUtils.dequalify(srcSym.getName());

            if (null != stmtAlias) {
              Symbol sym = srcSym.withName(stmtAlias + "." + symName);
              outTable.addSymbol(sym);
              outTable.addSymbol(new AliasSymbol(symName, sym));
            } else {
              outTable.addSymbol(srcSym.withName(symName));
            }
View Full Code Here

  protected void visit(DescribeStmt s) throws VisitException {
    // Check the symbol table that the identifier exists.
    String id = s.getIdentifier();
    SymbolTable symtab = mSymTableContext.top();

    Symbol symbol = symtab.resolve(id);
    if (null == symbol) {
      throw new TypeCheckException("No such identifier: " + id);
    }
  }
View Full Code Here

    String dotName = "." + symName;

    Iterator<Symbol> symbols = symTab.levelIterator();
    while (symbols.hasNext()) {
      Symbol sym = symbols.next();
      if (sym.getName().endsWith(dotName)) {
        // We've found 'foo.symName', but no symName. Ambiguous identifier.
        return true;
      }
    }
View Full Code Here

      Ref<AssignedSymbol> outSym, Ref<Type> outType) throws TypeCheckException {

    // Check that this field is defined by one of the input sources.
    // Since the source pushed a symbol table on the stack, just check
    // that we have a symbol table, and that this is a primitive value.
    Symbol fieldSym = fieldsSymTab.resolve(fieldName);
    if (null == fieldSym) {
      // This isn't just a simple field. Check if it's an attribute.
      if (fieldName.startsWith("#") && fieldName.length() > 1) {
        // This is an attribute name.
        String attrName = fieldName.substring(1);
        fieldSym = new AssignedSymbol(attrName,
            Type.getNullable(Type.TypeName.BINARY),
            attrName, IdentifierExpr.AccessType.ATTRIBUTE);
      } else if (isAmbiguousAlias(fieldName, fieldsSymTab)) {
        // The identifier doesn't exist, or else it's an ambiguous alias.
        // Return the appropriate error message.

        // This identifier is probably an alias for another identifier
        // but the alias is removed due to ambiguity in a JOIN.
        throw new TypeCheckException("Ambiguous identifier: \"" + fieldName + "\". "
            + "You must prefix this with a stream name qualifier.");
      } else {
        // This identifier straight-up doesn't exist.
        throw new TypeCheckException("No such identifier: \"" + fieldName + "\"");
      }
    }

    Type fieldType = fieldSym.getType();
    if (!fieldType.isConcrete()) {
      // This name refers to a stream or other ephemeral type. We can't
      // select that.
      throw new TypeCheckException("Cannot select non-concrete entity \""
          + fieldName + "\"");
    }

    outType.item = fieldType;

    // The field symbol should also be an AssignedSymbol that has a unique
    // reference name throughout the query. Bind to the reference name here;
    // the actual query uses this name instead of the user-friendly
    // identifier.
    fieldSym = fieldSym.resolveAliases();
    assert fieldSym instanceof AssignedSymbol;

    outSym.item = (AssignedSymbol) fieldSym;
  }
View Full Code Here

TOP

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

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.