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;
}
}
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;
}
}
Aggregations