-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Left and Right Tuples aligned with Super Cache improvements #5648 #5649
Conversation
-Improve NodeTypeEnums to contain more information (at no cost) and replace as many instanceof as possible.
1965d97
to
e1007cc
Compare
bom/drools-bom/pom.xml
Outdated
@@ -228,6 +228,25 @@ | |||
<scope>test</scope> | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>org.drools</groupId> | |||
<artifactId>drools-sivparvismagna</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this new module? I don't see it in your pull request (and the name is very cryptic). If this is a leftover can you please remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that is a mistake, let me fix that :) didn't realis that was still in there.
pom.xml
Outdated
@@ -162,6 +162,7 @@ | |||
<module>drools-io</module> | |||
<module>drools-core</module> | |||
<module>drools-base</module> | |||
<!--module>drools-sicparvismagna</module--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove.
pom.xml
Outdated
@@ -272,6 +273,7 @@ | |||
<module>drools-ruleunits</module> | |||
<module>drools-core</module> | |||
<module>drools-base</module> | |||
<module>drools-sivparvismagna</module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not existing new module, please remove.
@@ -0,0 +1,45 @@ | |||
package org.drools.core.reteoo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Apache header.
@@ -45,7 +46,10 @@ public interface NodeMemories { | |||
Memory peekNodeMemory( int memoryId ); | |||
|
|||
default Memory peekNodeMemory(NetworkNode node) { | |||
return node instanceof MemoryFactory ? peekNodeMemory(((MemoryFactory)node).getMemoryId()) : null; | |||
if (!NodeTypeEnums.isMemoryFactory(node) ) { | |||
System.out.println("pause"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this System.out
public class SuperCacheFixer { | ||
public static LeftTupleNode getLeftTupleNode(TupleImpl t) { | ||
Sink s = t.getSink(); | ||
switch (((BaseNode) s).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was needed, when working against interfaces - to avoid potential super cache issues?
|
||
public static RightTupleSink getRightTupleSink(RightTuple t) { | ||
Sink s = t.getSink(); | ||
switch (((BaseNode) s).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
} | ||
|
||
public static LeftTupleSinkNode asLeftTupleSink(NetworkNode n) { | ||
switch (((BaseNode) n).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
} | ||
|
||
public static NetworkNode checkcast(NetworkNode n) { | ||
switch (((BaseNode)n).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
|
||
public static ObjectTypeNode getObjectTypeNode(TupleImpl t) { | ||
Sink s = t.getSink(); | ||
switch (((BaseNode) s).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
|
||
public static ObjectTypeNodeId getLeftInputOtnId(TupleImpl t) { | ||
Sink s = t.getSink(); | ||
switch (((BaseNode) s).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
|
||
public static ObjectTypeNodeId getRightInputOtnId(TupleImpl t) { | ||
Sink s = t.getSink(); | ||
switch (((BaseNode) s).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
public static LeftTupleSource getLeftTupleSource(TupleImpl t) { | ||
Sink s = t.getSink(); | ||
LeftTupleSource n; | ||
switch (((BaseNode) s).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
throw new UnsupportedOperationException("Does not have a LeftTupleSource: " + s); | ||
} | ||
|
||
switch (n.getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be better to collapse these 2 subsequent switches into a single one?
throw new UnsupportedOperationException("Node does not have an ObjectSource: " + s); | ||
} | ||
|
||
switch (o.getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be better to collapse these 2 subsequent switches into a single one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not possible because we don't know the concrete type of getLeftTupleSource(), so it needs a second switch. However, this is only true if performance is improved via the concrete cast. If this cast adds no perf value, it can be removed.
public static ObjectSource getObjectSource(TupleImpl t) { | ||
Sink s = t.getSink(); | ||
ObjectSource o; | ||
switch (((BaseNode) s).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
|
||
public static TerminalNode asTerminalNode(TupleImpl t) { | ||
Sink s = t.getSink(); | ||
switch (((BaseNode) t.getSink()).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
} | ||
|
||
public static TerminalNode asTerminalNode(NetworkNode n) { | ||
switch (((BaseNode)n).getType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary cast.
public class BetaMemory<C> extends AbstractBaseLinkedListNode<Memory> | ||
implements | ||
SegmentNodeMemory { | ||
public interface BetaMemory<C> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to introduce this interface? Maybe I'm missing something but I see only one implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this was related to some work I did initially. I can revert for now. I wanted to move stuff out of core and avoid bringing too much into -base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks for this refactor, it's much cleaner now. Please only review my comments, especially the ones on the unnecessary new module declaration.
-Remove unecessary if statement with printout. -Removed incorrectly added maven module.
Benchmark result:
|
type pollution report (omitting types count less than 10000)
== without PR
== with PR (pr5649 "Added missing headers" commit)
== with PR (pr5649 "minor semplifications" commit)
|
== without PR
== with PR (pr5649 "Added missing headers" commit)
== with PR (pr5649 "minor semplifications" commit)
|
…pache#5648 (apache#5649) * -BetaConstraints no longer depends on ReteEvaluator. * -Trying to separate BetaMemory so BetaConstraints can go in -base. * -Refactoring Tuples around concrete classes. * -Centralise and improve super cache handling fix. -Improve NodeTypeEnums to contain more information (at no cost) and replace as many instanceof as possible. * -Move Super Cache helper methods into standalone class SuperCacheFixer. * -Remove RightTuple interface. * -Refactory creation to a Factory with switch for different implementations. * -Added missing headers. -Remove unecessary if statement with printout. -Removed incorrectly added maven module. * minor semplifications --------- Co-authored-by: mariofusco <[email protected]>
…pache#5648 (apache#5649) * -BetaConstraints no longer depends on ReteEvaluator. * -Trying to separate BetaMemory so BetaConstraints can go in -base. * -Refactoring Tuples around concrete classes. * -Centralise and improve super cache handling fix. -Improve NodeTypeEnums to contain more information (at no cost) and replace as many instanceof as possible. * -Move Super Cache helper methods into standalone class SuperCacheFixer. * -Remove RightTuple interface. * -Refactory creation to a Factory with switch for different implementations. * -Added missing headers. -Remove unecessary if statement with printout. -Removed incorrectly added maven module. * minor semplifications --------- Co-authored-by: mariofusco <[email protected]>
More detail in the opened issue #5648.
#5648