use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class GeoEnrichmentFunctionsTest method run.
public Object run(String rule, Map<String, Object> variables) throws Exception {
StellarProcessor processor = new StellarProcessor();
Assert.assertTrue(rule + " not valid.", processor.validate(rule, context));
return processor.parse(rule, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class SimpleHBaseEnrichmentFunctionsTest method run.
public Object run(String rule, Map<String, Object> variables) throws Exception {
StellarProcessor processor = new StellarProcessor();
Assert.assertTrue(rule + " not valid.", processor.validate(rule, context));
return processor.parse(rule, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class DateFunctionsTest method run.
/**
* Runs a Stellar expression.
* @param expr The expression to run.
*/
private Object run(String expr) {
StellarProcessor processor = new StellarProcessor();
assertTrue(processor.validate(expr));
return processor.parse(expr, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), StellarFunctions.FUNCTION_RESOLVER(), Context.EMPTY_CONTEXT());
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class MathFunctionsTest method run.
public static Object run(String rule, Map<String, Object> variables) {
Context context = Context.EMPTY_CONTEXT();
StellarProcessor processor = new StellarProcessor();
Assert.assertTrue(rule + " not valid.", processor.validate(rule, context));
return processor.parse(rule, new DefaultVariableResolver(v -> variables.get(v), v -> variables.containsKey(v)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class Microbenchmark method run.
private static void run(int numTimes, StellarStatement statement, Consumer<Long> func) {
StellarProcessor processor = new StellarProcessor();
for (int i = 0; i < numTimes; ++i) {
long start = System.nanoTime();
processor.parse(statement.expression, statement.variableResolver, statement.functionResolver, statement.context);
func.accept((System.nanoTime() - start) / 1000);
}
}
Aggregations