I want to express my concerns about "hardcoding" a filter of identity cross products. Someone might want a rule to fire for an identity activation. And while you can write a RHS that does the filters job, you can't write a RHS that gets you the identity activation if the filter's active.

Probably introduce it as a rule attribute, with default value for filter being activated, if it really is necessary to have such a filter at all.

There is nothing like SELECT * FROM A AS a, A AS b WHERE a.ROWID != b.ROWID hardcoded in SQL either.

Juergen.

Michael Neale wrote:
OK I thought this may cause an issue.

As Yuesong said, it was handy to be able to spread conditions across lines
(sentences in DSLs) as it made it more readable. Now when we do that, it
won't work.
So what do we do? Allow the identity cross product?
In simple cases, yes it does make things easier, but I think in practice,
the benefit of removing the cross product will save people a lot of hassle.

The case Yuesong mentions is valid though, as in you may want to just keep
adding "stand alone" constraints to a fact. But in that case, (with RC1) if
you added one more Message to working memory, then suddenly you would see
"wierd" behaviour (as you are getting all possible matches). Hence I think
that removing the cross products is probably the most desirable behaviour.
And also, it is possible to do what is required by Yuesong via a work around
with "eval" adding more constraints - its not optimal (it is a work around)
but in simple cases it may be fine.
As always if we get enough pressure, we can make this configurable
behaviour. But from Drools 2.x experience, we get a LOT of confusion over
the cross product stuff, and this saves a lot of hassle.


On 4/18/06, Edson Tirelli <[EMAIL PROTECTED]> wrote:

  Actually, there is one thing that changed and might affect this use
case:
it is the filter on identity cross product.

  Before RC2, if you had a Rule with 2 columns of the same type, like the
rule you wrote bellow, every object in the working memory of that type,
would try to match against itself. So, for instance, if you had asserted
two
messages (m1 and m2) in the working memory for this rule, the activations
would be:

[m1, m1]
[m1, m2]
[m2, m1]
[m2, m2]

  In RC2, we added an identity removal constraint to not allow identity
activations like [m1, m1] and [m2, m2].

  So, what is probably happening to you is that you are asserting a
single
message object in the working memory. Before RC2, it would create an
activation for [m1, m1] and now it does not creates anymore.
  As Mark said, this is probably and error when writing the rule, as the
rule should have only one column, not two. A better way to write this rule
would be:

  rule "Hello World"
    when
      m : Message( status == Message.HELLO, message == "Hello World" )
    then
      System.out.println( "fired" );
  end

   This way, each single message object asserted into working memory that
matches the constraints, will cause an activation.

  []s
  Edson


----- Original Message -----
From: "Mark Proctor" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, April 17, 2006 4:26 PM
Subject: Re: [drools-user] RC2



 package com.sample
 import com.sample.DroolsTest.Message;
 rule "Hello World"
   when
     m : Message( status == Message.HELLO )
     Message( message == "Hello World" )
   then
     System.out.println( "fired" );
 end

That's filtering on two columns, its like doing this in SQL:
select * from Message, Message
Not what most people want. This hasn't changed in any of the releases
in Drools 3.0

Mark

Yuesong Wang wrote:

Thanks for the great job on RC2. Solved a lot of my
problem :)

The following rule, however, does not work in RC2
anymore...

 package com.sample
 import com.sample.DroolsTest.Message;
 rule "Hello World"
   when
     m : Message( status == Message.HELLO )
     Message( message == "Hello World" )
   then
     System.out.println( "fired" );
 end

So the field constraints have to be in the sample
column? like

 m:Message(status==0, message=="Hello World")

That is probably no good, especially for someone who
wants to use DSL and map individul conditions to
separate sentences.

Yuesong

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com







--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.2/314 - Release Date: 16/4/2006

Reply via email to