Re: [rules-users] Possibly stupid question... but I have to ask
On 28 July 2011 23:36, menada euje...@gmail.com wrote: Because the fact is not already in the kbase (so i can't modify it and then insert it). (1) X x = new X(...); x.setA(...);...x.setZ(...); insert( x ); (2) X x = new X(...); insert( x ); modify( x ){ setA(...),..., setZ(...) } These two sequences are logically equivalent - you'll have equal objects and facts x at the end. But (1) is decidedly preferred because it is much less work for the engine. Consider: the insert in (2) sends it on one direction and then the modify instructs it otherwise. -W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to add application data via StatefulKnowledgeSession
Which version of drools are you using? The document you pointed out seems a little bit old. Since Drools 5, you can use globals to use application's data in your DRLs. If you are using Drools 5 or higher, I suggest you to read the documentation about globals. Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com 2011/7/28 Matthew Erler wir...@yahoo.com Can someone please show me an example where application data is added to workingMemory as described here: http://docs.codehaus.org/display/DROOLS/Application+Data using StatefulKnowledgeSession? I have a need to populate an object from a rules file and I don't want that object itself to be treated as a rule. All the examples I can find refer to the use of ruleBase to get workingMemory. My code utilizes StatefulKnowledgeSession to fire rules and I don't see how to get ruleBase or workingMemory from it. Thanks. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Condition syntax to access Map
Whoa! See below... 2011/7/28 Edson Tirelli ed.tire...@gmail.com I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == value ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole expression will be false, does not matter the value of c or the value it is being compared against. (Edson: Only if you define it so. The logical implication of c being null in an absent a.b (i.e., a.b==null) could very well be that a.b.c does not exist, and you can't claim that a.b.c exists if a.b. doesn't! Is there no house at some address? (city.street[name].house[number] == null) # true = no such house This test data with false when null: Vienna/TirelliStrasse/42 returns false, hence there *is* such a house. But we don't have a Tirelli Street in Vienna (yet)! Confer this to Perl's ! exists $city{-streets}{Tirelli}[42] ) Raising a null pointer exception, IMO, brings no advantage at all to the table... on the contrary, makes writing rules more difficult. Edson, Mark,... please do recall the times where you have had an NPE in the code in a boolean expression? How painful would it have been if Java would have returned false, continuing to cover a coding error made elsewhere? Why don't other languages tolerate null silently? (Perl, the most pragmatic of all, doesn't - it has introduced an operator I can use or not.) I have no problem when folks want to take shortcuts and live la dolce vita, but emI don't want to be led into the bog without my consent./em So, a builder option to turn this on is allright with me. Another example we had in the past: class Circle implements Shape class Square implements Shape rule X when Circle() from $shapes ... In the above example, $shapes is a list and the rule is clearly looking for Circles. If there are Squares in there, they will just not match. Raising a ClassCastException like it would happen in an imperative language brings no advantage to the table, IMO. This is an entirely different matter than the previous one. I see no reason whatsoever, not to define this from as working with an implicit filter. -W So, IMO, all property navigation should be null pointer safe in the LHS of the rules. This is not what happens today, but I think it should be fixed. Edson 2011/7/28 Vincent LEGENDRE vincent.legen...@eurodecision.com Hi all, I agree with W. : NPE should be the default, and null cases behaviour should be planned by programmers. But I am not sure about using a new operator in rules (and do the update in Guvnor ...). Why not using some drools annotations on the getter specifying the behaviour of an eval on a null value returned by this getter ? And may be these annotation could be added to an existing POJO via the declared type syntax (just like event role in fusion) ? Vincent. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Stateful vs. Stateless Session Performance
The comparison might not be done with the required fairness. Consider that the stateless session's execute method implies a dispose() call, which you appear to be skipping in the stateful test code. If your rules do not insert secondary facts and if you are able to clean up properly after processing one message, you won't see much difference. Also, major gains are only to be expected if you can run a stateless in sequential mode. -W On 29 July 2011 00:08, Ryan R. ryanroll...@gmail.com wrote: I have a usecase where I want to apply rules to messages that are received and processed one message at a time. I am thinking the stateless session matches this usecase. I was surprised though to notice that the stateless session seemed to perform upwards of 10x slower! I am including the below source which illustrates my usage. The DRL file used simply has one rule that does a simple modification on two fields. There is some test code above this stuff that just pushes messages into the plugin. I am also including VisualVM profiling results. The top results are for the stateful while the bottom are for the stateless. It looks like the stateless performance is dominated by calls to ReflectionInstantiator.newInstance()? StatelessKnowledgeSession Code: public class DataConditionPlugin implements Plugin { final KnowledgeBuilder kbuilder; final StatelessKnowledgeSession ksession; public DataConditionPlugin(String drlFileName) { kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); // this will parse and compile in one step kbuilder.add( ResourceFactory.newClassPathResource(drlFileName, DataConditionPlugin.class), ResourceType.DRL); // Check the builder for errors if (kbuilder.hasErrors()) { System.out.println(kbuilder.getErrors().toString()); throw new RuntimeException(Unable to compile \+drlFileName+\.); } // get the compiled packages (which are serializable) final CollectionKnowledgePackage pkgs = kbuilder.getKnowledgePackages(); // add the packages to a knowledgebase (deploy the knowledge packages). final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(pkgs); ksession = kbase.newStatelessKnowledgeSession(); } @Override public Object execute(Object message) { ksession.execute(message); return message; } } StatefulKnowledgeSession Code: public class DataConditionPlugin implements Plugin { final KnowledgeBuilder kbuilder; final StatefulKnowledgeSession ksession; public DataConditionPlugin(String drlFileName) { kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); // this will parse and compile in one step kbuilder.add( ResourceFactory.newClassPathResource(drlFileName, DataConditionPlugin.class), ResourceType.DRL); // Check the builder for errors if (kbuilder.hasErrors()) { System.out.println(kbuilder.getErrors().toString()); throw new RuntimeException(Unable to compile \+drlFileName+\.); } // get the compiled packages (which are serializable) final CollectionKnowledgePackage pkgs = kbuilder.getKnowledgePackages(); // add the packages to a knowledgebase (deploy the knowledge packages). final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(pkgs); ksession = kbase.newStatefulKnowledgeSession(); } protected void finalize() throws Throwable { ksession.dispose(); }; @Override public Object execute(Object message) { FactHandle factHandler = ksession.insert(message); ksession.fireAllRules(); Object o = ksession.getObject(factHandler); ksession.retract(factHandler); return o; } } http://drools.46999.n3.nabble.com/file/n3208057/Screenshot-Java_VisualVM.png -- View this message in context: http://drools.46999.n3.nabble.com/Stateful-vs-Stateless-Session-Performance-tp3208057p3208057.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Using Rule Templates
Can someone point me in the direction of documentation or examples for using Rule Templates together with data held in a database (or source other than XLS / CSV which seems to be what all the examples show)? Many thanks, David ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Condition syntax to access Map
Lets forget that these are nested accessors and the problems they bring. Lets look at what they would be if they were real relations: On 29/07/2011 08:55, Wolfgang Laun wrote: Whoa! See below... 2011/7/28 Edson Tirelli ed.tire...@gmail.com mailto:ed.tire...@gmail.com I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == value ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole expression will be false, does not matter the value of c or the value it is being compared against. (Edson: Only if you define it so. The logical implication of c being null in an absent a.b (i.e., a.b==null) could very well be that a.b.c does not exist, and you can't claim that a.b.c exists if a.b. doesn't! Is there no house at some address? (city.street[name].house[number] == null) # true = no such house $c : City() $s : Street( city == $c, street = name ) House( number == null) The above is identical logic to the more convenient form of nested accessors, it's the proper relational form. In this case if there was no Street, it wouldn't match. This test data with false when null: Vienna/TirelliStrasse/42 returns false, hence there /is/ such a house. But we don't have a Tirelli Street in Vienna (yet)! Confer this to Perl's ! exists $city{-streets}{Tirelli}[42] ) Raising a null pointer exception, IMO, brings no advantage at all to the table... on the contrary, makes writing rules more difficult. Edson, Mark,... please do recall the times where you have had an NPE in the code in a boolean expression? How painful would it have been if Java would have returned false, continuing to cover a coding error made elsewhere? Why don't other languages tolerate null silently? (Perl, the most pragmatic of all, doesn't - it has introduced an operator I can use or not.) I have no problem when folks want to take shortcuts and live la dolce vita, but emI don't want to be led into the bog without my consent./em So, a builder option to turn this on is allright with me. Another example we had in the past: class Circle implements Shape class Square implements Shape rule X when Circle() from $shapes ... In the above example, $shapes is a list and the rule is clearly looking for Circles. If there are Squares in there, they will just not match. Raising a ClassCastException like it would happen in an imperative language brings no advantage to the table, IMO. This is an entirely different matter than the previous one. I see no reason whatsoever, not to define this from as working with an implicit filter. -W So, IMO, all property navigation should be null pointer safe in the LHS of the rules. This is not what happens today, but I think it should be fixed. Edson 2011/7/28 Vincent LEGENDRE vincent.legen...@eurodecision.com mailto:vincent.legen...@eurodecision.com Hi all, I agree with W. : NPE should be the default, and null cases behaviour should be planned by programmers. But I am not sure about using a new operator in rules (and do the update in Guvnor ...). Why not using some drools annotations on the getter specifying the behaviour of an eval on a null value returned by this getter ? And may be these annotation could be added to an existing POJO via the declared type syntax (just like event role in fusion) ? Vincent. ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com http://www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Condition syntax to access Map
Yes, that is exactly what I think. Pattern matching constraints are like query parameters. They need to exist and evaluate to true in order to match. So, for this to match: a.b.c == null a needs to exist and be non-null, b needs to exist and be non-null, c needs to exist and be null. So it is not just NP safe navigation... it is an existence test at the same time. So for maps a[x].b[y].c[z] == null The keys x, y and z need to exist, and c[z] must have a value of null. That is what the expression above is asking for, in my understanding. This presents no loss of completeness to the language, as you can still test non-existence of keys if that is what you want, but the most common case you are looking for the opposite and it becomes much simpler to write rules that way. So, a builder option to turn this on is allright with me. We can probably do that and have a configuration option to turn this feature on/off. Edson 2011/7/29 Mark Proctor mproc...@codehaus.org Lets forget that these are nested accessors and the problems they bring. Lets look at what they would be if they were real relations: On 29/07/2011 08:55, Wolfgang Laun wrote: Whoa! See below... 2011/7/28 Edson Tirelli ed.tire...@gmail.com I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == value ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole expression will be false, does not matter the value of c or the value it is being compared against. (Edson: Only if you define it so. The logical implication of c being null in an absent a.b (i.e., a.b==null) could very well be that a.b.c does not exist, and you can't claim that a.b.c exists if a.b. doesn't! Is there no house at some address? (city.street[name].house[number] == null) # true = no such house $c : City() $s : Street( city == $c, street = name ) House( number == null) The above is identical logic to the more convenient form of nested accessors, it's the proper relational form. In this case if there was no Street, it wouldn't match. This test data with false when null: Vienna/TirelliStrasse/42 returns false, hence there *is* such a house. But we don't have a Tirelli Street in Vienna (yet)! Confer this to Perl's ! exists $city{-streets}{Tirelli}[42] ) Raising a null pointer exception, IMO, brings no advantage at all to the table... on the contrary, makes writing rules more difficult. Edson, Mark,... please do recall the times where you have had an NPE in the code in a boolean expression? How painful would it have been if Java would have returned false, continuing to cover a coding error made elsewhere? Why don't other languages tolerate null silently? (Perl, the most pragmatic of all, doesn't - it has introduced an operator I can use or not.) I have no problem when folks want to take shortcuts and live la dolce vita, but emI don't want to be led into the bog without my consent./em So, a builder option to turn this on is allright with me. Another example we had in the past: class Circle implements Shape class Square implements Shape rule X when Circle() from $shapes ... In the above example, $shapes is a list and the rule is clearly looking for Circles. If there are Squares in there, they will just not match. Raising a ClassCastException like it would happen in an imperative language brings no advantage to the table, IMO. This is an entirely different matter than the previous one. I see no reason whatsoever, not to define this from as working with an implicit filter. -W So, IMO, all property navigation should be null pointer safe in the LHS of the rules. This is not what happens today, but I think it should be fixed. Edson 2011/7/28 Vincent LEGENDRE vincent.legen...@eurodecision.com Hi all, I agree with W. : NPE should be the default, and null cases behaviour should be planned by programmers. But I am not sure about using a new operator in rules (and do the update in Guvnor ...). Why not using some drools annotations on the getter specifying the behaviour of an eval on a null value returned by this getter ? And may be these annotation could be added to an existing POJO via the declared type syntax (just like event role in fusion) ? Vincent. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing
Re: [rules-users] Condition syntax to access Map
On 29/07/2011 14:28, Edson Tirelli wrote: Yes, that is exactly what I think. Pattern matching constraints are like query parameters. They need to exist and evaluate to true in order to match. So, for this to match: a.b.c == null a needs to exist and be non-null, b needs to exist and be non-null, c needs to exist and be null. So it is not just NP safe navigation... it is an existence test at the same time. So for maps a[x].b[y].c[z] == null The keys x, y and z need to exist, and c[z] must have a value of null. That is what the expression above is asking for, in my understanding. This presents no loss of completeness to the language, as you can still test non-existence of keys if that is what you want, but the most common case you are looking for the opposite and it becomes much simpler to write rules that way. So, a builder option to turn this on is allright with me. We can probably do that and have a configuration option to turn this feature on/off. I'm strongly against configuration options in this case, we decide on one way and stick with it. We already have too many configurations and a casual person looking at the code could introduce a bug as they weren't aware of what configuratino was on for null safety. I think part of the problem here is we are mixing domains, between script evaluation and relational constraints. There is a reason why other rule engines don't do nested accessors :) (ignoring the technical issues too). Mark Mark Edson 2011/7/29 Mark Proctor mproc...@codehaus.org mailto:mproc...@codehaus.org Lets forget that these are nested accessors and the problems they bring. Lets look at what they would be if they were real relations: On 29/07/2011 08:55, Wolfgang Laun wrote: Whoa! See below... 2011/7/28 Edson Tirelli ed.tire...@gmail.com mailto:ed.tire...@gmail.com I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == value ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole expression will be false, does not matter the value of c or the value it is being compared against. (Edson: Only if you define it so. The logical implication of c being null in an absent a.b (i.e., a.b==null) could very well be that a.b.c does not exist, and you can't claim that a.b.c exists if a.b. doesn't! Is there no house at some address? (city.street[name].house[number] == null) # true = no such house $c : City() $s : Street( city == $c, street = name ) House( number == null) The above is identical logic to the more convenient form of nested accessors, it's the proper relational form. In this case if there was no Street, it wouldn't match. This test data with false when null: Vienna/TirelliStrasse/42 returns false, hence there /is/ such a house. But we don't have a Tirelli Street in Vienna (yet)! Confer this to Perl's ! exists $city{-streets}{Tirelli}[42] ) Raising a null pointer exception, IMO, brings no advantage at all to the table... on the contrary, makes writing rules more difficult. Edson, Mark,... please do recall the times where you have had an NPE in the code in a boolean expression? How painful would it have been if Java would have returned false, continuing to cover a coding error made elsewhere? Why don't other languages tolerate null silently? (Perl, the most pragmatic of all, doesn't - it has introduced an operator I can use or not.) I have no problem when folks want to take shortcuts and live la dolce vita, but emI don't want to be led into the bog without my consent./em So, a builder option to turn this on is allright with me. Another example we had in the past: class Circle implements Shape class Square implements Shape rule X when Circle() from $shapes ... In the above example, $shapes is a list and the rule is clearly looking for Circles. If there are Squares in there, they will just not match. Raising a ClassCastException like it would happen in an imperative language brings no advantage to the table, IMO. This is an entirely different matter than the previous one. I see no reason whatsoever, not to define this from as working with an implicit filter. -W So, IMO, all property navigation should be null pointer safe in the LHS of the rules. This is not what happens today, but I think it should be fixed. Edson 2011/7/28 Vincent LEGENDRE vincent.legen...@eurodecision.com
Re: [rules-users] Using Rule Templates
Are you aware of the Expert manual's Chapter Authoring, where Section x.2, Templates discusses these and, in Subsection x.2.2, Expanding a Template shows how to use Collections of Pojos and Maps as parameter provides for template expansions? -W 2011/7/29 David Godfrey davidg...@gmail.com Can someone point me in the direction of documentation or examples for using Rule Templates together with data held in a database (or source other than XLS / CSV which seems to be what all the examples show)? Many thanks, David ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] error resolving class name on imported class when loading package
I am getting an error when the knowledge agent loads a pkg. The rules source file contains an import for a class: com.abclegal.domain.task.FileDocumentsWithCourtTask and the RHS of a rule makes a cast using the class name without fully qualifying it: ((FileDocumentsWithCourtTask)$step.getTask()).addDocument($doc); I see the following error when the package is loaded by knowledge agent: Error creating bean with name 'workflowKnowledgeAgent': Invocation of init method failed; nested exception is [Error: unable to resolve method using strict-mode: java.lang.Object.FileDocumentsWithCourtTask()] [Near : {... ((FileDocumentsWithCourtTask)$st }] note in the error that the FileDocumentsWithCourtTask is not being resolved according to the import statement. The really odd thing about this is that it doesn't get the error all the time. Sometimes the package is loaded without error. I can probably resolve this by fully-qualifying the class name within the RHS, but you are not supposed to have to do that if you put the fully-qualified name in the import of the rule. Any clue why this error might happen? -- View this message in context: http://drools.46999.n3.nabble.com/error-resolving-class-name-on-imported-class-when-loading-package-tp3210034p3210034.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to add application data via StatefulKnowledgeSession
I'm using Drool 5. I reviewed globals and it looks like it might be appropriate for my situation. I find plenty of documentation on how to use a global in a consequence, but none on how to use a global in a condition. Do you know if it's possible to use a global in a condition? My situation is that I need to check a container class to see if the container is filled, if not then fill the container (the condition would actually be more elaborate and include facts but I'm omitting them for the sake of brevity). The DRL file would look something like this (the example doesn't work of course): global com.example.Container globalContainer; rule container full rule when globalContainer.getContentsFlag() == false then globalContainer.fill(new ContainerContents()); globalContainer.setContentsFlag(true); --- On Fri, 7/29/11, Esteban Aliverti esteban.alive...@gmail.com wrote: From: Esteban Aliverti esteban.alive...@gmail.com Subject: Re: [rules-users] How to add application data via StatefulKnowledgeSession To: Rules Users List rules-users@lists.jboss.org Date: Friday, July 29, 2011, 3:51 AM Which version of drools are you using? The document you pointed out seems a little bit old.Since Drools 5, you can use globals to use application's data in your DRLs.If you are using Drools 5 or higher, I suggest you to read the documentation about globals. Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com 2011/7/28 Matthew Erler wir...@yahoo.com Can someone please show me an example where application data is added to workingMemory as described here: http://docs.codehaus.org/display/DROOLS/Application+Data using StatefulKnowledgeSession? I have a need to populate an object from a rules file and I don't want that object itself to be treated as a rule. All the examples I can find refer to the use of ruleBase to get workingMemory. My code utilizes StatefulKnowledgeSession to fire rules and I don't see how to get ruleBase or workingMemory from it. Thanks. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to add application data via StatefulKnowledgeSession
If the global is both modified by rules and investigated by rules: then it's not a global but a singleton fact. You can use a global in a condition, but only if the data obtained from the global is constant over time. I think that your container ought to be a fact. -W 2011/7/29 Matthew Erler wir...@yahoo.com I'm using Drool 5. I reviewed globals and it looks like it might be appropriate for my situation. I find plenty of documentation on how to use a global in a consequence, but none on how to use a global in a condition. Do you know if it's possible to use a global in a condition? My situation is that I need to check a container class to see if the container is filled, if not then fill the container (the condition would actually be more elaborate and include facts but I'm omitting them for the sake of brevity). The DRL file would look something like this (the example doesn't work of course): global com.example.Container globalContainer; rule container full rule when globalContainer.getContentsFlag() == false then globalContainer.fill(new ContainerContents()); globalContainer.setContentsFlag(true); --- On *Fri, 7/29/11, Esteban Aliverti esteban.alive...@gmail.com*wrote: From: Esteban Aliverti esteban.alive...@gmail.com Subject: Re: [rules-users] How to add application data via StatefulKnowledgeSession To: Rules Users List rules-users@lists.jboss.org Date: Friday, July 29, 2011, 3:51 AM Which version of drools are you using? The document you pointed out seems a little bit old. Since Drools 5, you can use globals to use application's data in your DRLs. If you are using Drools 5 or higher, I suggest you to read the documentation about globals. Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com 2011/7/28 Matthew Erler wir...@yahoo.comhttp://mc/compose?to=wir...@yahoo.com Can someone please show me an example where application data is added to workingMemory as described here: http://docs.codehaus.org/display/DROOLS/Application+Data using StatefulKnowledgeSession? I have a need to populate an object from a rules file and I don't want that object itself to be treated as a rule. All the examples I can find refer to the use of ruleBase to get workingMemory. My code utilizes StatefulKnowledgeSession to fire rules and I don't see how to get ruleBase or workingMemory from it. Thanks. ___ rules-users mailing list rules-users@lists.jboss.orghttp://mc/compose?to=rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.orghttp://mc/compose?to=rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Condition syntax to access Map
Ah, other engines don't do nested accessors because they're wimps. WIMPS! :) --- On Fri, 7/29/11, Mark Proctor mproc...@codehaus.org wrote: From: Mark Proctor mproc...@codehaus.org Subject: Re: [rules-users] Condition syntax to access Map To: rules-users@lists.jboss.org Date: Friday, July 29, 2011, 8:52 AM On 29/07/2011 14:28, Edson Tirelli wrote: Yes, that is exactly what I think. Pattern matching constraints are like query parameters. They need to exist and evaluate to true in order to match. So, for this to match: a.b.c == null a needs to exist and be non-null, b needs to exist and be non-null, c needs to exist and be null. So it is not just NP safe navigation... it is an existence test at the same time. So for maps a[x].b[y].c[z] == null The keys x, y and z need to exist, and c[z] must have a value of null. That is what the expression above is asking for, in my understanding. This presents no loss of completeness to the language, as you can still test non-existence of keys if that is what you want, but the most common case you are looking for the opposite and it becomes much simpler to write rules that way. So, a builder option to turn this on is allright with me. We can probably do that and have a configuration option to turn this feature on/off. I'm strongly against configuration options in this case, we decide on one way and stick with it. We already have too many configurations and a casual person looking at the code could introduce a bug as they weren't aware of what configuratino was on for null safety. I think part of the problem here is we are mixing domains, between script evaluation and relational constraints. There is a reason why other rule engines don't do nested accessors :) (ignoring the technical issues too). Mark Mark Edson 2011/7/29 Mark Proctor mproc...@codehaus.org Lets forget that these are nested accessors and the problems they bring. Lets look at what they would be if they were real relations: On 29/07/2011 08:55, Wolfgang Laun wrote: Whoa! See below... 2011/7/28 Edson Tirelli ed.tire...@gmail.com I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == value ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole expression will be false, does not matter the value of c or the value it is being compared against. (Edson: Only if you define it so. The logical implication of c being null in an absent a.b (i.e., a.b==null) could very well be that a.b.c does not exist, and you can't claim that a.b.c exists if a.b. doesn't! Is there no house at some address? (city.street[name].house[number] == null) # true = no such house $c : City() $s : Street( city == $c, street = name ) House( number == null) The above is identical logic to the more convenient form of nested accessors, it's the proper relational form. In this case if there was no Street, it wouldn't match. This test data with false when null: Vienna/TirelliStrasse/42 returns false, hence there is such a house. But we don't have a Tirelli Street in Vienna (yet)! Confer this to Perl's
Re: [rules-users] Stateful vs. Stateless Session Performance
Thanks Wolfgang- I did not realize the stateless session was just a wrapper around the stateful session. I think the stateful with manual cleanup after each fireAllRules invocation is the way to go here. As a follow up question, do you think Drools and Rules Engines in general are the way to go for operations that distort object field values one object at a time? Would an embedded scripting language better fit this usecase? I also did some additional benchmarking with virtually the same stateful session setup. The below plot shows execution time of the rules engine for Java POJO (static) and MessagePack (Dynamic) Messages from 1000 - 200K messages in step sizes of 1000 messages. I was surprised to see the discrete jumps of 1 second in execution time. I was also surprised to see that on the low end execution time for a few thousand messages was 1 second? That seemed slow and why the discrete jumps? Sorry no label on plot: Y Axis is Exec time in seconds X Axis is Number of Messages (Step Size 1K messages) http://drools.46999.n3.nabble.com/file/n3210745/WithPayloadNoFieldRemoval.jpg Ryan R. -- View this message in context: http://drools.46999.n3.nabble.com/Stateful-vs-Stateless-Session-Performance-tp3208057p3210745.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Stateful vs. Stateless Session Performance
Please ignore the previously posted benchmark data. The benchmark code had a bug. -- View this message in context: http://drools.46999.n3.nabble.com/Stateful-vs-Stateless-Session-Performance-tp3208057p3211133.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[
Hello, I am new to Drools. On starting to execute a simple program, eclipse gives the following stacktrace as error. I even included the org.eclipse.jdt that comes with eclipse, but it is still giving me error. Anybody please suggest the problem. I am using Drools 5.0 and its dependencies and Eclipse Helios java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem; at org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(EclipseJavaCompiler.java:321) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335) at org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:351) at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51) at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:389) at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:56) at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:74) at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:690) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:653) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25) at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:40) at com.sample.DroolsTest.main(DroolsTest.java:23) Thanks -- View this message in context: http://drools.46999.n3.nabble.com/org-eclipse-jdt-internal-compiler-CompilationResult-getProblems-tp3211240p3211240.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users