This is an old revision of the document!


Use the TimEL facade to compile and run a program:

// Assemble the evaluation interval as [now, now + 1 second)
Instant now =;
Interval interval = Interval.of(now,, ChronoUnit.SECONDS));
// Compile the expression 1 + 1.
// As we expect an Integer here, we explicitly request an IntegerType
// for the sake of type safety, but we can compile generic code as well.
Expression<Integer> expression = TimEL
        .parse("1 + 1")
        .compile(new IntegerType());
// Iterate through the results
TimeIterator<Integer> itor = TimEL
        .evaluate(expression, interval);
// Since 1+1 is constant we'll have a single sample for the whole interval
int v =;

That's it!

Now let's try something a bit more complex, so we provide an input time-serie variable. As TimEL is a streaming api, it will pull values out of the variable when it needs them. In this simple case we are going to use a TreeMapVariable, which is a Variable backed by a regular in memory TreeMap:

// Create a new variable backed by a TreeMap
TreeMapVariable<Integer> variable = new TreeMapVariable<>();
TreeMap<Interval, Integer> values = variable.getTreeMap();
// Add some values to the variable
Instant now =;
for(int[] i : new int[][] {{0, 1, 1}, {1, 2, 2} /* Gap */, {2, 3, 4}})
  [0], ChronoUnit.MINUTES),
  [1], ChronoUnit.MINUTES)
    ), i[2]);
// Compile "a * a"
Expression expression = TimEL
        .parse("a * a")
        .withVariable("a", new IntegerType(), variable) // Declare 'a' as a int
// Evaluate the expression in the interval [now, now + 5 minutes)
TimeIterator<Double> itor = TimEL
        .evaluate(expression, Interval.of(now,, ChronoUnit.MINUTES)));
// Pull the results, effectively evaluating the expression.
// This will print 3 lines, one for each interval, with the value 1, 4 and 16.
    System.out.println("\t" +;

That's it!

  • quickstart.1557428168.txt.gz
  • Last modified: 2019/05/09 18:56
  • by admin