Package com.odiago.flumebase.exec

Examples of com.odiago.flumebase.exec.StreamSymbol


  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 + "_",
View Full Code Here


    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);
View Full Code Here

    if (0 == mFields.size()) {
      throw new RuntimeException("Must define at least one field with addField()");
    }

    return new StreamSymbol(mStreamName, mSourceType, makeStreamType(),
        mSource, mIsLocal, new ArrayList<TypedField>(mFields), mFormatSpec);
  }
View Full Code Here

    } else if (node instanceof CreateStreamNode) {
      // Just perform this operation immediately. Do not translate this into another
      // layer. (This results in an empty flow being generated, which is discarded.)
      CreateStreamNode createStream = (CreateStreamNode) node;
      String streamName = createStream.getName();
      StreamSymbol streamSym = new StreamSymbol(createStream);
      if (!streamSym.getEventParser().validate(streamSym)) {
        // Fails final check of parameters
        // TODO: The EventParser is giving better info in its LOG; but this
        // should really be communicated back to the user.
        throw new DAGOperatorException(
            "Stream cannot be created with the specified parameters.");
      } else if (mRootSymbolTable.resolve(streamName) != null) {
        // TODO: Allow CREATE OR REPLACE STREAM to override this.
        throw new DAGOperatorException("Object already exists at top level: " + streamName);
      } else {
        mRootSymbolTable.addSymbol(streamSym);
        mSubmitterSession.sendInfo("CREATE STREAM");
      }

      if (createStream.getType().equals(StreamSourceType.File)
          && streamSym.getFormatSpec().getParam(FileSourceElement.TIMESTAMP_COL_KEY) == null) {
        // We're reading from a file, and making up timestamps based on read time.
        // Warn the user that timestamps will change between queries.
        StringBuilder sb = new StringBuilder();
        sb.append("Warning: File-based streams will set event timestamps based on read time.\n");
        sb.append("To specify timestamps explictly, set the ");
        sb.append(FileSourceElement.TIMESTAMP_COL_KEY);
        sb.append(" event format property.");
        mSubmitterSession.sendInfo(sb.toString());
      }
    } else if (node instanceof DescribeNode) {
      // Look up the referenced object in the symbol table and describe it immediately.
      DescribeNode describe = (DescribeNode) node;
      Symbol sym = mRootSymbolTable.resolve(describe.getIdentifier());
      mSubmitterSession.sendInfo(sym.toString());
    } else if (node instanceof DropNode) {
      // Perform the operation here.
      // Remove the objet from our symbol table.
      DropNode dropNode = (DropNode) node;
      String name = dropNode.getName();
      Symbol sym = mRootSymbolTable.resolve(name);
      if (null == sym) {
        // Shouldn't happen; the type checker already accepted this statement.
        throw new DAGOperatorException("No such object at top level: " + name);
      }
      EntityTarget targetType = dropNode.getType();
      // Perform the operation.
      mRootSymbolTable.remove(name);
      mSubmitterSession.sendInfo("DROP " + targetType.toString().toUpperCase());
    } else if (node instanceof NamedSourceNode) {
      NamedSourceNode namedInput = (NamedSourceNode) node;
      String streamName = namedInput.getStreamName();
      Symbol symbol = mRootSymbolTable.resolve(streamName).resolveAliases();
      if (null == symbol) {
        throw new DAGOperatorException("No symbol for stream: " + streamName);
      }

      if (!(symbol instanceof StreamSymbol)) {
        throw new DAGOperatorException("Identifier " + streamName + " has type: "
            + symbol.getType() + ", not STREAM.");
      }

      StreamSymbol streamSymbol = (StreamSymbol) symbol;

      switch (streamSymbol.getSourceType()) {
      case File:
        String fileName = streamSymbol.getSource();
        newElem = new FileSourceElement(newContext, fileName, streamSymbol.isLocal(),
            namedInput.getFields(), streamSymbol);
        break;
      case Source:
        if (!streamSymbol.isLocal()) {
          throw new DAGOperatorException("Do not know how to handle a non-local source yet.");
        }
        String flumeSource = streamSymbol.getSource();
        long flowIdNum = mFlowId.getId();
        String flowSourceId = "flumebase-flow-" + flowIdNum + "-" + streamSymbol.getName();
        newElem = new LocalFlumeSourceElement(newContext, flowSourceId,
            mFlumeConfig, flumeSource, (Schema) namedInput.getAttr(PlanNode.OUTPUT_SCHEMA_ATTR),
            namedInput.getFields(), streamSymbol);
        if (!streamSymbol.isLocal()) {
          LOG.info("Created local Flume logical node: " + flowSourceId);
          LOG.info("You may need to connect upstream Flume elements to this source.");
        }

        // Mark Flume as required to execute this flow.
        mLocalFlow.setFlumeRequired(true);
        break;
      case Memory:
        newElem = new LocalInMemSourceElement(newContext,
            namedInput.getFields(), (InMemStreamSymbol) streamSymbol);
        break;
      case Node:
        String nodeSourceId = "flumebase-flow-" + mFlowId.getId() + "-" + streamSymbol.getName();
        newElem = new FlumeNodeElement(newContext, nodeSourceId,
            mFlumeConfig, streamSymbol.getSource(),
            (Schema) namedInput.getAttr(PlanNode.OUTPUT_SCHEMA_ATTR),
            namedInput.getFields(), streamSymbol);

        LOG.info("Created local Flume receiver context: " + nodeSourceId);
        LOG.info("This will be connected to upstream Flume node: " + streamSymbol.getSource());

        // Mark Flume as required to execute this flow.
        mLocalFlow.setFlumeRequired(true);
        break;
      default:
        throw new DAGOperatorException("Unhandled stream source type: "
            + streamSymbol.getSourceType());
      }
    } else if (node instanceof FilterNode) {
      FilterNode filterNode = (FilterNode) node;
      Expr filterExpr = filterNode.getFilterExpr();
      newElem = new FilterElement(newContext, filterExpr);
View Full Code Here

TOP

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

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.