-
Notifications
You must be signed in to change notification settings - Fork 9
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
DROOLS-7475 Proposed feature for ['key'] accessor #56
Changes from 1 commit
a4f6afe
1cd8cf9
7493fde
7cd6073
941af73
7db369b
b1cf0d7
5f6004c
2ebf1f4
bc9cb36
0f41f50
f6ccd37
b536459
b2602bb
08c78d3
4dc4656
896b925
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,11 @@ | |
import org.drools.model.Prototype; | ||
import org.drools.model.PrototypeDSL; | ||
import org.drools.model.PrototypeExpression; | ||
import org.drools.model.PrototypeExpression.IndexableExpression; | ||
import org.drools.model.PrototypeFact; | ||
import org.drools.model.functions.Function1; | ||
|
||
public class ExtractorPrototypeExpression implements PrototypeExpression { | ||
public class ExtractorPrototypeExpression implements PrototypeExpression, IndexableExpression { | ||
/** | ||
* This is okay for ansible-integration work as prototype do not define accessor programmatically, | ||
* but having prototype definition ignored in {@link #asFunction(Prototype)} call, ought to be revised | ||
|
@@ -40,7 +41,6 @@ public Function1<PrototypeFact, Object> asFunction(Prototype prototype) { | |
}; | ||
} | ||
|
||
// TODO used for indexing, normalizing chunks. | ||
public String getFieldName() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this is breaking indexing, see https://github.com/kiegroup/drools/blob/main/drools-model/drools-canonical-model/src/main/java/org/drools/model/PrototypeDSL.java#L135 What I suggest is introducing an interface named something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also it would be nice to add a few assertions in some tests, for instance here, to make sure that the alpha node is indexed as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems no other way indeed given There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about just adding the extractor method to the In this way we can avoid the instanceof and the downcasting: each expression can be indexable returning a value or not with an empty option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the comment @danielezonca
are semantically guarding JUST-and-only the indexing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danielezonca I don't see any semantic difference between the method returning an Optional and the new interface and actually I still prefer to use the second to have clearer marker between which expression is indexable and which isn't. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return this.computedFieldName; | ||
} | ||
|
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'm not familiar with this
RulesEvaluator
interface (even if we have probably similar concepts in Drools repo) but I guess it is a "facade" to hide the Session (a bit similar to theRuleEvaluator
in Drools). I don't think we want to expose aasKieSession
.@mariofusco
Wdyt?
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 believe is package-protected for testing puposes? 🤔
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.
Yes, this is only for testing purpose and unfortunately unavoidable. In particular the need is to access the
KieSession
and then theKieBase
and theRete
network to check that a node was indexed as expected. I don't see any other way to do this.