Ejemplo n.º 1
0
 public void execute(InternalWorkingMemory workingMemory) {
   InternalFactHandle factHandle = (InternalFactHandle) leftTuple.getObject();
   if (node.isOpenQuery()) {
     // iterate to the query terminal node, as the child leftTuples will get picked up there
     workingMemory
         .getEntryPointNode()
         .retractObject(
             factHandle,
             context,
             workingMemory
                 .getObjectTypeConfigurationRegistry()
                 .getObjectTypeConf(workingMemory.getEntryPoint(), factHandle.getObject()),
             workingMemory);
     // workingMemory.getFactHandleFactory().destroyFactHandle( factHandle );
   } else {
     // get child left tuples, as there is no open query
     if (leftTuple.getFirstChild() != null) {
       node.getSinkPropagator().propagateRetractLeftTuple(leftTuple, context, workingMemory);
     }
   }
 }
Ejemplo n.º 2
0
  private void doRiaNode2(
      InternalWorkingMemory wm,
      LeftTupleSets srcTuples,
      RightInputAdapterNode riaNode,
      LinkedList<StackEntry> stack) {

    ObjectSink[] sinks = riaNode.getSinkPropagator().getSinks();

    BetaNode betaNode = (BetaNode) sinks[0];
    BetaMemory bm;
    Memory nodeMem = wm.getNodeMemory(betaNode);
    if (NodeTypeEnums.AccumulateNode == betaNode.getType()) {
      bm = ((AccumulateMemory) nodeMem).getBetaMemory();
    } else {
      bm = (BetaMemory) nodeMem;
    }

    // Build up iteration array for other sinks
    BetaNode[] bns = null;
    BetaMemory[] bms = null;
    int length = sinks.length;
    if (length > 1) {
      bns = new BetaNode[sinks.length - 1];
      bms = new BetaMemory[sinks.length - 1];
      for (int i = 1; i < length; i++) {
        bns[i - 1] = (BetaNode) sinks[i];
        Memory nodeMem2 = wm.getNodeMemory(bns[i - 1]);
        if (NodeTypeEnums.AccumulateNode == betaNode.getType()) {
          bms[i - 1] = ((AccumulateMemory) nodeMem2).getBetaMemory();
        } else {
          bms[i - 1] = (BetaMemory) nodeMem2;
        }
      }
    }

    length--; // subtract one, as first is not in the array;
    for (LeftTuple leftTuple = srcTuples.getInsertFirst(); leftTuple != null; ) {
      LeftTuple next = leftTuple.getStagedNext();

      PropagationContext pctx = leftTuple.getPropagationContext();
      InternalFactHandle handle = riaNode.createFactHandle(leftTuple, pctx, wm);

      RightTuple rightTuple = new RightTuple(handle, betaNode);
      leftTuple.setObject(rightTuple);
      rightTuple.setPropagationContext(pctx);
      bm.getStagedRightTuples().addInsert(rightTuple);

      if (bns != null) {
        // Add peered RightTuples, they are attached to FH - unlink LeftTuples that has a peer ref
        for (int i = 0; i < length; i++) {
          rightTuple = new RightTuple(handle, bns[i]);
          rightTuple.setPropagationContext(pctx);
          bms[i].getStagedRightTuples().addInsert(rightTuple);
        }
      }

      leftTuple.clearStaged();
      leftTuple = next;
    }

    for (LeftTuple leftTuple = srcTuples.getDeleteFirst(); leftTuple != null; ) {
      LeftTuple next = leftTuple.getStagedNext();

      RightTuple rightTuple = (RightTuple) leftTuple.getObject();
      RightTupleSets rightTuples = bm.getStagedRightTuples();
      switch (rightTuple.getStagedType()) {
        case LeftTuple.INSERT:
          {
            rightTuples.removeInsert(rightTuple);
            break;
          }
        case LeftTuple.UPDATE:
          {
            rightTuples.removeUpdate(rightTuple);
            break;
          }
      }
      rightTuples.addDelete(rightTuple);

      if (bns != null) {
        // Add peered RightTuples, they are attached to FH - unlink LeftTuples that has a peer ref
        for (int i = 0; i < length; i++) {
          rightTuple = rightTuple.getHandleNext();
          rightTuples = bms[i].getStagedRightTuples();
          switch (rightTuple.getStagedType()) {
            case LeftTuple.INSERT:
              {
                rightTuples.removeInsert(rightTuple);
                break;
              }
            case LeftTuple.UPDATE:
              {
                rightTuples.removeUpdate(rightTuple);
                break;
              }
          }
          rightTuples.addDelete(rightTuple);
        }
      }

      leftTuple.clearStaged();
      leftTuple = next;
    }

    for (LeftTuple leftTuple = srcTuples.getUpdateFirst(); leftTuple != null; ) {
      LeftTuple next = leftTuple.getStagedNext();

      RightTuple rightTuple = (RightTuple) leftTuple.getObject();
      RightTupleSets rightTuples = bm.getStagedRightTuples();
      switch (rightTuple.getStagedType()) {
        case LeftTuple.INSERT:
          {
            rightTuples.removeInsert(rightTuple);
            break;
          }
        case LeftTuple.UPDATE:
          {
            rightTuples.removeUpdate(rightTuple);
            break;
          }
      }
      rightTuples.addUpdate(rightTuple);

      if (bns != null) {
        // Add peered RightTuples, they are attached to FH - unlink LeftTuples that has a peer ref
        for (int i = 0; i < length; i++) {
          rightTuple = rightTuple.getHandleNext();
          rightTuples = bms[i].getStagedRightTuples();
          switch (rightTuple.getStagedType()) {
            case LeftTuple.INSERT:
              {
                rightTuples.removeInsert(rightTuple);
                break;
              }
            case LeftTuple.UPDATE:
              {
                rightTuples.removeUpdate(rightTuple);
                break;
              }
          }
          rightTuples.addUpdate(rightTuple);
        }
      }

      leftTuple.clearStaged();
      leftTuple = next;
    }

    srcTuples.resetAll();
  }
Ejemplo n.º 3
0
 public void execute(InternalWorkingMemory workingMemory) {
   final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
   accctx.setAction(null);
   node.evaluateResultConstraints(
       source, leftTuple, context, workingMemory, memory, accctx, useLeftMemory);
 }