コード例 #1
0
  // 有数据输入的root节点赋以相应的值,没有数据输入的节点置为空
  private void attachRoot(Map<String, Set<String>> map, String fromAlias, DataBag bag) {
    if (isTap) {
      roots.get(0).attachInputBag(bag);
      return;
    }

    Iterator<PhysicalOperator> ito = roots.iterator();
    PhysicalOperator root = null;
    while (ito.hasNext()) {
      root = ito.next();
      if (map.get(fromAlias).contains(root.getAlias())) {
        root.attachInputBag(fromAlias, bag);
      } else {
        root.attachInputBag((DataBag[]) null);
      }
    }
  }
コード例 #2
0
 public void feedData(String fromAlias, DataBag bag) throws Exception {
   if (isWindowProcessor()) {
     ((PhysicalOperator) windowPO).attachInputBag(new DataBag[] {bag});
   } else {
     synchronized (lock) {
       try {
         // 第一个节点的情况 ,数据输入为上一级bolt或者tap
         if (isRoot()) {
           attachRoot(this.boltLevalInputMap, fromAlias, bag);
         } else {
           attachRoot(this.getInputMap(), fromAlias, bag);
         }
         executeAndEmit(fromAlias, bag);
       } finally {
         this.innerPlan.detachAllInputBag();
       }
     }
   }
 }