Constraint efficiency: (was: "New in 5.2.0" - What works, what doesn't?)
by Wolfgang Laun
Edson,
On 6 May 2011 01:14, Edson Tirelli <ed.tirelli(a)gmail.com> wrote:
>
> Wolfgang,
>
> These are remaining bugs that must be fixed before final. Goal is to
> support free form expressions as long as they return a boolean value (for
> traditional constraints), or any value (for positional). Period.
>
(Well, as it's past 5.2.0M2...)
Given that any expression is valid, will there still be a distinction w.r.t.
efficiency, as there was with traditional constraints as opposed to eval()?
If yes, how can I tell whether a constraint expression is "good" or "bad"?
One might assume that all legacy forms will be handled as efficiently as
now, but it's possible that not only
field == ($var + 1)
but also
field == $var + 1
is efficient. Or, similarly,
field == $var
and (now) also
$var == field
But certainly not
field - 1 == $var
Or, at least, not until some later version ;-)
I repeat this quote (from 5.2.0 Drools Introduction and General User Guide) and
my question, what does it mean? Where is this "documented"? Is this somehow
related to the efficiency issue?
<quote>
As previously we had to document the restricted limitations of a field
constraint on the LHS compared to expressions used inside of an 'eval' or
used on the RHS.
</quote>
Wolfgang
>
> Edson
>
> 2011/5/5 Wolfgang Laun <wolfgang.laun(a)gmail.com>
>
>> In the 5.2.0 Drools Introduction and General User Guide, there's section
>> 2.1.3.1, Free Form expressions in Constraints (New Parser). It contains
>> several examples:
>> #1 Person( age * 2 > $anotherPersonsAge + 2 )
>> #2 Person( addresses["home"].streetName.startsWith( "High Park" ) )
>> #3 Person( isAdult() )
>>
>> #1 does not compile: Unable to build constraint as 'age * 2' is invalid :
>> [Rule name='exa1']
>>
>> #2 works - although I'd very much prefer not to be swamped with MVEL
>> extensions unless I ask for it.
>>
>> #3 does not compile: Unable to Analyse Expression isAdult():
>> [Error: no such identifier: isAdult]
>> [Near : {... isAdult() ....}]
>>
>> Neither rule name nor line number is provided.
>>
>> Would it please be possible to have a precise statement what one *can*write as a constraint?
>>
>>
>> <quote>
>> As previously we had to document the restricted limitations of a field
>> constraint on the LHS compared to expressions used inside of an 'eval' or
>> used on the RHS.
>> </quote>
>>
>> I'm sorry, but I do not understand the meaning of this sentence. What does
>> it mean, please?
>>
>> Cheers
>> Wolfgang
>>
>>
>
13 years, 7 months
Guvnor is broken on master?
by Jervis Liu
Hi, I just tried the Guvnor on master. Start from fresh, after importing
examples I got following errors. This is in Eclipse hosted mode. Any one
knows what happens to master?
500 The call failed on the server; see server log for details
Unable to rebuild snapshot [TEST
Asset: Pricing loans.gdst Message: Unable to return Declaration for
identifier 'Asset' UUID: e25d9eb0-48cf-4373-806d-df9b8cf78717 Asset:
Pricing loans.gdst Message: Unable to return Declaration for identifier
'Job' UUID: e25d9eb0-48cf-4373-806d-df9b8cf78717 Asset: Pricing
loans.gdst Message: Unable to return Declaration for identifier 'Job'
UUID: e25d9eb0-48cf-4373-806d-df9b8cf78717 ]
Thanks,
Jervis
13 years, 7 months
Implicit package imports
by Michael Anstis
Hi,
I'm fixing a bug in all of Guvnors' guided editors:
https://issues.jboss.org/browse/GUVNOR-1362
The existing problem is if a model Date field is set in one of the guided
editors RHS we need to convert the String into a Date for use in the set
Method (currently we attempt to pass the String which fails).
I have a working solution however it requires the user to explicitly add a
package import for "java.text.SimpleDateFormat" that handles the parsing.
This can be accomplished through the UI.
I have two options to remove the need for the user to do anything:-
(1) Pre-process all rules to be included in the package, check if one uses
Date in the RHS and if so add an import into the header. I'd need to
pre-process all rules as the package DRL String is built linearly and by the
time the package compiler gets to a rule that uses a Date in the RHS the
header, including imports, has already been built.
(2) Add (another) implicit import into *all* packages. I assume we already
do something like this for the boxed primitives and some others (List?
Collection? Map? etc).
Before I venture into option (1) can any (core) developer advise (1) where
can I add an additional implicit import (I assume the compiler somewhere),
(2) is this simpler solution acceptable to the (core) developers?
Thanks,
Mike
13 years, 7 months
"New in 5.2.0" - What works, what doesn't?
by Wolfgang Laun
In the 5.2.0 Drools Introduction and General User Guide, there's section
2.1.3.1, Free Form expressions in Constraints (New Parser). It contains
several examples:
#1 Person( age * 2 > $anotherPersonsAge + 2 )
#2 Person( addresses["home"].streetName.startsWith( "High Park" ) )
#3 Person( isAdult() )
#1 does not compile: Unable to build constraint as 'age * 2' is invalid :
[Rule name='exa1']
#2 works - although I'd very much prefer not to be swamped with MVEL
extensions unless I ask for it.
#3 does not compile: Unable to Analyse Expression isAdult():
[Error: no such identifier: isAdult]
[Near : {... isAdult() ....}]
Neither rule name nor line number is provided.
Would it please be possible to have a precise statement what one *can* write
as a constraint?
<quote>
This was also important for us to start to move towards a single consistent
grammer for both the "when" left hand side and "then" right hand side.
</quote>
It seems that example #2 increases the grammar gap because the constraint
expression can certainly not used on the RHS.
<quote>
As previously we had to document the restricted limitations of a field
constraint on the LHS compared to expressions used inside of an 'eval' or
used on the RHS.
</quote>
I'm sorry, but I do not understand the meaning of this sentence. What does
it mean, please?
Cheers
Wolfgang
13 years, 7 months
Dependency management?
by Wolfgang Laun
This is what I find below my ~/.m2:
-rw-r--r-- 1 x x 711693 2011-05-02 14:12
./org/mvel/mvel2/2.1-SNAPSHOT/mvel2-2.1-20110501.033205-24.jar
-rw-r--r-- 1 x x 711693 2011-05-02 14:12
./org/mvel/mvel2/2.1-SNAPSHOT/mvel2-2.1-SNAPSHOT.jar
At that time I didn't build anything except droolsjbpm/drools, so both must
have been downloaded by the same build.
-W
13 years, 7 months
@metadata: status; compatibility issues
by Wolfgang Laun
The current parser handles metadata annotations
'@' *Identifier* '(' *Text* ')'
so that the annotations for one entity (e.g., a rule) are available as a
Map<String,Object>, where the key is given by the *Identifier *and the value
of the entry is available according to
*if* *Text* can be *completely* parsed as *Identifier* '='
*Expression*(where
*Expression* is whatever the DRL parser accepts as an expression, i.e., an
extended subset of Java expressions)
*then*
the value is a Map<String,String>
*else
the *value is a String, with trimmed leading and trailing white space,
but preserving all embedded white space
Changes compared to 5.1.1:
- no Map was ever returned in 5.1.1,
- @m( "foo" ) in 5.1.1. returned "foo", but 5.2.0 returns "\"foo\"".
- @m( "foo", "bar" ) in 5.1.1. returned "foo\", \"bar", but 5.2.0 returns
"\"foo\", \"bar\""
- comments between "@...(" and ")" are now handled consistently but were
not in 5.1.1
Possibly considered a problem for 5.2.0 or later:
- No check is made for duplicate "outer" map keys; entries are overwritten.
- Repeated "inner" map keys produce concatenated entries, e.g. @m( k = 1, k
= "a" ) returns "1a" as the value for key "k".
- Returning (arbitrary) expressions, unchanged, as String now may cause
incompatibilitie with more sophisticated processing (if this ever should be
considered).
-W
13 years, 7 months
configuring timer service (and persistence)
by Jordi Alvarez
Hello, I am involved in a project in which we are using Drools Flow 5.1.1.
as the underlying BPM.
We have drools integration with Spring. We are using JPA+Spring+Drools
integration, and have setup the knowledge base and stateful session as
indicated in the drools spring integration documentation. Our BPM has
external clients that call adaptor methods for Drools. That is, drools is
never used in a direct way from an external client. We use this strategy in
order to provide some additional behaviour and also in order to provide
transactional behaviour as it is usually made with Spring.
We needed to partially apply the patch reported at the end of:
http://drools.46999.n3.nabble.com/5-1-0-CR1-Drools-Spring-Configuration-C...
*
"3.* Interesting thing is that I have to recreate "Environment" now every
time before reloading the Session, otherwise the entityManager is closed,
and it does not respond to a simple Spring AOP TM wrapping... But that is
another issue.. "
We still have some persistence problems when using drools Timers. The
problems arise when drools creates the transaction itself. We do have some
listeners which persist some information in our own tables. For this reason
and also some others (as reported in
http://drools.46999.n3.nabble.com/Drools-5-1-Flow-in-a-quot-Clustered-quo...),
we would like to configure the timer service used
internally by Drools.
Looking at drools source code, it seems that it should be possible, since a
defult implementation is provided by drools (JDKTimerService and
JpaJDKTimerService if persistence is used). For example, class *
KnowledgeStoreServiceImpl* seems to define a set of default services (which
could pressumably be overriden someway). Nevertheless, after looking to that
for a while we have found no specific documentation and no clear way to do
that for our Spring integration.
Is there a way to change the TimerService implementation provided by Drools?
Any help is appreciated.
Thanks very much in advance!
Jordi Alvarez
13 years, 8 months
CR1 release postponed to Monday
by Geoffrey De Smet
Hi guys,
Mark has asked me to postpone the CR1 release to tomorrow (Monday),
so some important performance regressions can be fixed (including the a
new mvel version).
IRC is the best place to get the most up to date info.
I'll mail here once CR1 has been released (I forgot that for M2).
--
With kind regards,
Geoffrey De Smet
13 years, 8 months