Search in sources :

Example 1 with StormContext

use of org.apache.calcite.interpreter.StormContext in project storm by apache.

the class EvaluationFilter method isKeep.

@Override
public boolean isKeep(TridentTuple tuple) {
    Context calciteContext = new StormContext(dataContext);
    calciteContext.values = tuple.getValues().toArray();
    filterInstance.execute(calciteContext, outputValues);
    return (outputValues[0] != null && (boolean) outputValues[0]);
}
Also used : Context(org.apache.calcite.interpreter.Context) DataContext(org.apache.calcite.DataContext) TridentOperationContext(org.apache.storm.trident.operation.TridentOperationContext) StormContext(org.apache.calcite.interpreter.StormContext) StormContext(org.apache.calcite.interpreter.StormContext)

Example 2 with StormContext

use of org.apache.calcite.interpreter.StormContext in project storm by apache.

the class EvaluationFunction method execute.

@Override
public Values execute(TridentTuple input) {
    Context calciteContext = new StormContext(dataContext);
    calciteContext.values = input.getValues().toArray();
    projectionInstance.execute(calciteContext, outputValues);
    return new Values(outputValues);
}
Also used : Context(org.apache.calcite.interpreter.Context) DataContext(org.apache.calcite.DataContext) TridentOperationContext(org.apache.storm.trident.operation.TridentOperationContext) StormContext(org.apache.calcite.interpreter.StormContext) Values(org.apache.storm.tuple.Values) StormContext(org.apache.calcite.interpreter.StormContext)

Example 3 with StormContext

use of org.apache.calcite.interpreter.StormContext in project storm by apache.

the class EvaluationCalc method execute.

@Override
public Iterable<Values> execute(TridentTuple input) {
    Context calciteContext = new StormContext(dataContext);
    calciteContext.values = input.getValues().toArray();
    if (filterInstance != null) {
        filterInstance.execute(calciteContext, outputValues);
        // filtered out
        if (outputValues[0] == null || !((Boolean) outputValues[0])) {
            return Collections.emptyList();
        }
    }
    if (projectionInstance != null) {
        projectionInstance.execute(calciteContext, outputValues);
        return Collections.singletonList(new Values(outputValues));
    } else {
        return Collections.singletonList(new Values(input.getValues()));
    }
}
Also used : DataContext(org.apache.calcite.DataContext) TridentOperationContext(org.apache.storm.trident.operation.TridentOperationContext) StormContext(org.apache.calcite.interpreter.StormContext) Context(org.apache.calcite.interpreter.Context) Values(org.apache.storm.tuple.Values) StormContext(org.apache.calcite.interpreter.StormContext)

Aggregations

DataContext (org.apache.calcite.DataContext)3 Context (org.apache.calcite.interpreter.Context)3 StormContext (org.apache.calcite.interpreter.StormContext)3 TridentOperationContext (org.apache.storm.trident.operation.TridentOperationContext)3 Values (org.apache.storm.tuple.Values)2