Summary

In this chapter we've learned about the Rete algorithm and mainly about how it uses the Rete network to represent our rules. We've explored various types of nodes that are within the Rete network: Alpha nodes that can apply a constraint on a single fact and Beta nodes that can apply a constraint on multiple facts. We've seen various rules and their corresponding Rete networks.

We've learned about various optimizations used within Drools. One of them was node sharing. By sharing the nodes we can greatly reduce the amount of work a computer must do in order to execute our rules. After all, there is no point in evaluating the same conditions multiple times.

We've seen that the order of the conditions within a rule and even the order of the constraints within a condition is crucial when it comes to node sharing. Drools currently doesn't implement any node-rearranging strategy to achieve the best node sharing. When designing your rules, try to put the most restrictive conditions and constraints first. Try to keep the same order for them. By doing this the advantage that you can get from node sharing will be maximized.

The Rete node indexing section described how the Alpha and Beta node indexing works. Keep in mind that it applies only to constraints with an equal operator. However, there are plans to extend this support also for relational operators (greater than, less than, and so on).

This chapter showed the power of declarative programming. We just declare what should be done and the engine can then decide how to do it, as effectively as possible depending on the runtime conditions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.218.147