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
Last revision Both sides next revision
quickstart [2019/05/17 20:13]
a.leofreddi
quickstart [2019/08/10 16:17]
a.leofreddi
Line 7: Line 7:
       <​groupId>​net.vleo.timel</​groupId>​       <​groupId>​net.vleo.timel</​groupId>​
       <​artifactId>​timel-core</​artifactId>​       <​artifactId>​timel-core</​artifactId>​
-      <​version>​0.9.1</​version>​+      <​version>​0.9.2</​version>​
   </​dependency>​   </​dependency>​
  
 //Gradle// //Gradle//
-  implementation '​net.vleo.timel:​timel-core:​0.9.1'+  implementation '​net.vleo.timel:​timel-core:​0.9.2'
  
 \\ \\
  
-When the dependency is in place, use the TimEL facade class to compile and evaluate expressions:+Now you're ready to go! Let's count how many days passed since (unix) epoch:
  
 <code java> <code java>
-// Assemble ​the evaluation interval as [now, now + 1 second) +// Compile ​the expression 
-Instant now Instant.now();​ +Expression<?>​ expression ​TimEL 
-Interval interval = Interval.of(now, now.plus(1, ChronoUnit.SECONDS));+        .parse("​scale(scale(uniform(1.0), every(1, \"​DAY_OF_YEAR\",​ \"​UTC\"​)))") 
 +        .compile();
  
-// Compile ​the expression 1 + 1. +// Evaluate and print the number ​of days from epoch 
-// As we expect an Integer here, we explicitly request an IntegerType +Interval interval ​Interval.of(Instant.ofEpochMilli(0), Instant.now()); 
-// for the sake of type safety, but we can compile generic code as well. +System.out.println(TimEL.evaluate(expression,​ interval).next());​
-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 = itor.next().getValue();+
 </​code>​ </​code>​
  
-That's it! +===== 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.txt
  • Last modified: 2019/10/31 19:30
  • by a.leofreddi