コード例 #1
0
  private static ProtobufMessages.NodeMemory writeAccumulateNodeMemory(
      final int nodeId, final Memory memory) {
    // for accumulate nodes, we need to store the ID of created (result) handles
    AccumulateMemory accmem = (AccumulateMemory) memory;
    if (accmem.betaMemory.getLeftTupleMemory().size() > 0) {
      ProtobufMessages.NodeMemory.AccumulateNodeMemory.Builder _accumulate =
          ProtobufMessages.NodeMemory.AccumulateNodeMemory.newBuilder();

      final org.drools.core.util.Iterator tupleIter =
          accmem.betaMemory.getLeftTupleMemory().iterator();
      for (LeftTuple leftTuple = (LeftTuple) tupleIter.next();
          leftTuple != null;
          leftTuple = (LeftTuple) tupleIter.next()) {
        AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
        if (accctx.getResultFactHandle() != null) {
          FactHandle _handle =
              ProtobufMessages.FactHandle.newBuilder()
                  .setId(accctx.getResultFactHandle().getId())
                  .setRecency(accctx.getResultFactHandle().getRecency())
                  .build();
          _accumulate.addContext(
              ProtobufMessages.NodeMemory.AccumulateNodeMemory.AccumulateContext.newBuilder()
                  .setTuple(PersisterHelper.createTuple(leftTuple))
                  .setResultHandle(_handle)
                  .build());
        }
      }

      return ProtobufMessages.NodeMemory.newBuilder()
          .setNodeId(nodeId)
          .setNodeType(ProtobufMessages.NodeMemory.NodeType.ACCUMULATE)
          .setAccumulate(_accumulate.build())
          .build();
    }
    return null;
  }
コード例 #2
0
 public void execute(InternalWorkingMemory workingMemory) {
   final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
   accctx.setAction(null);
   node.evaluateResultConstraints(
       source, leftTuple, context, workingMemory, memory, accctx, useLeftMemory);
 }