Last (query directive)
From WandoraWiki
Description
Returns the last or the last N rows of specified directive. May return less than specified number of rows if the inner directive does not return that many rows.
Constructor
Last(Directive directive) - Returns the last row of directive.
Last(int count, Directive directive) - Returns the last count rows of directive
Examples
Following example gets the sum of number of instances of instances in the input topic. The Count selects the number of instances of each instance topic. The Eval calculates the sum. It always returns sum up to the current row. Then the Last directive selects only the last row which contains the final sum. Note that it is easier to do the same thing using Sum directive.
importPackage(org.wandora.query2); new Last( new Eval( "param.sum+=parseInt(val);"+ "param.sum;" ,{sum:0}).as("#sum") .from( new Count( new Instances() ).from(new Instances()) ) )