if there is enough demand for it, we may be able to make it some working
memory wide configuration option - certainly. Submit a JIRA request if you
like, may come in handy (certainly will for you). But not as the default, as
not everyone implements equals() correctly !
On 4/11/06, Juergen <[EMAIL PROTECTED]> wrote:
>
> Quick'n dirty I could make drools 3 do it the way I would prefer - in
> the context of my current problem and datastructures involved - by
> modifying:
>
> org.drools.reteoo.WorkingMemoryImpl, line 95f (rev. 3509):
> replace:
> /** Object-to-handle mapping. */
> private Map identityMap
> = new IdentityMap();
>
> by:
> /** Object-to-handle mapping. */
> private Map identityMap
> = new java.util.HashMap();
>
> (not considering side effects, identityMap type cast problems, ...)
>
> Then org.drools.reteoo.WorkingMemoryImpl, assertObject (line 422, rev.
> 3509):
> FactHandleImpl handle = (FactHandleImpl) this.identityMap.get( object );
>
> would return first "A"s handle when the second "A" is asserted, refering
> to the example in my former posting.
>
> I expected some way to customize the behaviour of the working memory,
> basically by choosing between either of the Maps.
>
> But as mentioned, such behaviour might not be desirable by others (they
> probably want "A" being asserted twice and handled as two different
> objects) and even if not customizable in drools itself, it can most
> likely be done by wrapping assertObject and managing your own
> object-to-handle map plus taking care not to use assert directly in RHS.
>
> I first wrongly thought logical assertions had something to do with
> this, but I guess that relates more to the 'logical' conditional element
> in jess and logical dependencies among facts.
>
> Michael Neale wrote:
> > what is your expectations on how it should work? (everyone has different
> > ideas it seems !)
> >
> > On 4/10/06, Juergen <[EMAIL PROTECTED]> wrote:
> >
> >>I mean
> >>
> >>workingMemory.assertObject(new String("A"));
> >>workingMemory.assertObject(new String("A"));
> >>
> >>would currently assert both strings into working memory, whereas if it
> >>would check not for identityHashCode but with equals, the second assert
> >>would have no effect.
> >>
> >>When during experimentation with rule engines I switched from jess
> >>(where it is done with equals I think) to drools 2 I first experienced
> >>problems due to this differences (also did not find much in both engines
> >>docu), leading to my question if I could customize drools behaviour.
> >>
> >>As one can always write a wrapper for drools assertObject to make such
> >>checks, and lots of other users probably dont need, my request is not
> >>important.
> >>
> >>Juergen
> >>
> >>
> >>Michael Neale wrote:
> >>
> >>>so you mean
> >>>p1 : Person()
> >>>p2 : Person()
> >>>eval ( p1.equals(p2) )
> >>>
> >>>(but presumably a shorthand form?)
> >>>
> >>>
> >>>
> >>>On 4/8/06, Mark Proctor <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> >>>>We hadn't planned it, not promising anything - but I'll see how
> things
> >>>>pan out, may be we will get time.
> >>>>
> >>>>Mark
> >>>>Juergen wrote:
> >>>>
> >>>>
> >>>>>ad. Can object equality for assertion be customized?
> >>>>>Drools 3 still seems to use IdentityMap with System.identityHashCode
> ().
> >>>>>Is it planned to be customizeable e.g. with equals() in 3.0?
> >>>>>
> >>>>>Michael Neale wrote:
> >>>>>
> >>>>>
> >>>>>>Short answer, not easily with Drools 2. But yes, with Drools 3.
> >>>>>>
> >>>>>>On 3/22/06, Juergen <[EMAIL PROTECTED]> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>I recently looked into drools after experimenting with JESS and got
> a
> >>>>>>>few questions I could not look up in the drools documentation:
> >>>>>>>
> >>>>>>>- Exists a condition to test for non-existence of a matching
> >>>>>>>object/fact?
> >>>>>>>-- If yes, how to use it for own domain specific language
> conditions
> >>>>>>>
> >>>>>>>- How is sharing of conditions/nodes between productions
> implemented
> >>>>
> >>>>in
> >>>>
> >>>>
> >>>>>>>drools, one of the main benefits of the rete algorithm?
> >>>>>>>-- How is the equality of conditions defined for java smf? via
> >>
> >>textual
> >>
> >>>>>>>equality of the condition's java code?
> >>>>>>>-- How can equality of conditions for sharing be defined for domain
> >>>>>>>specific language conditions?
> >>>>>>>e.g. Conway's game of life (slightly modified dsl)
> >>>>>>><rule name="kill the overcrowded">
> >>>>>>> <conway:cellIsAlive cellName="cell"/>
> >>>>>>> <conway:cellIsOverCrowded cellName="cell"/>
> >>>>>>> <conway:killCell cellName="cell"/>
> >>>>>>></rule>
> >>>>>>><rule name="kill the lonely">
> >>>>>>> <conway:cellIsAlive cellName="cell"/>
> >>>>>>> <conway:cellIsLonely cellName="cell"/>
> >>>>>>> <conway:killCell cellName="cell"/>
> >>>>>>></rule>
> >>>>>>>
> >>>>>>>The conway:cellIsAlive condition could be shared between these two
> >>>>>>>productions. Would it?
> >>>>>>>
> >>>>>>>- When will the properties map be supported in drools
> implementation
> >>>>
> >>>>of
> >>>>
> >>>>
> >>>>>>>JSR 94 javax.rules API?
> >>>>>>>-- e.g. to be able to set conflict resolver of a rule base and
> other
> >>>>>>>settings that can be set via drools native API
> >>>>>>>
> >>>>>>>- Can object equality for assertion be customized?
> >>>>>>>-- Currently, org.drools.util.IdentityMap
> >>>>>>>(org.drools.reteoo.WorkingMemoryImpl) makes use of
> >>>>>>>System.identityHashCode(). There seems to be no way to customize
> >>
> >>that,
> >>
> >>>>>>>e.g. make drools use equals() instead, neither via native nor JSR
> 94
> >>>>>>>API.
> >>>>>>>
> >>>>>>>My apologies if some questions have already been answered in other
> >>>>>>>postings, I made no thorough search in this newsgroup yet.
> >>>>>>>
> >>>>>>>Thanks a lot, Juergen
>
>