Hi
I'm having trouble understanding how collections are accessed in conditions
and what this means in terms of perfomance. My app has concepts with a
unidirectional composite relation. Making it bidirectional, as suggested in
other posts, is really not preferred. This is the most natural model for
this business.
declare Parent
children : Collection // Collection<Child>
end
declare Child
anAttribute : String
end
With this set-up, I can think of only two rules to check for the existence
of a child and only one to check for the absence (without starting to check
for the size of a populated list, which seems farfetched and unreadable):
rule "01 - Parent has child - using contains"
when
$child : Child( )
Parent( children contains $child )
then
// do stuff
end
rule "02 - Parent has child - using from"
when
$parent : Parent( )
Child( ) from $parent.children
then
// do stuff
end
rule "03 - Parent does not have child - using from"
when
$parent : Parent( )
not Child( ) from $parent.children
then
// do stuff
end
1) Is the cost of the "contains" in rule 01 the same as the "from" in
rule
02? Why (not)? If so, inserting the Child facts in the working memory seems
not necessary.
2) I read in other posts and the user guide that putting all facts in
working memory should be faster. Is it correct to say, that the perfomance
gain will only be achieved when not using the "from" CE and thus only by
using a bi-directional relation between Parent and Child?
In any case, it seems to me that stuffing child objects into working memory
shouldn't be the concern of a client calling a "rule service". So should
this be more optimal, I'd make the rules insert the facts using an
agenda/ruleflow to make sure everything is inserted before doing the
business stuff.
Greetz
-Evert
---
If you are posting a question, please try search first. Your question may
have already been answered.
Don't post repeatedly. Wait for a few days. People will read your post by
email.
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Accessing-collections...
Sent from the Drools - User mailing list archive at
Nabble.com.