public void result(
      EventBean[] row,
      int fromStreamNum,
      EventBean myEvent,
      Node myNode,
      Collection<EventBean[]> resultFinalRows,
      EventBean resultRootEvent) {
    row[streamNum] = myEvent;
    Node parentResultNode = myNode.getParent();
    parentNode.result(
        row,
        streamNum,
        myNode.getParentEvent(),
        parentResultNode,
        resultFinalRows,
        resultRootEvent);

    // record the fact that an event that was generated by a child
    haveChildResults = true;

    // If we had more then on result event for this stream, we need to track all the different
    // events
    // generated by the child node
    if (singleResultNode == null) {
      completedEvents.add(myEvent);
    }
  }
Exemplo n.º 2
0
  public void process(
      List<Node>[] result, Collection<EventBean[]> resultFinalRows, EventBean resultRootEvent) {
    List<Node> nodes = result[streamNum];
    if (nodes == null) {
      return;
    }

    for (Node node : nodes) {
      Set<EventBean> events = node.getEvents();
      for (EventBean theEvent : events) {
        processEvent(theEvent, node, resultFinalRows, resultRootEvent);
      }
    }
  }
 private void processEvent(
     EventBean theEvent,
     Node currentNode,
     Collection<EventBean[]> resultFinalRows,
     EventBean resultRootEvent) {
   EventBean[] row = new EventBean[numStreams];
   row[streamNum] = theEvent;
   parentNode.result(
       row,
       streamNum,
       currentNode.getParentEvent(),
       currentNode.getParent(),
       resultFinalRows,
       resultRootEvent);
 }
  public void process(
      List<Node>[] result, Collection<EventBean[]> resultFinalRows, EventBean resultRootEvent) {
    // there cannot be child nodes to compute a cartesian product if this node had no results
    if (resultsForStream == null) {
      return;
    }

    // If this node's result set consisted of a single event
    if (singleResultNode != null) {
      // If there are no child results, post a row
      if (!haveChildResults) {
        EventBean[] row = new EventBean[numStreams];
        row[streamNum] = singleResultEvent;
        parentNode.result(
            row,
            streamNum,
            singleResultNode.getParentEvent(),
            singleResultNode,
            resultFinalRows,
            resultRootEvent);
      }

      // if there were child results we are done since they have already been posted to the parent
      return;
    }

    // We have multiple events for this node, generate an event row for each event not yet received
    // from
    // event rows generated by the child node.
    for (Node node : resultsForStream) {
      Set<EventBean> events = node.getEvents();
      for (EventBean theEvent : events) {
        if (completedEvents.contains(theEvent)) {
          continue;
        }
        processEvent(theEvent, node, resultFinalRows, resultRootEvent);
      }
    }
  }
  public void init(List<Node>[] result) {
    resultsForStream = result[streamNum];
    singleResultNode = null;
    singleResultEvent = null;
    haveChildResults = false;

    if (resultsForStream != null) {
      int numNodes = resultsForStream.size();
      if (numNodes == 1) {
        Node node = resultsForStream.get(0);
        Set<EventBean> nodeEvents = node.getEvents();

        // If there is a single result event (typical case)
        if (nodeEvents.size() == 1) {
          singleResultNode = node;
          singleResultEvent = nodeEvents.iterator().next();
        }
      }

      if (singleResultNode == null) {
        completedEvents = new HashSet<EventBean>();
      }
    }
  }