io.siddhi.core.config.SiddhiQueryContext Java Examples

The following examples show how to use io.siddhi.core.config.SiddhiQueryContext. 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: InMemoryTable.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
    TableState state = stateHolder.getState();
    try {
        return new InMemoryCompiledCondition(OperatorParser.constructOperator(state.eventHolder, condition,
                matchingMetaInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext),
                ExpressionParser.parseExpression(condition, matchingMetaInfoHolder.getMetaStateEvent(),
                        matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors,
                        false, 0, ProcessingMode.BATCH,
                        false, siddhiQueryContext),
                matchingMetaInfoHolder.getStoreEventIndex()
        );
    } finally {
        stateHolder.returnState(state);
    }
}
 
Example #2
Source File: InMemoryTable.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
public CompiledUpdateSet compileUpdateSet(UpdateSet updateSet, MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
    Map<Integer, ExpressionExecutor> expressionExecutorMap = new HashMap<>();
    for (UpdateSet.SetAttribute setAttribute : updateSet.getSetAttributeList()) {
        ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(
                setAttribute.getAssignmentExpression(), matchingMetaInfoHolder.getMetaStateEvent(),
                matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors,
                false, 0, ProcessingMode.BATCH, false,
                siddhiQueryContext);
        int attributePosition = tableDefinition.
                getAttributePosition(setAttribute.getTableVariable().getAttributeName());
        expressionExecutorMap.put(attributePosition, expressionExecutor);
    }
    return new InMemoryCompiledUpdateSet(expressionExecutorMap);
}
 
Example #3
Source File: CacheTable.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public CacheCompiledConditionWithRouteToCache generateCacheCompileCondition(
        Expression condition, MatchingMetaInfoHolder storeMatchingMetaInfoHolder,
        SiddhiQueryContext siddhiQueryContext, List<VariableExpressionExecutor> storeVariableExpressionExecutors) {
    boolean routeToCache = checkConditionToRouteToCache(condition, storeMatchingMetaInfoHolder);
    MetaStateEvent metaStateEvent = new MetaStateEvent(storeMatchingMetaInfoHolder.getMetaStateEvent().
            getMetaStreamEvents().length);
    for (MetaStreamEvent referenceMetaStreamEvent : storeMatchingMetaInfoHolder.getMetaStateEvent().
            getMetaStreamEvents()) {
        metaStateEvent.addEvent(referenceMetaStreamEvent);
    }
    MatchingMetaInfoHolder matchingMetaInfoHolder = new MatchingMetaInfoHolder(
            metaStateEvent,
            storeMatchingMetaInfoHolder.getMatchingStreamEventIndex(),
            storeMatchingMetaInfoHolder.getStoreEventIndex(),
            storeMatchingMetaInfoHolder.getMatchingStreamDefinition(),
            this.tableDefinition,
            storeMatchingMetaInfoHolder.getCurrentState());

    Map<String, Table> tableMap = new ConcurrentHashMap<>();
    tableMap.put(this.tableDefinition.getId(), this);

    return new CacheCompiledConditionWithRouteToCache(compileCondition(condition, matchingMetaInfoHolder,
            storeVariableExpressionExecutors, tableMap, siddhiQueryContext, routeToCache), routeToCache);
}
 
Example #4
Source File: IncrementalStartTimeEndTimeFunctionExecutor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length == 1) {
        if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) {
            throw new SiddhiAppValidationException("Only string values are supported for single within clause "
                    + "but found, " + attributeExpressionExecutors[0].getReturnType());
        }
    } else if (attributeExpressionExecutors.length == 2) {
        if (!(attributeExpressionExecutors[0].getReturnType() == Attribute.Type.LONG
                || attributeExpressionExecutors[0].getReturnType() == Attribute.Type.STRING)) {
            throw new SiddhiAppValidationException(
                    "Only string and long types are supported as first value of within clause");
        }
        if (!(attributeExpressionExecutors[1].getReturnType() == Attribute.Type.LONG
                || attributeExpressionExecutors[1].getReturnType() == Attribute.Type.STRING)) {
            throw new SiddhiAppValidationException(
                    "Only string and long types are supported as second value of within clause");
        }
    } else {
        throw new SiddhiAppValidationException("incrementalAggregator:startTimeEndTime() function accepts " +
                "only one or two arguments, but found " + attributeExpressionExecutors.length);
    }
    return null;
}
 
Example #5
Source File: AbstractRecordTable.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public CompiledUpdateSet compileUpdateSet(UpdateSet updateSet,
                                          MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
    RecordTableCompiledUpdateSet recordTableCompiledUpdateSet = new RecordTableCompiledUpdateSet();
    Map<String, ExpressionExecutor> parentExecutorMap = new HashMap<>();
    for (UpdateSet.SetAttribute setAttribute : updateSet.getSetAttributeList()) {
        ExpressionExecutor inMemoryAssignmentExecutor = ExpressionParser.parseExpression(
                setAttribute.getAssignmentExpression(), matchingMetaInfoHolder.getMetaStateEvent(),
                matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors,
                false, 0, ProcessingMode.BATCH, false,
                siddhiQueryContext);
        ExpressionBuilder expressionBuilder = new ExpressionBuilder(setAttribute.getAssignmentExpression(),
                matchingMetaInfoHolder, variableExpressionExecutors, tableMap, null,
                inMemoryAssignmentExecutor, siddhiQueryContext);
        CompiledExpression compiledExpression = compileSetAttribute(expressionBuilder);
        recordTableCompiledUpdateSet.put(setAttribute.getTableVariable().getAttributeName(), compiledExpression);
        Map<String, ExpressionExecutor> expressionExecutorMap =
                expressionBuilder.getVariableExpressionExecutorMap();
        parentExecutorMap.putAll(expressionExecutorMap);
    }
    recordTableCompiledUpdateSet.setExpressionExecutorMap(parentExecutorMap);
    return recordTableCompiledUpdateSet;
}
 
Example #6
Source File: CustomFunctionExtension.java    From siddhi with Apache License 2.0 6 votes vote down vote up
/**
 * The initialization method for FunctionExecutor, this method will be called before the other methods
 *
 * @param attributeExpressionExecutors are the executors of each function parameters
 * @param configReader
 * @param siddhiQueryContext           the context of the siddhi query
 */
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            SiddhiQueryContext siddhiQueryContext) {
    for (ExpressionExecutor expressionExecutor : attributeExpressionExecutors) {
        Attribute.Type attributeType = expressionExecutor.getReturnType();
        if (attributeType == Attribute.Type.DOUBLE) {
            returnType = attributeType;

        } else if ((attributeType == Attribute.Type.STRING) || (attributeType == Attribute.Type.BOOL)) {
            throw new SiddhiAppCreationException("Plus cannot have parameters with types String or Bool");
        } else {
            returnType = Attribute.Type.LONG;
        }
    }
    return null;
}
 
Example #7
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 #8
Source File: StringListSizeFunctionExtension.java    From eagle with Apache License 2.0 6 votes vote down vote up
/**
 * The initialization method for StringListSizeFunctionExtension,
 * this method will be called before the other methods.
 *
 * @param attributeExpressionExecutors  the executors of each function parameter
 * @param configReader                  the config reader for the Siddhi app
 * @param siddhiQueryContext            the context of the Siddhi query
 */
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new SiddhiAppValidationException("Invalid no of arguments passed to str:listSize() function, "
                + "required 1, but found " + attributeExpressionExecutors.length);
    }

    Attribute.Type attributeType = attributeExpressionExecutors[0].getReturnType();
    if (attributeType != Attribute.Type.STRING) {
        throw new SiddhiAppValidationException("Invalid parameter type found for the argument of str:listSize() "
                + "function, required " + Attribute.Type.STRING + ", but found " + attributeType.toString());
    }
    return null;
}
 
Example #9
Source File: AttributeStreamFunction.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
protected StateFactory init(AbstractDefinition inputDefinition,
                            ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            boolean outputExpectsExpiredEvents, SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new SiddhiAppCreationException("Only one attribute is expected but found " +
                attributeExpressionExecutors.length);
    }
    if (!(attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor)) {
        throw new SiddhiAppCreationException("Attribute is expected to be constant, but its not!");
    }
    newAttributes = new ArrayList<>();
    newAttributes.add(
            new Attribute(((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue().toString(),
                    inputDefinition.getAttributeList().get(0).getType()));
    return null;
}
 
Example #10
Source File: IncrementalAggregateBaseTimeFunctionExecutor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 2) {
        throw new SiddhiAppValidationException("incrementalAggregator:getAggregationStartTime() function accepts " +
                "two arguments, but found " + attributeExpressionExecutors.length);
    }
    if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) {
        throw new SiddhiAppValidationException("Second argument of " +
                "incrementalAggregator:getAggregationStartTime() function accepts should be of type 'STRING', " +
                "but found '" + attributeExpressionExecutors[1].getReturnType() + "'.");
    }
    this.timeZone = siddhiQueryContext.getSiddhiContext().getConfigManager().extractProperty(SiddhiConstants
            .AGG_TIME_ZONE);
    if (timeZone == null) {
        this.timeZone = SiddhiConstants.AGG_TIME_ZONE_DEFAULT;
    }
    return null;
}
 
Example #11
Source File: BaseIncrementalValueStore.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public BaseIncrementalValueStore(String aggregatorName, long initialTimestamp,
                                 List<ExpressionExecutor> expressionExecutors,
                                 ExpressionExecutor shouldUpdateTimestamp, StreamEventFactory streamEventFactory,
                                 SiddhiQueryContext siddhiQueryContext, boolean groupBy, boolean local) {

    this.initialTimestamp = initialTimestamp;
    this.expressionExecutors = expressionExecutors;
    this.shouldUpdateTimestamp = shouldUpdateTimestamp;

    this.streamEventFactory = streamEventFactory;

    if (!local) {
        this.valueStateHolder = siddhiQueryContext.generateStateHolder(aggregatorName + "-" +
                this.getClass().getName() + "-value", groupBy, () -> new ValueState());
        this.storeStateHolder = siddhiQueryContext.generateStateHolder(aggregatorName + "-" +
                this.getClass().getName(), false, () -> new StoreState());
    } else {
        this.valueStateHolder = new PartitionSyncStateHolder(() -> new ValueState());
        this.storeStateHolder = new SingleSyncStateHolder(() -> new StoreState());
    }
}
 
Example #12
Source File: EmptyWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            StreamEventClonerHolder streamEventClonerHolder, boolean outputExpectsExpiredEvents,
                            boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) {
    this.outputExpectsExpiredEvents = outputExpectsExpiredEvents;
    this.siddhiQueryContext = siddhiQueryContext;
    return () -> new EmptyWindowProcessor.WindowState(streamEventClonerHolder, false,
            outputExpectsExpiredEvents, findToBeExecuted);
}
 
Example #13
Source File: FrequentWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory<WindowState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                         ConfigReader configReader,
                                         SiddhiQueryContext siddhiQueryContext) {
    mostFrequentCount = Integer.parseInt(String.valueOf(((ConstantExpressionExecutor)
            attributeExpressionExecutors[0]).getValue()));
    variableExpressionExecutors = new VariableExpressionExecutor[attributeExpressionExecutors.length - 1];
    for (int i = 1; i < attributeExpressionExecutors.length; i++) {
        variableExpressionExecutors[i - 1] = (VariableExpressionExecutor) attributeExpressionExecutors[i];
    }
    return () -> new WindowState();
}
 
Example #14
Source File: LengthBatchWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, WindowState state,
                                          SiddhiQueryContext siddhiQueryContext) {
    return OperatorParser.constructOperator(state.expiredEventQueue, condition, matchingMetaInfoHolder,
            variableExpressionExecutors, tableMap, siddhiQueryContext);
}
 
Example #15
Source File: JoinInputStreamParser.java    From siddhi with Apache License 2.0 5 votes vote down vote up
private static void setStreamRuntimeProcessorChain(
        MetaStreamEvent metaStreamEvent, SingleStreamRuntime streamRuntime,
        String inputStreamId, Map<String, Table> tableMap, Map<String, Window> windowMap,
        Map<String, AggregationRuntime> aggregationMap,
        List<VariableExpressionExecutor> variableExpressionExecutors, boolean outputExpectsExpiredEvents,
        Within within, Expression per, List<Variable> queryGroupByList, SiddhiQueryContext siddhiQueryContext,
        InputStream inputStream) {
    switch (metaStreamEvent.getEventType()) {

        case TABLE:
            TableWindowProcessor tableWindowProcessor = new TableWindowProcessor(tableMap.get(inputStreamId));
            tableWindowProcessor.initProcessor(metaStreamEvent,
                    new ExpressionExecutor[0], null, outputExpectsExpiredEvents,
                    true, false, inputStream, siddhiQueryContext);
            streamRuntime.setProcessorChain(tableWindowProcessor);
            break;
        case WINDOW:
            WindowWindowProcessor windowWindowProcessor = new WindowWindowProcessor(
                    windowMap.get(inputStreamId));
            windowWindowProcessor.initProcessor(metaStreamEvent,
                    variableExpressionExecutors.toArray(new ExpressionExecutor[0]), null,
                    outputExpectsExpiredEvents, true, false, inputStream, siddhiQueryContext);
            streamRuntime.setProcessorChain(windowWindowProcessor);
            break;
        case AGGREGATE:

            AggregationRuntime aggregationRuntime = aggregationMap.get(inputStreamId);
            AggregateWindowProcessor aggregateWindowProcessor = new AggregateWindowProcessor(
                    aggregationRuntime, within, per, queryGroupByList);
            aggregateWindowProcessor.initProcessor(metaStreamEvent,
                    variableExpressionExecutors.toArray(new ExpressionExecutor[0]), null,
                    outputExpectsExpiredEvents, true, false, inputStream, siddhiQueryContext);
            streamRuntime.setProcessorChain(aggregateWindowProcessor);
            break;
        case DEFAULT:
            break;
    }
}
 
Example #16
Source File: InstanceOfFloatFunctionExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new SiddhiAppValidationException("Invalid no of arguments passed to instanceOfFloat() " +
                "function, required only 1, but found " + attributeExpressionExecutors.length);
    }
    return null;
}
 
Example #17
Source File: TimeBatchWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, WindowState state,
                                          SiddhiQueryContext siddhiQueryContext) {
    return OperatorParser.constructOperator(state.expiredEventQueue, condition, matchingMetaInfoHolder,
            variableExpressionExecutors, tableMap, siddhiQueryContext);
}
 
Example #18
Source File: EmptyWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, WindowState state,
                                          SiddhiQueryContext siddhiQueryContext) {
    return OperatorParser.constructOperator(state.expiredEventQueue, condition, matchingMetaInfoHolder,
            variableExpressionExecutors, tableMap, siddhiQueryContext);
}
 
Example #19
Source File: AggregationParser.java    From siddhi with Apache License 2.0 5 votes vote down vote up
private static boolean populateFinalBaseAggregators(
        Map<String, Table> tableMap, List<VariableExpressionExecutor> incomingVariableExpressionExecutors,
        MetaStreamEvent incomingMetaStreamEvent, List<ExpressionExecutor> incomingExpressionExecutors,
        List<IncrementalAttributeAggregator> incrementalAttributeAggregators,
        SiddhiQueryContext siddhiQueryContext, List<Expression> finalBaseAggregators) {

    boolean isOptimisedLookup = true;

    List<Attribute> finalBaseAttributes = new ArrayList<>();

    for (IncrementalAttributeAggregator incrementalAttributeAggregator : incrementalAttributeAggregators) {
        Attribute[] baseAttributes = incrementalAttributeAggregator.getBaseAttributes();
        Expression[] baseAttributeInitialValues = incrementalAttributeAggregator.getBaseAttributeInitialValues();
        Expression[] baseAggregators = incrementalAttributeAggregator.getBaseAggregators();

        if (baseAggregators.length > 1) {
            isOptimisedLookup = false;
        }

        for (int i = 0; i < baseAttributes.length; i++) {
            validateBaseAggregators(incrementalAttributeAggregators,
                    incrementalAttributeAggregator, baseAttributes,
                    baseAttributeInitialValues, baseAggregators, i);
            if (!finalBaseAttributes.contains(baseAttributes[i])) {
                finalBaseAttributes.add(baseAttributes[i]);
                finalBaseAggregators.add(baseAggregators[i]);
                incomingMetaStreamEvent.addOutputData(baseAttributes[i]);
                incomingExpressionExecutors.add(ExpressionParser.parseExpression(baseAttributeInitialValues[i],
                        incomingMetaStreamEvent, 0, tableMap, incomingVariableExpressionExecutors,
                        false, 0,
                        ProcessingMode.BATCH, false, siddhiQueryContext));
            }
        }
    }
    return isOptimisedLookup;
}
 
Example #20
Source File: InstanceOfDoubleFunctionExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new SiddhiAppValidationException("Invalid no of arguments passed to instanceOfDouble() " +
                "function, required only 1, but found " + attributeExpressionExecutors.length);
    }
    return null;
}
 
Example #21
Source File: ExternalTimeWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory<WindowState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                         ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length == 2) {
        if (attributeExpressionExecutors[1].getReturnType() == Attribute.Type.INT) {
            timeToKeep = Integer.parseInt(String.valueOf(((ConstantExpressionExecutor)
                    attributeExpressionExecutors[1]).getValue()));
        } else {
            timeToKeep = Long.parseLong(String.valueOf(((ConstantExpressionExecutor)
                    attributeExpressionExecutors[1]).getValue()));
        }
        if (!(attributeExpressionExecutors[0] instanceof VariableExpressionExecutor)) {
            throw new SiddhiAppValidationException("ExternalTime window's 1st parameter timeStamp should be a" +
                    " type long stream attribute but found " + attributeExpressionExecutors[0].getClass());
        }
        timeStampVariableExpressionExecutor = ((VariableExpressionExecutor) attributeExpressionExecutors[0]);
        if (timeStampVariableExpressionExecutor.getReturnType() != Attribute.Type.LONG) {
            throw new SiddhiAppValidationException("ExternalTime window's 1st parameter timeStamp should be " +
                    "type long, but found " + timeStampVariableExpressionExecutor.getReturnType());
        }
    } else {
        throw new SiddhiAppValidationException("ExternalTime window should only have two parameter (<long> " +
                "timeStamp, <int|long|time> windowTime), but found " + attributeExpressionExecutors.length + " " +
                "input attributes");
    }
    return () -> new WindowState();
}
 
Example #22
Source File: TimeWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, WindowState state,
                                          SiddhiQueryContext siddhiQueryContext) {
    return OperatorParser.constructOperator(state.expiredEventQueue, condition,
            matchingMetaInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);
}
 
Example #23
Source File: TimeWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory<WindowState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                         ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) {
    this.siddhiQueryContext = siddhiQueryContext;

    if (attributeExpressionExecutors.length == 1) {
        if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
            if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.INT) {
                timeInMilliSeconds = (Integer) ((ConstantExpressionExecutor) attributeExpressionExecutors[0])
                        .getValue();

            } else if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.LONG) {
                timeInMilliSeconds = (Long) ((ConstantExpressionExecutor) attributeExpressionExecutors[0])
                        .getValue();
            } else {
                throw new SiddhiAppValidationException("Time window's parameter attribute should be either " +
                        "int or long, but found " + attributeExpressionExecutors[0].getReturnType());
            }
        } else {
            throw new SiddhiAppValidationException("Time window should have constant parameter attribute but " +
                    "found a dynamic attribute " + attributeExpressionExecutors[0].getClass().getCanonicalName());
        }
    } else {
        throw new SiddhiAppValidationException("Time window should only have one parameter (<int|long|time> " +
                "windowTime), but found " + attributeExpressionExecutors.length + " input attributes");
    }
    return () -> new WindowState(streamEventClonerHolder);
}
 
Example #24
Source File: SequenceMultiProcessStreamReceiver.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public SequenceMultiProcessStreamReceiver(String streamId, int processCount, StateStreamRuntime
        stateStreamRuntime, Object patternSyncObject, SiddhiQueryContext siddhiQueryContext) {
    super(streamId, processCount, patternSyncObject, siddhiQueryContext);
    this.stateStreamRuntime = stateStreamRuntime;
    eventSequence = new int[processCount];
    int count = 0;
    for (int i = eventSequence.length - 1; i >= 0; i--) {
        eventSequence[count] = i;
        count++;
    }
}
 
Example #25
Source File: IncrementalShouldUpdateFunctionExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory<FunctionState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                           ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new SiddhiAppValidationException("shouldUpdate() function has to have exactly 1 parameter, " +
                "currently " + attributeExpressionExecutors.length + " parameters provided");
    }
    if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.LONG) {
        throw new OperationNotSupportedException("Parameter given for shouldUpdate() function has to be of type " +
                "long, but found: " + attributeExpressionExecutors[0].getReturnType());
    }
    return () -> new FunctionState();
}
 
Example #26
Source File: AggregateWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            StreamEventClonerHolder streamEventClonerHolder, boolean outputExpectsExpiredEvents,
                            boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) {
    // nothing to be done
    return null;
}
 
Example #27
Source File: WindowWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
    return window.compileCondition(condition, matchingMetaInfoHolder, variableExpressionExecutors, tableMap,
            siddhiQueryContext);
}
 
Example #28
Source File: WindowWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory init(MetaStreamEvent metaStreamEvent,
                            AbstractDefinition inputDefinition,
                            ExpressionExecutor[] attributeExpressionExecutors,
                            ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder,
                            boolean outputExpectsExpiredEvents, boolean findToBeExecuted,
                            SiddhiQueryContext siddhiQueryContext) {
    return null;
}
 
Example #29
Source File: AbstractQueryableRecordTable.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public CompiledUpdateSet compileUpdateSet(UpdateSet updateSet,
                                          MatchingMetaInfoHolder matchingMetaInfoHolder,
                                          List<VariableExpressionExecutor> variableExpressionExecutors,
                                          Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
    CompiledUpdateSet recordTableCompiledUpdateSet = super.compileUpdateSet(updateSet,
            matchingMetaInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);
    if (cacheEnabled) {
        CompiledUpdateSet cacheCompileUpdateSet = cacheTable.compileUpdateSet(updateSet, matchingMetaInfoHolder,
                variableExpressionExecutors, tableMap, siddhiQueryContext);
        return new CompiledUpdateSetWithCache(recordTableCompiledUpdateSet, cacheCompileUpdateSet);
    }
    return recordTableCompiledUpdateSet;
}
 
Example #30
Source File: ScriptFunctionExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                            SiddhiQueryContext siddhiQueryContext) {
    returnType = siddhiQueryContext.getSiddhiAppContext().getScript(functionId).getReturnType();
    script = siddhiQueryContext.getSiddhiAppContext().getScript(functionId);
    return null;
}