[rules-users] Avoid caching method results within non fact objects

Wolfgang Laun wolfgang.laun at gmail.com
Fri Aug 3 11:49:42 EDT 2012


This...

On 03/08/2012, rogelio_sevilla1 <rogelio.sevilla1 at gmail.com> wrote:
> Thanks Laune and Greg,
>
> Yes, I'm pretty positive that the amount of facts are the real problem in
> my
> situation. Currently I have only 3 rules, and the first one is in charge of
> creating the previous state from a current fact in case it has not been
> created.
>
> If the session receives a current fact for the first time, this rule
> creates
> the previous state object so it can be updated within other rules.
>
> I have something like this (just a example, sorry for typos):
>
> rule "State Generator"
> when
>   $currentFact : CurrentFact()
>   not PreviousFact(id == $currentFact.id)
> then
>   PreviousFact previousFact = new PreviousFact();
>   previousFact.cloneThis($currentFact)                      // ?
>   insert(previousFact)  <-- this takes a lot of time
> end

...is strange. First, the line I've marked with "// ?" is incorrect.
But, more importantly, you should retract the CurrentFact *before* you
insert the PreviousFact. Otherwise, you'll create some useless
overhead.

-W


>
>
> That's why I would really like to avoid inserting these states within the
> working memory. When I started storing them in the Wrapper Hash, the
> fireAllRules went from 80 seconds of execution to 7 seconds.
>
> Thanks a lot in advance for your advice.
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Avoid-caching-method-results-within-non-fact-objects-tp4019005p4019017.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list