Example #1
0
  public void visitNode(FlatNode node) {
    System.out.println("Creating SliceNodes: " + node);
    OutputSliceNode output = new OutputSliceNode();
    InputSliceNode input = new InputSliceNode();
    FilterContent content;
    int mult = 1;

    if (node.isFilter()) {
      if (node.contents instanceof SIRFileWriter) {
        content = new FileOutputContent((SIRFileWriter) node.contents);
      } else if (node.contents instanceof SIRFileReader) {
        content = new FileInputContent((SIRFileReader) node.contents);
      } else content = new FilterContent(node.getFilter());

    } else if (node.isSplitter()) {
      CType type = CommonUtils.getOutputType(node);
      SIRIdentity id = new SIRIdentity(type);
      RenameAll.renameAllFilters(id);
      content = new FilterContent(id);
      if (!node.isDuplicateSplitter()) mult = node.getTotalOutgoingWeights();

    } else {
      // joiner
      CType type = CommonUtils.getOutputType(node);
      SIRIdentity id = new SIRIdentity(type);
      RenameAll.renameAllFilters(id);
      content = new FilterContent(id);
      mult = node.getTotalIncomingWeights();
    }
    if (exeCounts[0].containsKey(node.contents))
      content.setInitMult(mult * ((int[]) exeCounts[0].get(node.contents))[0]);
    else content.setInitMult(0);

    content.setSteadyMult(mult * ((int[]) exeCounts[1].get(node.contents))[0]);

    FilterSliceNode filterNode = new FilterSliceNode(content);
    if (node.isSplitter() || node.isJoiner()) generatedIds.add(filterNode);

    inputNodes.put(node.contents, input);
    outputNodes.put(node.contents, output);
    filterNodes.put(node.contents, filterNode);
  }