E&S CVS Commit: PEAK-Rules - Added a generic version of the
Chambers & Chen algorithm, with tests.
pje at eby-sarna.com
pje at eby-sarna.com
Mon Jul 3 19:25:27 EDT 2006
Author: pje
Date: Mon Jul 3 19:25:26 2006
New Revision: 2201
URL: http://svn.eby-sarna.com?rev=2201&view=rev
Log:
Added a generic version of the Chambers & Chen algorithm, with tests.
Unlike the RuleDispatch implementation, this one doesn't care how
indexes or criteria or expressions actually work, and it has a much
simpler way of dealing with inter-expression constraints. The tree
building algorithm can also be easily revised to produce any kind of
dispatch tree, either eagerly or lazily, and whether in the form of
bytecode, source code, or an actual object tree. (RuleDispatch only
supports lazy creation of an object tree; it can't do anything else.)
Of course, this core algorithm is useless without some concrete types to
represent expressions, criteria, and indexes -- not to mention some
actual tree-generating code to go along with it. But this algorithm for
generating decision trees will be at the heart of the main rule engine
for predicate dispatching.
At this point, about 2/3rds of the code in the ``dispatch.functions``
module of RuleDispatch has been mapped to ``peak.rules.core`` and
``peak.rules.indexing``. About 1/6th of ``dispatch.strategy`` has also
been translated. ``dispatch.ast_builder`` will not require any code
changes, but it will probably get some new tests. The remaining modules,
however, (including ``strategy``, ``combiners``, and ``predicates``)
will be changed substantially.
The good news is that these changes should mostly be simplifications,
since most of the ``predicates`` module will become calls to
BytecodeAssembler APIs. But the remaining parts of ``strategy`` and
``functions`` will likely become more complex, because they will need
to know how to generate decision-making bytecode, deal with rule
removals, and a few other odds and ends. Some additional code will also
be needed to ensure that the core implementation is sufficiently
extensible to allow new features (like predicate abstractions and
classifiers) to be implemented.
Added:
PEAK-Rules/Indexing.txt (with props)
PEAK-Rules/peak/rules/indexing.py (with props)
Modified:
PEAK-Rules/test_rules.py
More information about the source-changes
mailing list