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

The following examples show how to use io.siddhi.core.config.SiddhiQueryContext#generateStateHolder() . 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: 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 2
Source File: AttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public void initAggregator(ExpressionExecutor[] attributeExpressionExecutors, ProcessingMode processingMode,
                           boolean outputExpectsExpiredEvents,
                           ConfigReader configReader, boolean groupBy, SiddhiQueryContext siddhiQueryContext) {
    try {
        this.attributeExpressionExecutors = attributeExpressionExecutors;
        this.attributeSize = attributeExpressionExecutors.length;
        InputParameterValidator.validateExpressionExecutors(this, attributeExpressionExecutors);
        StateFactory<S> stateFactory = init(attributeExpressionExecutors, processingMode,
                outputExpectsExpiredEvents, configReader, siddhiQueryContext);
        stateHolder = siddhiQueryContext.generateStateHolder(this.getClass().getName(),
                groupBy, stateFactory, true);
    } catch (Throwable t) {
        throw new SiddhiAppCreationException(t);
    }
}
 
Example 3
Source File: OutputRateLimiter.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public void init(LockWrapper lockWrapper, boolean groupBy, SiddhiQueryContext siddhiQueryContext) {
    this.siddhiQueryContext = siddhiQueryContext;
    if (outputCallback != null) {
        this.lockWrapper = lockWrapper;
    }
    latencyTracker = siddhiQueryContext.getLatencyTracker();
    stateHolder = siddhiQueryContext.generateStateHolder(this.getClass().getName(), groupBy, init());
}
 
Example 4
Source File: IncrementalExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
public IncrementalExecutor(String aggregatorName, TimePeriod.Duration duration,
                           List<ExpressionExecutor> processExpressionExecutors,
                           ExpressionExecutor shouldUpdateTimestamp, GroupByKeyGenerator groupByKeyGenerator,
                           boolean isRoot, Table table, IncrementalExecutor child,
                           SiddhiQueryContext siddhiQueryContext, MetaStreamEvent metaStreamEvent,
                           String timeZone) {
    this.timeZone = timeZone;
    this.aggregatorName = aggregatorName;
    this.duration = duration;
    this.isRoot = isRoot;
    this.table = table;
    this.next = child;

    this.timestampExpressionExecutor = processExpressionExecutors.remove(0);
    this.streamEventFactory = new StreamEventFactory(metaStreamEvent);

    this.groupByKeyGenerator = groupByKeyGenerator;
    this.baseIncrementalValueStore = new BaseIncrementalValueStore(aggregatorName, -1,
            processExpressionExecutors, shouldUpdateTimestamp, streamEventFactory, siddhiQueryContext, true,
            false);
    this.resetEvent = AggregationParser.createRestEvent(metaStreamEvent, streamEventFactory.newInstance());
    setNextExecutor(child);

    this.siddhiAppName = siddhiQueryContext.getSiddhiAppContext().getName();
    this.stateHolder = siddhiQueryContext.generateStateHolder(
            aggregatorName + "-" + this.getClass().getName(), false, () -> new ExecutorState());
    this.executorService = Executors.newSingleThreadExecutor();

    this.isProcessingExecutor = false;

}
 
Example 5
Source File: SnapshotOutputRateLimiter.java    From siddhi with Apache License 2.0 4 votes vote down vote up
protected SnapshotOutputRateLimiter(WrappedSnapshotOutputRateLimiter wrappedSnapshotOutputRateLimiter,
                                    SiddhiQueryContext siddhiQueryContext, boolean groupBy) {
    this.wrappedSnapshotOutputRateLimiter = wrappedSnapshotOutputRateLimiter;
    this.siddhiQueryContext = siddhiQueryContext;
    stateHolder = siddhiQueryContext.generateStateHolder(this.getClass().getName(), groupBy, init());
}
 
Example 6
Source File: AbsentLogicalPreStateProcessor.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public void init(SiddhiQueryContext siddhiQueryContext) {
    this.siddhiQueryContext = siddhiQueryContext;
    this.stateHolder = siddhiQueryContext.generateStateHolder(
            this.getClass().getName(),
            false, () -> new LogicalStreamPreState());
}
 
Example 7
Source File: AbsentStreamPreStateProcessor.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public void init(SiddhiQueryContext siddhiQueryContext) {
    this.siddhiQueryContext = siddhiQueryContext;
    this.stateHolder = siddhiQueryContext.generateStateHolder(
            this.getClass().getName(),
            false, () -> new LogicalStreamPreState());
}
 
Example 8
Source File: StreamPreStateProcessor.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public void init(SiddhiQueryContext siddhiQueryContext) {
    this.siddhiQueryContext = siddhiQueryContext;
    this.stateHolder = siddhiQueryContext.generateStateHolder(
            this.getClass().getName(),
            false, () -> new StreamPreState());
}
 
Example 9
Source File: CountPreStateProcessor.java    From siddhi with Apache License 2.0 4 votes vote down vote up
public void init(SiddhiQueryContext siddhiQueryContext) {
    this.siddhiQueryContext = siddhiQueryContext;
    this.stateHolder = siddhiQueryContext.generateStateHolder(
            this.getClass().getName(),
            false, () -> new CountStreamPreState());
}