Search in sources :

Example 1 with SegmentNodeMemory

use of org.drools.core.reteoo.SegmentNodeMemory in project drools by kiegroup.

the class AddRemoveRule method splitNodeMemories.

private static void splitNodeMemories(SegmentMemory sm1, SegmentMemory sm2, int pos) {
    LinkedList<Memory> smNodeMemories1 = sm1.getNodeMemories();
    LinkedList<Memory> smNodeMemories2 = sm2.getNodeMemories();
    Memory mem = smNodeMemories1.getFirst();
    int nodePosMask = 1;
    for (int i = 0, length = smNodeMemories1.size(); i < length; i++) {
        Memory next = mem.getNext();
        if (i > pos) {
            smNodeMemories1.remove(mem);
            smNodeMemories2.add(mem);
            mem.setSegmentMemory(sm2);
            // correct the NodePosMaskBit
            if (mem instanceof SegmentNodeMemory) {
                ((SegmentNodeMemory) mem).setNodePosMaskBit(nodePosMask);
            }
            nodePosMask = nodePosMask << 1;
        }
        mem = next;
    }
}
Also used : Memory(org.drools.core.common.Memory) PathMemory(org.drools.core.reteoo.PathMemory) InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) SegmentNodeMemory(org.drools.core.reteoo.SegmentNodeMemory) ObjectTypeNodeMemory(org.drools.core.reteoo.ObjectTypeNode.ObjectTypeNodeMemory) RiaNodeMemory(org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory) AccumulateMemory(org.drools.core.reteoo.AccumulateNode.AccumulateMemory) TupleMemory(org.drools.core.reteoo.TupleMemory) BetaMemory(org.drools.core.reteoo.BetaMemory) SegmentMemory(org.drools.core.reteoo.SegmentMemory) FromMemory(org.drools.core.reteoo.FromNode.FromMemory) SegmentNodeMemory(org.drools.core.reteoo.SegmentNodeMemory)

Example 2 with SegmentNodeMemory

use of org.drools.core.reteoo.SegmentNodeMemory in project drools by kiegroup.

the class AddRemoveRule method mergeNodeMemories.

private static void mergeNodeMemories(SegmentMemory sm1, SegmentMemory sm2) {
    LinkedList<Memory> smNodeMemories1 = sm1.getNodeMemories();
    LinkedList<Memory> smNodeMemories2 = sm2.getNodeMemories();
    int nodePosMask = 1;
    for (int i = 0, length = smNodeMemories1.size(); i < length; i++) {
        nodePosMask = nodePosMask >> 1;
    }
    for (Memory mem = smNodeMemories2.getFirst(); mem != null; ) {
        Memory next = mem.getNext();
        smNodeMemories2.remove(mem);
        smNodeMemories1.add(mem);
        mem.setSegmentMemory(sm1);
        // correct the NodePosMaskBit
        if (mem instanceof SegmentNodeMemory) {
            ((SegmentNodeMemory) mem).setNodePosMaskBit(nodePosMask);
        }
        nodePosMask = nodePosMask >> 1;
        mem = next;
    }
}
Also used : Memory(org.drools.core.common.Memory) PathMemory(org.drools.core.reteoo.PathMemory) InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) SegmentNodeMemory(org.drools.core.reteoo.SegmentNodeMemory) ObjectTypeNodeMemory(org.drools.core.reteoo.ObjectTypeNode.ObjectTypeNodeMemory) RiaNodeMemory(org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory) AccumulateMemory(org.drools.core.reteoo.AccumulateNode.AccumulateMemory) TupleMemory(org.drools.core.reteoo.TupleMemory) BetaMemory(org.drools.core.reteoo.BetaMemory) SegmentMemory(org.drools.core.reteoo.SegmentMemory) FromMemory(org.drools.core.reteoo.FromNode.FromMemory) SegmentNodeMemory(org.drools.core.reteoo.SegmentNodeMemory)

Aggregations

InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)2 Memory (org.drools.core.common.Memory)2 AccumulateMemory (org.drools.core.reteoo.AccumulateNode.AccumulateMemory)2 BetaMemory (org.drools.core.reteoo.BetaMemory)2 FromMemory (org.drools.core.reteoo.FromNode.FromMemory)2 ObjectTypeNodeMemory (org.drools.core.reteoo.ObjectTypeNode.ObjectTypeNodeMemory)2 PathMemory (org.drools.core.reteoo.PathMemory)2 RiaNodeMemory (org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory)2 SegmentMemory (org.drools.core.reteoo.SegmentMemory)2 SegmentNodeMemory (org.drools.core.reteoo.SegmentNodeMemory)2 TupleMemory (org.drools.core.reteoo.TupleMemory)2