Java Code Examples for io.siddhi.core.config.SiddhiQueryContext#getSiddhiAppContext()

The following examples show how to use io.siddhi.core.config.SiddhiQueryContext#getSiddhiAppContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpressionBatchWindowProcessor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
private MetaStateEvent constructExpression(MetaStreamEvent metaStreamEvent,
                                           SiddhiQueryContext siddhiQueryContext) {
    Expression expression = SiddhiCompiler.parseExpression(expressionString);
    MetaStreamEvent metaStreamEventFirst = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventFirst.setInputReferenceId("first");
    MetaStreamEvent metaStreamEventLast = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventLast.setInputReferenceId("last");
    MetaStateEvent metaStateEvent = new MetaStateEvent(
            new MetaStreamEvent[]{metaStreamEvent, metaStreamEventFirst, metaStreamEventLast});
    variableExpressionExecutors = new ArrayList<>();
    SiddhiQueryContext exprQueryContext = new SiddhiOnDemandQueryContext(
            siddhiQueryContext.getSiddhiAppContext(), siddhiQueryContext.getName(),
            expressionString);
    expressionExecutor = ExpressionParser.parseExpression(expression, metaStateEvent,
            0, new HashMap<>(), variableExpressionExecutors, false,
            0, ProcessingMode.SLIDE, true, exprQueryContext);
    if (expressionExecutor.getReturnType() != Attribute.Type.BOOL) {
        throw new SiddhiAppRuntimeException("Expression ('" + expressionString + "') does not return Bool");
    }
    return metaStateEvent;
}
 
Example 2
Source File: ExpressionWindowProcessor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
private MetaStateEvent constructExpression(MetaStreamEvent metaStreamEvent,
                                           SiddhiQueryContext siddhiQueryContext) {
    Expression expression = SiddhiCompiler.parseExpression(expressionString);
    MetaStreamEvent metaStreamEventFirst = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventFirst.setInputReferenceId("first");
    MetaStreamEvent metaStreamEventLast = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventLast.setInputReferenceId("last");
    MetaStateEvent metaStateEvent = new MetaStateEvent(
            new MetaStreamEvent[]{metaStreamEvent, metaStreamEventFirst, metaStreamEventLast});
    variableExpressionExecutors = new ArrayList<>();
    SiddhiQueryContext exprQueryContext = new SiddhiOnDemandQueryContext(
            siddhiQueryContext.getSiddhiAppContext(), siddhiQueryContext.getName(),
            expressionString);
    expressionExecutor = ExpressionParser.parseExpression(expression, metaStateEvent,
            0, new HashMap<>(), variableExpressionExecutors, false,
            0, ProcessingMode.SLIDE, true, exprQueryContext);
    if (expressionExecutor.getReturnType() != Attribute.Type.BOOL) {
        throw new SiddhiAppRuntimeException("Expression ('" + expressionString + "') does not return Bool");
    }
    return metaStateEvent;
}
 
Example 3
Source File: OutputParser.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public static OutputCallback constructOutputCallback(OutputStream outStream, String key,
                                                     ConcurrentMap<String, StreamJunction> streamJunctionMap,
                                                     StreamDefinition outputStreamDefinition,
                                                     SiddhiQueryContext siddhiQueryContext) {
    String id = outStream.getId();
    //Construct CallBack
    if (outStream instanceof InsertIntoStream) {
        StreamJunction outputStreamJunction = streamJunctionMap.get(id + key);
        if (outputStreamJunction == null) {
            outputStreamJunction = new StreamJunction(outputStreamDefinition,
                    siddhiQueryContext.getSiddhiAppContext().getExecutorService(),
                    siddhiQueryContext.getSiddhiAppContext().getBufferSize(), null,
                    siddhiQueryContext.getSiddhiAppContext());
            streamJunctionMap.putIfAbsent(id + key, outputStreamJunction);
        }
        InsertIntoStreamCallback insertIntoStreamCallback = new InsertIntoStreamCallback(outputStreamDefinition,
                siddhiQueryContext.getName());
        insertIntoStreamCallback.init(streamJunctionMap.get(id + key));
        return insertIntoStreamCallback;

    } else {
        throw new SiddhiAppCreationException(outStream.getClass().getName() + " not supported",
                outStream.getQueryContextStartIndex(), outStream.getQueryContextEndIndex());
    }
}