Ejemplo n.º 1
0
  public static void dpUpdatesExistentialReorderLeftMemory(
      BetaMemory bm, LeftTupleSets srcLeftTuples) {
    LeftTupleMemory ltm = bm.getLeftTupleMemory();

    // sides must first be re-ordered, to ensure iteration integrity
    for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; ) {
      LeftTuple next = leftTuple.getStagedNext();
      if (leftTuple.getMemory() != null) {
        ltm.remove(leftTuple);
      }
      leftTuple = next;
    }

    for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; ) {
      LeftTuple next = leftTuple.getStagedNext();
      if (leftTuple.getBlocker() == null) {
        ltm.add(leftTuple);
        for (LeftTuple childLeftTuple = leftTuple.getFirstChild(); childLeftTuple != null; ) {
          LeftTuple childNext = childLeftTuple.getLeftParentNext();
          childLeftTuple.reAddRight();
          childLeftTuple = childNext;
        }
      }
      leftTuple = next;
    }
  }
Ejemplo n.º 2
0
    public void execute(InternalWorkingMemory workingMemory) {
      leftTuple.setLeftTupleSink(this.node);
      if (leftTuple.getFirstChild() == null) {
        this.node.assertLeftTuple(leftTuple, context, workingMemory);
      } else {
        if (retract) {
          this.node
              .getSinkPropagator()
              .propagateRetractLeftTuple(leftTuple, context, workingMemory);
        } else {
          this.node
              .getSinkPropagator()
              .propagateModifyChildLeftTuple(leftTuple, context, workingMemory, true);
        }
      }

      if (leftTuple.getLeftParent() == null) {
        // It's not an open query, as we aren't recording parent chains, so we need to clear out
        // right memory

        Object node = workingMemory.getNodeMemory(this.node);

        RightTupleMemory rightMemory = null;
        if (node instanceof BetaMemory) {
          rightMemory = ((BetaMemory) node).getRightTupleMemory();
        } else if (node instanceof AccumulateMemory) {
          rightMemory = ((AccumulateMemory) node).betaMemory.getRightTupleMemory();
        }

        final TupleStartEqualsConstraint constraint = TupleStartEqualsConstraint.getInstance();
        TupleStartEqualsConstraintContextEntry contextEntry =
            new TupleStartEqualsConstraintContextEntry();
        contextEntry.updateFromTuple(workingMemory, leftTuple);

        FastIterator rightIt = rightMemory.fastIterator();
        RightTuple temp = null;
        for (RightTuple rightTuple =
                rightMemory.getFirst(
                    leftTuple, (InternalFactHandle) context.getFactHandle(), rightIt);
            rightTuple != null; ) {
          temp = (RightTuple) rightIt.next(rightTuple);

          if (constraint.isAllowedCachedLeft(contextEntry, rightTuple.getFactHandle())) {
            rightMemory.remove(rightTuple);
          }
          rightTuple = temp;
        }
      }
    }
Ejemplo n.º 3
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);
     }
   }
 }