Analysis: variable constraint with index causes SIOOBEx
by Wolfgang Laun
5.1 and trunk permits you to write e.g.
Foo( $array: array )
Bar( this == $array[0] )
but this crashes druing compilation with
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1949)
at
org.drools.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:928)
It's OK by this syntax:
accessor_element ; ID square_chunk* ;
Processing in DescriptorFactory handles []:
createAccessorPath(List<BaseDescr> aeList) {
...
if (name.indexOf('.') > -1 || name.indexOf('[') > -1) {
evaluator = new QualifiedIdentifierRestrictionDescr();
Then in PatternBuilder, we end up in this variant of the overloaded method
buildRestriction:
private Restriction buildRestriction(final RuleBuildContext context,
final InternalReadAccessor
extractor,
final FieldConstraintDescr
fieldConstraintDescr,
final
QualifiedIdentifierRestrictionDescr qiRestrictionDescr)
and this is where it happens, lastDot being == -1.
{ final int lastDot = qiRestrictionDescr.getText().lastIndexOf( '.'
);
final String className = qiRestrictionDescr.getText().substring( 0,
lastDot );
If the syntax isn't too permissive, then this method would have to handle
x[y] in
addition to x.y, etc.
-W
14 years, 1 month
Lazily Enabled Truth Maintenace (Project Propsoal)
by Mark Proctor
Here is another project proposal, this time simpler. I think this one
has Wolfgang's name on it ;)
http://blog.athico.com/2010/09/lazily-enabled-truth-maintenace.html
Three weeks ago I posted the project idea for "Left and Right Unlinking"
<http://blog.athico.com/2010/08/left-and-right-unlinking-community.html>. So
far there are no takers, so if you are interested let me know :)
In the meantime I tried to think of a simpler enhancement that we would
like to see done.
At the moment Drools has a user setting "MaintainTMSOption" which can be
true or false. It's a small optimisation that when turned off avoids
using the equality hashmap that is maintained for all inserted objects.
It would be a much better idea to remove this configuration setting,
thus simplifying things for end users and have TMS lazily enabled on demand.
For each object type there is an "ObjectTypeConf" configuration object
that is retrieved every time a working memory action, such as insert, is
executed. The enabledTMS boolean should be moved there, so there is one
per object type, by default it is false.
When a working memory action occurs, like insert, it retrieved the
ObjectTypeConf and checks the maintainTms boolean there, instead of the
current engine scoped configuration. When a logical insertion occurs and
the ObjectTypeConf is retrieved if maintainTms is false it sets the
value to true and then iterates the associated ObjectTypeNode memory
lazily adding all the objects to the TMS equality map. From then on for
that ObjectType all inserted objects are added to that equality map.
With this you now have the advantage of TMS being laziy enabled, so the
minor hashmap operation is no longer used and likewise a small memory
saving from not populating the map. There is a further advantage that
this is now fine grained and when enabled only impacts for that specific
object type.
A further enhancement could use a int counter, instead of a boolean.
Each logical insertion for that object type increases the counter, each
retraction decreases the counter; even if automatically retracted if the
truth is broken for that logical assertion. When the counter reaches
zero, TMS for that OTN can be disabled. We do not however remove the
objects from the equality map, as this would cause "churn" if TMS is
continuously enabled and disabled. Instead when TMS is disabled record
the current fact counter id. Then if TMS is disabled on a retraction but
there is a counter id, we can check that counter id to see if the fact
is prior to TMS being disabled and thus would need to be retracted from
the equality map.
14 years, 1 month
timer and repeat limit
by Wolfgang Laun
This works *almost* as expected:
timer(int: 5s 0m2s repeat-limit=10 )
the exception being that the rule with this attribute fires nine times.
As might be expected, this one fies once:
timer(int: 5s 0m2s repeat-limit=2)
But, surprise, surprise, these two both fires once, too:
timer(int: 5s 0m2s repeat-limit=1)
timer(int: 5s 0m2s repeat-limit=0)
I think this is due to the code in org.drools.time.impl.IntervalTrigger
where the increment happens in getTimeAfter(), *before* the test
repeatCount >= repeatLimit; see below.
public Date nextFireTime() {
Date date = this.nextFireTime;
// FIXME: this is not safe for serialization
this.nextFireTime = getTimeAfter();
updateToNextIncludeDate();
if ( this.endTime != null && this.nextFireTime.after( this.endTime )
) {
this.nextFireTime = null;
} else if ( repeatLimit != -1 && repeatCount >= repeatLimit ) {
this.nextFireTime = null;
}
return date;
}
private Date getTimeAfter() {
this.repeatCount++;
...
}
14 years, 1 month
University of Texas Austin
by Mark Proctor
I'm looking for locations for the next USA based conference for
febuary (end of febuary).
http://blog.athico.com/2010/09/drools-boot-camps-2011-usa-and-emea.html
I figured most people want somewhere warm and Austin is centrally
located. I don't know about pricing but Austin University seems to have
nice conference facilities:
http://www.meetattexas.com/
If we do this around austin university it would be good if we could
double up organisation with the local logic based programming groups,
maybe a professor at Austin University wants to be actively involved? If
anyone has any ideas, please let me know :)
Mark
14 years, 1 month
drools-guvnor and drools-factcontstraints: commit before Friday
by Geoffrey De Smet
Next Friday (starting from 8:00 CET) I 'll:
- move the drools-factcontstraints module into the drools-guvnor module
- move the drools-guvnor-gwtclient part out of the drools-guvnor module
into a separate module
So please commit anything in those directories before Friday 8:00 CET. I
'll give a sign on IRC and this dev list once it's done.
More info about what will be done and feed-back welcome in the jira issue:
https://jira.jboss.org/browse/JBRULES-2707
This change will allow us to use the maven-gwt-plugin (so remove the ANT
script in guvnor) and remove the generated javascripts files from
subversion (no more tree conflicts on drools-guvnor/src/main/webapp/org...)
--
With kind regards,
Geoffrey De Smet
14 years, 1 month