You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "pibizza (via GitHub)" <gi...@apache.org> on 2025/11/05 14:14:35 UTC
[PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
pibizza opened a new pull request, #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Refactors PHREAK rule network evaluation to encapsulate traversal state into a dedicated SegmentCursor class.
- Extracted SegmentCursor.java - Encapsulates segment traversal state and navigation logic
- Refactored RuleNetworkEvaluatorImpl.java - Simplified to focus on evaluation logic
- Updated method signatures foro the new API
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "mariofusco (via GitHub)" <gi...@apache.org>.
mariofusco commented on code in PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510#discussion_r2499720020
##########
drools-core/src/main/java/org/drools/core/phreak/SegmentCursor.java:
##########
@@ -0,0 +1,475 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.core.phreak;
+
+import org.drools.base.common.NetworkNode;
+import org.drools.base.reteoo.NodeTypeEnums;
+import org.drools.core.common.Memory;
+import org.drools.core.common.TupleSets;
+import org.drools.core.reteoo.BetaMemory;
+import org.drools.core.reteoo.BetaNode;
+import org.drools.core.reteoo.LeftTupleNode;
+import org.drools.core.reteoo.LeftTupleSink;
+import org.drools.core.reteoo.LeftTupleSinkNode;
+import org.drools.core.reteoo.PathMemory;
+import org.drools.core.reteoo.SegmentMemory;
+import org.drools.core.reteoo.SegmentNodeMemory;
+import org.drools.core.reteoo.TerminalNode;
+import org.drools.core.reteoo.TupleToObjectNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.drools.core.phreak.BuildtimeSegmentUtilities.nextNodePosMask;
+
+public class SegmentCursor {
+ private static final Logger log = LoggerFactory.getLogger(SegmentCursor.class);
+
+ private PathMemory pmem;
+ private SegmentMemory[] smems;
+ private int smemIndex;
+ private long bit;
+ private Memory nodeMem;
+ private NetworkNode node;
+ private TupleSets srcTuples;
+ private TupleSets stagedLeftTuples;
+
+ public SegmentCursor(PathMemory pmem,
+ SegmentMemory[] smems,
+ int smemIndex,
+ long bit,
+ Memory nodeMem,
+ NetworkNode node,
+ TupleSets srcTuples) {
+ this.pmem = pmem;
+ this.smems = smems;
+ this.smemIndex = smemIndex;
+ this.bit = bit;
+ this.nodeMem = nodeMem;
+ this.node = node;
+ this.srcTuples = srcTuples;
+ }
+
+ public PathMemory getPathMemory() {
Review Comment:
Are all these getters necessary? Maybe if this class is package private and used only by the `RuleNetworkEvaluator` we could actually get rid of all of them, also make the fields package private and access directly them?
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "mariofusco (via GitHub)" <gi...@apache.org>.
mariofusco merged PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510#issuecomment-3495006470
Btw, Drools GHA (ubuntu-latest) fails these days. Not related to this PR.
I filed a GH issue, and am looking.
https://github.com/apache/incubator-kie-drools/issues/6511
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "pibizza (via GitHub)" <gi...@apache.org>.
pibizza commented on code in PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510#discussion_r2502899174
##########
drools-core/src/main/java/org/drools/core/phreak/SegmentCursor.java:
##########
@@ -0,0 +1,475 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.core.phreak;
+
+import org.drools.base.common.NetworkNode;
+import org.drools.base.reteoo.NodeTypeEnums;
+import org.drools.core.common.Memory;
+import org.drools.core.common.TupleSets;
+import org.drools.core.reteoo.BetaMemory;
+import org.drools.core.reteoo.BetaNode;
+import org.drools.core.reteoo.LeftTupleNode;
+import org.drools.core.reteoo.LeftTupleSink;
+import org.drools.core.reteoo.LeftTupleSinkNode;
+import org.drools.core.reteoo.PathMemory;
+import org.drools.core.reteoo.SegmentMemory;
+import org.drools.core.reteoo.SegmentNodeMemory;
+import org.drools.core.reteoo.TerminalNode;
+import org.drools.core.reteoo.TupleToObjectNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.drools.core.phreak.BuildtimeSegmentUtilities.nextNodePosMask;
+
+public class SegmentCursor {
Review Comment:
Not really, it is used in the metric project by a phreak metric node. I plan to extend to other phreak nodes also.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "mariofusco (via GitHub)" <gi...@apache.org>.
mariofusco commented on code in PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510#discussion_r2499703991
##########
drools-core/src/main/java/org/drools/core/phreak/SegmentCursor.java:
##########
@@ -0,0 +1,475 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.core.phreak;
+
+import org.drools.base.common.NetworkNode;
+import org.drools.base.reteoo.NodeTypeEnums;
+import org.drools.core.common.Memory;
+import org.drools.core.common.TupleSets;
+import org.drools.core.reteoo.BetaMemory;
+import org.drools.core.reteoo.BetaNode;
+import org.drools.core.reteoo.LeftTupleNode;
+import org.drools.core.reteoo.LeftTupleSink;
+import org.drools.core.reteoo.LeftTupleSinkNode;
+import org.drools.core.reteoo.PathMemory;
+import org.drools.core.reteoo.SegmentMemory;
+import org.drools.core.reteoo.SegmentNodeMemory;
+import org.drools.core.reteoo.TerminalNode;
+import org.drools.core.reteoo.TupleToObjectNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.drools.core.phreak.BuildtimeSegmentUtilities.nextNodePosMask;
+
+public class SegmentCursor {
Review Comment:
Can we make this whole class package private?
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "pibizza (via GitHub)" <gi...@apache.org>.
pibizza commented on code in PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510#discussion_r2502904411
##########
drools-core/src/main/java/org/drools/core/phreak/SegmentCursor.java:
##########
@@ -0,0 +1,475 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.core.phreak;
+
+import org.drools.base.common.NetworkNode;
+import org.drools.base.reteoo.NodeTypeEnums;
+import org.drools.core.common.Memory;
+import org.drools.core.common.TupleSets;
+import org.drools.core.reteoo.BetaMemory;
+import org.drools.core.reteoo.BetaNode;
+import org.drools.core.reteoo.LeftTupleNode;
+import org.drools.core.reteoo.LeftTupleSink;
+import org.drools.core.reteoo.LeftTupleSinkNode;
+import org.drools.core.reteoo.PathMemory;
+import org.drools.core.reteoo.SegmentMemory;
+import org.drools.core.reteoo.SegmentNodeMemory;
+import org.drools.core.reteoo.TerminalNode;
+import org.drools.core.reteoo.TupleToObjectNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.drools.core.phreak.BuildtimeSegmentUtilities.nextNodePosMask;
+
+public class SegmentCursor {
+ private static final Logger log = LoggerFactory.getLogger(SegmentCursor.class);
+
+ private PathMemory pmem;
+ private SegmentMemory[] smems;
+ private int smemIndex;
+ private long bit;
+ private Memory nodeMem;
+ private NetworkNode node;
+ private TupleSets srcTuples;
+ private TupleSets stagedLeftTuples;
+
+ public SegmentCursor(PathMemory pmem,
+ SegmentMemory[] smems,
+ int smemIndex,
+ long bit,
+ Memory nodeMem,
+ NetworkNode node,
+ TupleSets srcTuples) {
+ this.pmem = pmem;
+ this.smems = smems;
+ this.smemIndex = smemIndex;
+ this.bit = bit;
+ this.nodeMem = nodeMem;
+ this.node = node;
+ this.srcTuples = srcTuples;
+ }
+
+ public PathMemory getPathMemory() {
Review Comment:
See comment above. I plan to extend the use of the SegmentCursor to other prheak nodes, so probably it's better to keep the getters. Eventually we can decide to throw them away - I really hope we can encapsulate most of their usage anyway.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "pibizza (via GitHub)" <gi...@apache.org>.
pibizza commented on code in PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510#discussion_r2502900711
##########
drools-core/src/main/java/org/drools/core/phreak/SegmentCursor.java:
##########
@@ -0,0 +1,475 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.core.phreak;
+
+import org.drools.base.common.NetworkNode;
+import org.drools.base.reteoo.NodeTypeEnums;
+import org.drools.core.common.Memory;
+import org.drools.core.common.TupleSets;
+import org.drools.core.reteoo.BetaMemory;
+import org.drools.core.reteoo.BetaNode;
+import org.drools.core.reteoo.LeftTupleNode;
+import org.drools.core.reteoo.LeftTupleSink;
+import org.drools.core.reteoo.LeftTupleSinkNode;
+import org.drools.core.reteoo.PathMemory;
+import org.drools.core.reteoo.SegmentMemory;
+import org.drools.core.reteoo.SegmentNodeMemory;
+import org.drools.core.reteoo.TerminalNode;
+import org.drools.core.reteoo.TupleToObjectNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.drools.core.phreak.BuildtimeSegmentUtilities.nextNodePosMask;
+
+public class SegmentCursor {
+ private static final Logger log = LoggerFactory.getLogger(SegmentCursor.class);
+
+ private PathMemory pmem;
Review Comment:
Done
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues #203] Cleanup Phreak code - Extract SegmentCursor [incubator-kie-drools]
Posted by "mariofusco (via GitHub)" <gi...@apache.org>.
mariofusco commented on code in PR #6510:
URL: https://github.com/apache/incubator-kie-drools/pull/6510#discussion_r2499709152
##########
drools-core/src/main/java/org/drools/core/phreak/SegmentCursor.java:
##########
@@ -0,0 +1,475 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.core.phreak;
+
+import org.drools.base.common.NetworkNode;
+import org.drools.base.reteoo.NodeTypeEnums;
+import org.drools.core.common.Memory;
+import org.drools.core.common.TupleSets;
+import org.drools.core.reteoo.BetaMemory;
+import org.drools.core.reteoo.BetaNode;
+import org.drools.core.reteoo.LeftTupleNode;
+import org.drools.core.reteoo.LeftTupleSink;
+import org.drools.core.reteoo.LeftTupleSinkNode;
+import org.drools.core.reteoo.PathMemory;
+import org.drools.core.reteoo.SegmentMemory;
+import org.drools.core.reteoo.SegmentNodeMemory;
+import org.drools.core.reteoo.TerminalNode;
+import org.drools.core.reteoo.TupleToObjectNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.drools.core.phreak.BuildtimeSegmentUtilities.nextNodePosMask;
+
+public class SegmentCursor {
+ private static final Logger log = LoggerFactory.getLogger(SegmentCursor.class);
+
+ private PathMemory pmem;
Review Comment:
I believe that some of these fields could be flagged as `final`?
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org