mariofusco commented on code in PR #6488:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6488#discussion_r2433357766


##########
drools-core/src/main/java/org/drools/core/reteoo/SegmentMemory.java:
##########
@@ -282,32 +297,77 @@ public void addPathMemory(PathMemory pathMemory) {
         }
     }
 
+    public void splitBitMasks(SegmentMemory sm, int pos) {
+        int splitPos = pos + 1; // +1 as zero based
+        long currentAllLinkedMaskTest = allLinkedMaskTest;
+        long currentLinkedNodeMask = linkedNodeMask;
+        long mask = (1L << splitPos) - 1;
+
+        this.allLinkedMaskTest = mask & currentAllLinkedMaskTest;
+        this.linkedNodeMask = linkedNodeMask & allLinkedMaskTest;
+
+        mask = currentAllLinkedMaskTest >> splitPos;
+        sm.allLinkedMaskTest = mask;
+        sm.linkedNodeMask = mask & (currentLinkedNodeMask >> splitPos);
+    }
+
+    public void splitBitMasks(SegmentMemory sm, long currentLinkedNodeMask) {
+        // @TODO Haven't made this work for more than 64 nodes, as per 
SegmentUtilities.nextNodePosMask (mdp)
+        int splitPos = proto.getNodesInSegment().length; // +1 as zero based
+        long currentDirtyNodeMask = dirtyNodeMask;
+        long splitMask = ((1L << (splitPos)) - 1);
+
+        this.dirtyNodeMask = currentDirtyNodeMask & splitMask;
+        this.linkedNodeMask = currentLinkedNodeMask & splitMask;
+
+        sm.linkedNodeMask = currentLinkedNodeMask >> splitPos;
+        sm.dirtyNodeMask = currentDirtyNodeMask >> splitPos;
+    }
+
+    public void mergeBitMasks(SegmentMemory sm) {
+        long mask = sm.allLinkedMaskTest << sm.nodeMemories.length;
+        this.allLinkedMaskTest = mask & allLinkedMaskTest;
+
+        mask = sm.allLinkedMaskTest << sm.nodeMemories.length;

Review Comment:
   Thinking twice, since you didn't change the logic, and indeed all tests are 
green, I would rather merge this pull request as it and attempt to rewrite this 
method according to our intuition in a separated one, do you agree?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to