use of io.siddhi.core.util.snapshot.state.PartitionStateHolder in project siddhi by wso2.
the class SiddhiQueryContext method generateStateHolder.
public StateHolder generateStateHolder(String name, boolean groupBy, StateFactory stateFactory, boolean unSafe) {
if (stateFactory != null) {
StateHolder stateHolder;
if (unSafe) {
if (partitioned || groupBy) {
stateHolder = new PartitionStateHolder(stateFactory);
} else {
stateHolder = new SingleStateHolder(stateFactory);
}
} else {
if (partitioned || groupBy) {
stateHolder = new PartitionSyncStateHolder(stateFactory);
} else {
stateHolder = new SingleSyncStateHolder(stateFactory);
}
}
if (SnapshotService.getSkipStateStorageThreadLocal().get() == null || !SnapshotService.getSkipStateStorageThreadLocal().get()) {
Map<String, StateHolder> stateHolderMap = siddhiAppContext.getSnapshotService().getStateHolderMap(partitionId, this.getName());
stateHolderMap.put(idGenerator.createNewId() + "-" + name, stateHolder);
}
stateful = true;
return stateHolder;
} else {
return new EmptyStateHolder();
}
}
Aggregations