My question is not really about java, but the implementation of the Rete network.
Rete implementations typically have a pattern network and a join network. The pattern network is responsible for matching constants and 'intra-condition' variable references. The join network is responsible for variable references across conditions. Typically processing within the pattern network is much more efficient than the join network. Back to my original example, by testing each object property separately I create two conditions, hence two nodes in the pattern network. By creating a single comparison function, I reduce this to one condition/pattern node. This may seem like '6 of one, half dozen of the other', but what if my test object has 10 properties? Would it be better to have 10 conditions in my rule, or create a comparison method and have only one condition? It seems to me that in order to facilitate pattern sharing (one of the stated benefits of the Rete network) the use of more, simple conditions might be better. This whole thought process was triggered by a posting a few days back regarding building 'human readable' rules through the effective crafting of Java methods on the test objects. I started to wonder what the impact of this would be to pattern matching within the Rete engine, which leads me to realize that I really didn't understand how pattern matching works in Drools. The general concept of differentiating between the pattern and join networks also has relevance to some work that is happening on my current project. Thanks. -Mitch -----Original Message----- From: Michael Neale [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 07, 2006 3:43 PM To: [email protected] Subject: Re: [drools-user] Structuring conditions, alpha and beta networks The former would be more efficient, just as in java code. Its comparing to identies (integer comparison) versus a method call. (assuming the results are the same). On 3/8/06, Mitch Christensen <[EMAIL PROTECTED]> wrote: > > Hey, > > If I have a Java bean with two properties, p1 and p2 and want to have a > rule > that processes matching beans, which set of patterns is 'better' as far as > Drools is concerned? > > Assuming, > > <parameter identifier='b1'><class>MyBean</class></parameter> > <parameter identifier='b2'><class>MyBean</class></parameter> > > Then would > > <java:condition>b1.getP1() == b2.getP1()</java:condition> > <java:condition>b1.getP2() == b2.getP2()</java:condition> > > OR > > <java:condition>b1.equals(b2)</java:condition> > > (assuming I've properly implemented equals()) > > Be more appropriate? > > Are there any performance implications between the two? > > My experience with other Rete implementations is that the alpha network > performs constant tests. In Drools, I'm having a hard time visualizing > the > difference between what the alpha and beta portions of the network will be > processing. > > It seems to me that the alpha portion of the network should be responsible > for the parameter identification (is this true?), if so, does it also > apply > to conditions, and if so, to what extent? > > I have read most (if not all) of the Drools documentation and still > struggle > a bit understanding how this works. > > Any help or pointers to good documentation would be appreciated. > > Thanks. > -Mitch > > >
