Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
quickstart [2019/05/09 19:05]
admin
quickstart [2019/10/31 19:30] (current)
a.leofreddi
Line 1: Line 1:
 ====== Quickstart ====== ====== Quickstart ======
  
-Use the TimEL facade ​to compile and run a program:+To use TimEL you need to import the following dependecy:
  
-<code java+//Maven// 
-// Assemble the evaluation interval as [now, now + 1 second) +  ​<dependency
-Instant now = Instant.now(); +      <​groupId>​net.vleo.timel<​/groupId>​ 
-Interval interval = Interval.of(now, now.plus(1, ChronoUnit.SECONDS));​+      <​artifactId>​timel-core<​/artifactId>​ 
 +      <​version>​0.9.3</​version>​ 
 +  </​dependency>​
  
-// Compile the expression 1 + 1. +//Gradle// 
-// As we expect an Integer here, we explicitly request an IntegerType +  ​implementation 'net.vleo.timel:​timel-core:​0.9.3'
-// 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 +Now you're ready to go! Let's count how many days passed since (unixepoch:
-int v = itor.next().getValue()+
-</​code>​+
  
-That's it!+<code java> 
 +// Compile the expression 
 +Expression<?>​ expression = TimEL 
 +        .parse("​scale(scale(uniform(1.0),​ every(1, \"​DAY_OF_YEAR\",​ \"​UTC\"​)))"​) 
 +        .compile();
  
-\\+// Evaluate and print the number of days from epoch 
 +Interval interval = Interval.of(Instant.ofEpochMilli(0),​ Instant.now());​ 
 +System.out.println(TimEL.evaluate(expression,​ interval).next());​ 
 +</​code>​ 
 + 
 +===== Adding a variable =====
  
 Now let's try something a bit more complex, where 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 case we are going to use a TreeMapVariable,​ which is a Variable backed by a regular in memory TreeMap: Now let's try something a bit more complex, where 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 case we are going to use a TreeMapVariable,​ which is a Variable backed by a regular in memory TreeMap:
  • quickstart.1557428717.txt.gz
  • Last modified: 2019/05/09 19:05
  • by admin