On 11 August 2011 13:06, wendy <w.mungovan(a)yahoo.com> wrote:
I'm still not sure I can make my rule work like that. Sorry, my
real
problem
is a little more complicated then I initially described.
We are trying to detect if some set of conditions stay within a set of
ranges over a period of time. So still using the example below. The color
is really the key for the shape and the size can change over time. For
example, we would want to know if any shape's size was larger than 5 for 20
min.
I see how you are making a map that would have a list of all the shapes of
the same color. So $map['BLUE'] would return all shapes
and $shape: Shapes( $color: color, size > 5 ) could change to $shape:
Shapes( $color: color, size > 5 ) over window:time(20m) to only get Shape
sizes for the last 20 min.
Yes.
now this would be a map where the key would be the color and the value
would
be the min size over a 20 min window.
//untested
$map: Map()
from accumulate ( $shape: Shapes( $color: color) over window:time(20m),
init( Map m = new HashMap(); ),
action( Number min = m.get( $color );
if( min == null ) m.put($shape.size);
else if (min > $shape.size) m.put($shape.size);),
result( m ) )
and then I would need to iterate through the map and find all the ones
whose
min size > 5?
I don't see why you would need a map with mininum size per color. If you
restrict
accumulate ( $shape: Shapes( $color: color, size > 5 )
you won't get any list in the map where there is a shape with size <= 5. By
investigating the map I proposed you can still find the minimum sizes > 5 -
these are the minimum sizes in each list.
-W