Andreas Andreakis wrote:
A possible solution to prevent Facts dublication would be to save Facts in a HashSet. Drawback: you need to specify hashcodes
This will probably work, but is no longer declarative, rule-based programming. If you do not care about this semi-philosophical argument, stop reading here...
The correct way to solve the problem in my opinion is to add an extra rule that removes duplicates (in Drools you should probably give it a higher salience...). So you simply add away, and declare that duplicates have to be removed. The responsibility of using a hash-set (or any other efficient data-structure) to efficiently look up duplicate facts should lie with the rule-engine, not with the user.
As always, I do not know the details of the internals of Drools, so your solution might in fact be faster, but it remains a hack in my opinion...

Greets,

Reply via email to