private void doRiaNode(
      InternalWorkingMemory wm,
      LeftInputAdapterNode liaNode,
      PathMemory pmem,
      TupleSets<LeftTuple> srcTuples,
      BetaNode betaNode,
      LeftTupleSinkNode sink,
      SegmentMemory[] smems,
      int smemIndex,
      Memory nodeMem,
      BetaMemory bm,
      LinkedList<StackEntry> stack,
      RuleExecutor executor) {
    RiaPathMemory pathMem = bm.getRiaRuleMemory();
    SegmentMemory[] subnetworkSmems = pathMem.getSegmentMemories();
    SegmentMemory subSmem = null;
    for (int i = 0; subSmem == null; i++) {
      // segment positions outside of the subnetwork, in the parent chain, are null
      // so we must iterate to find the first non null segment memory
      subSmem = subnetworkSmems[i];
    }

    // Resume the node after the riaNode segment has been processed and the right input memory
    // populated
    StackEntry stackEntry =
        new StackEntry(
            liaNode,
            betaNode,
            bm.getNodePosMaskBit(),
            sink,
            pmem,
            nodeMem,
            smems,
            smemIndex,
            srcTuples,
            false,
            false);
    stack.add(stackEntry);
    if (log.isTraceEnabled()) {
      int offset = getOffset(betaNode);
      log.trace(
          "{} RiaQueue {} {}", indent(offset), betaNode.toString(), srcTuples.toStringSizes());
    }

    TupleSets<LeftTuple> subLts = subSmem.getStagedLeftTuples().takeAll();
    // node is first in the segment, so bit is 1
    innerEval(
        liaNode,
        pathMem,
        subSmem.getRootNode(),
        1,
        subSmem.getNodeMemories().getFirst(),
        subnetworkSmems,
        subSmem.getPos(),
        subLts,
        wm,
        stack,
        true,
        executor);
  }
Example #2
0
  private void doRiaNode(
      InternalWorkingMemory wm,
      LeftInputAdapterNode liaNode,
      PathMemory rmem,
      LeftTupleSets srcTuples,
      BetaNode betaNode,
      LeftTupleSinkNode sink,
      SegmentMemory[] smems,
      int smemIndex,
      Memory nodeMem,
      BetaMemory bm,
      LinkedList<StackEntry> stack,
      Set<String> visitedRules,
      RuleExecutor executor) {
    RiaPathMemory pathMem = bm.getRiaRuleMemory();
    SegmentMemory[] subnetworkSmems = pathMem.getSegmentMemories();
    SegmentMemory subSmem = null;
    for (int i = 0; subSmem == null; i++) {
      // segment positions outside of the subnetwork, in the parent chain, are null
      // so we must iterate to find the first non null segment memory
      subSmem = subnetworkSmems[i];
    }

    //        if (betaNode.getLeftTupleSource().getSinkPropagator().size() == 2) {
    //            // sub network is not part of  share split, so need to handle propagation
    //            // this ensures the first LeftTuple is actually the subnetwork node
    //            // and the main outer network now receives the peer, notice the swap at the end
    // "srcTuples == peerTuples"
    //            LeftTupleSets peerTuples = new LeftTupleSets();
    //            SegmentPropagator.processPeers(srcTuples, peerTuples, betaNode);
    //            // Make sure subnetwork Segment has tuples to process
    //            LeftTupleSets subnetworkStaged = subSmem.getStagedLeftTuples();
    //            subnetworkStaged.addAll(srcTuples);
    //
    //            srcTuples.resetAll();
    //
    //            srcTuples = peerTuples;
    //        }

    // Resume the node after the riaNode segment has been processed and the right input memory
    // populated
    StackEntry stackEntry =
        new StackEntry(
            liaNode,
            betaNode,
            sink,
            rmem,
            nodeMem,
            smems,
            smemIndex,
            srcTuples,
            visitedRules,
            false);
    stack.add(stackEntry);
    if (log.isTraceEnabled()) {
      int offset = getOffset(betaNode);
      log.trace(
          "{} RiaQueue {} {}", indent(offset), betaNode.toString(), srcTuples.toStringSizes());
    }

    //        RightInputAdapterNode riaNode = ( RightInputAdapterNode ) betaNode.getRightInput();
    // RiaNodeMemory riaNodeMemory = (RiaNodeMemory) wm.getNodeMemory((MemoryFactory)
    // betaNode.getRightInput());
    // LeftTupleSets riaStagedTuples =
    eval2(
        liaNode,
        pathMem,
        (LeftTupleSink) subSmem.getRootNode(),
        subSmem.getNodeMemories().getFirst(),
        subnetworkSmems,
        subSmem.getPos(),
        subSmem.getStagedLeftTuples(),
        wm,
        stack,
        visitedRules,
        true,
        executor);
  }