io.siddhi.core.util.snapshot.state.StateFactory Java Examples
The following examples show how to use
io.siddhi.core.util.snapshot.state.StateFactory.
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: DefaultFunctionExecutor.java From siddhi with Apache License 2.0 | 6 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (attributeExpressionExecutors.length != 2) { // check whether all the arguments passed throw new SiddhiAppValidationException("Invalid no of parameters passed to default() function, " + "it require only 2 (attribute, default value) , " + "but found " + attributeExpressionExecutors.length); } else if (!(attributeExpressionExecutors[1] instanceof ConstantExpressionExecutor)) { throw new SiddhiAppValidationException("Invalid parameter passed to default() function, " + "this only consumes constants, but found " + attributeExpressionExecutors[1].getClass().getName()); } else if ((attributeExpressionExecutors[0].getReturnType() != attributeExpressionExecutors[1] .getReturnType())) { throw new SiddhiAppValidationException("Both attribute and default value parameters need to be of " + "same return type but they are of " + attributeExpressionExecutors[0].getReturnType() + "and" + attributeExpressionExecutors[1].getReturnType()); } returnType = attributeExpressionExecutors[0].getReturnType(); return null; }
Example #2
Source File: DelayWindowProcessor.java From siddhi with Apache License 2.0 | 6 votes |
@Override protected StateFactory 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 || attributeExpressionExecutors[0].getReturnType() == Attribute.Type.LONG) { delayInMilliSeconds = Long.parseLong(((ConstantExpressionExecutor) attributeExpressionExecutors[0]) .getValue().toString()); } else { throw new SiddhiAppValidationException("Delay window's parameter attribute should be either " + "int or long, but found " + attributeExpressionExecutors[0].getReturnType()); } } else { throw new SiddhiAppValidationException("Delay window should have constant parameter attribute but " + "found a dynamic attribute " + attributeExpressionExecutors[0].getClass().getCanonicalName()); } } else { throw new SiddhiAppValidationException("Delay window should only have one parameter (<int|long|time> " + "delayTime), but found " + attributeExpressionExecutors.length + " input attributes"); } return () -> new DelayedWindowState(streamEventClonerHolder); }
Example #3
Source File: IncrementalStartTimeEndTimeFunctionExecutor.java From siddhi with Apache License 2.0 | 6 votes |
@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 #4
Source File: AttributeStreamFunction.java From siddhi with Apache License 2.0 | 6 votes |
@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 #5
Source File: StringSubtractFunctionExtension.java From eagle with Apache License 2.0 | 6 votes |
/** * The initialization method for StringSubtractFunctionExtension, * 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 != 2) { throw new SiddhiAppValidationException("Invalid no of arguments passed to str:subtract() function, " + "required 2, 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:subtract() " + "function, required " + Attribute.Type.STRING + ", but found " + attributeType.toString()); } return null; }
Example #6
Source File: StringEmptyFunctionExtension.java From eagle with Apache License 2.0 | 6 votes |
/** * The initialization method for StringEmptyFunctionExtension, * 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:empty() 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:empty() " + "function, required " + Attribute.Type.STRING + ", but found " + attributeType.toString()); } return null; }
Example #7
Source File: StringListSizeFunctionExtension.java From eagle with Apache License 2.0 | 6 votes |
/** * 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 #8
Source File: BatchWindowProcessor.java From siddhi with Apache License 2.0 | 6 votes |
@Override protected StateFactory<WindowState> init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder, boolean outputExpectsExpiredEvents, boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) { this.outputExpectsExpiredEvents = outputExpectsExpiredEvents; this.findToBeExecuted = findToBeExecuted; this.siddhiQueryContext = siddhiQueryContext; if (attributeExpressionExecutors.length == 1) { length = (Integer) (((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue()); } else if (attributeExpressionExecutors.length == 0) { length = 0; } else { throw new SiddhiAppValidationException("Batch window should have at most one parameter (<int> " + "chunkLength), but found " + attributeExpressionExecutors.length + " input attributes"); } if (length < 0) { throw new SiddhiAppValidationException("Batch window should have at most one parameter (<int> " + "chunkLength) greater than zero. But found value 'chunkLength = " + length + " ' "); } return () -> new WindowState(streamEventClonerHolder, outputExpectsExpiredEvents, findToBeExecuted); }
Example #9
Source File: ContainsIgnoreCaseExtension.java From eagle with Apache License 2.0 | 6 votes |
/** * The initialization method for ContainsIgnoreCaseExtension, * 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 != 2) { throw new SiddhiAppValidationException("Invalid no of arguments passed to str:containsIgnoreCase() " + "function, required 2, but found " + attributeExpressionExecutors.length); } if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { throw new SiddhiAppValidationException("Invalid parameter type found for the first argument of " + "str:containsIgnoreCase() function, required " + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[0].getReturnType().toString()); } if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { throw new SiddhiAppValidationException("Invalid parameter type found for the second argument of " + "str:containsIgnoreCase() function, required " + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType().toString()); } return null; }
Example #10
Source File: CustomPlusFunctionExtension.java From flink-siddhi with Apache License 2.0 | 6 votes |
/** * The initialization method for FunctionExecutor, this method will be called before the other methods */ @Override protected StateFactory init(ExpressionExecutor[] expressionExecutors, 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 #11
Source File: LossyFrequentWindowProcessor.java From siddhi with Apache License 2.0 | 6 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { support = Double.parseDouble(String.valueOf(((ConstantExpressionExecutor) attributeExpressionExecutors[0]) .getValue())); if (attributeExpressionExecutors.length > 1) { error = Double.parseDouble(String.valueOf(((ConstantExpressionExecutor) attributeExpressionExecutors[1]) .getValue())); } else { error = support / 10; // recommended error is 10% of 20$ of support value; } if ((support > 1 || support < 0) || (error > 1 || error < 0)) { log.error("Wrong argument has provided, Error executing the window"); } variableExpressionExecutors = new VariableExpressionExecutor[attributeExpressionExecutors.length - 2]; if (attributeExpressionExecutors.length > 2) { // by-default all the attributes will be compared for (int i = 2; i < attributeExpressionExecutors.length; i++) { variableExpressionExecutors[i - 2] = (VariableExpressionExecutor) attributeExpressionExecutors[i]; } } windowWidth = Math.ceil(1 / error); return () -> new WindowState(); }
Example #12
Source File: CustomFunctionExtension.java From siddhi with Apache License 2.0 | 6 votes |
@Override public 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 #13
Source File: EmptyWindowProcessor.java From siddhi with Apache License 2.0 | 5 votes |
@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 #14
Source File: LastGroupByPerTimeOutputRateLimiter.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory<RateLimiterState> init() { this.scheduler = SchedulerParser.parse(this, siddhiQueryContext); this.scheduler.setStreamEventFactory(new StreamEventFactory(0, 0, 0)); this.scheduler.init(lockWrapper, siddhiQueryContext.getName()); return () -> new RateLimiterState(); }
Example #15
Source File: CronWindowProcessor.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory<WindowState> init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder, boolean outputExpectsExpiredEvents, boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) { this.streamEventClonerHolder = streamEventClonerHolder; this.id = siddhiQueryContext.getName() + "_" + siddhiQueryContext.generateNewId(); if (attributeExpressionExecutors != null) { cronString = (String) (((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue()); } return () -> new WindowState(streamEventClonerHolder); }
Example #16
Source File: CreateSetFunctionExecutor.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (attributeExpressionExecutors.length != 1) { throw new SiddhiAppValidationException("createSet() function has to have exactly 1 parameter, currently " + attributeExpressionExecutors.length + " parameters provided"); } if (!isAttributeTypeSupported(attributeExpressionExecutors[0].getReturnType())) { throw new OperationNotSupportedException("createSet() function not supported for type: " + attributeExpressionExecutors[0].getReturnType()); } return null; }
Example #17
Source File: AllAggregationGroupByWindowedPerSnapshotOutputRateLimiter.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory<RateLimiterState> init() { this.scheduler = SchedulerParser.parse(this, siddhiQueryContext); this.scheduler.setStreamEventFactory(new StreamEventFactory(0, 0, 0)); this.scheduler.init(lockWrapper, siddhiQueryContext.getName()); return () -> new RateLimiterState(); }
Example #18
Source File: GroupingWindowProcessor.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory<S> init(MetaStreamEvent metaStreamEvent, AbstractDefinition inputDefinition, ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder, boolean outputExpectsExpiredEvents, boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) { StateFactory<S> stateFactory = init(attributeExpressionExecutors, configReader, outputExpectsExpiredEvents, siddhiQueryContext); Attribute groupingKey = new Attribute("_groupingKey", Attribute.Type.STRING); internalAttributes = new ArrayList<Attribute>(1); internalAttributes.add(groupingKey); metaStreamEvent.addData(groupingKey); return stateFactory; }
Example #19
Source File: SiddhiQueryContext.java From siddhi with Apache License 2.0 | 5 votes |
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(); } }
Example #20
Source File: FrequentWindowProcessor.java From siddhi with Apache License 2.0 | 5 votes |
@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 #21
Source File: SortWindowProcessor.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.INT) { lengthToKeep = Integer.parseInt(String.valueOf(((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue())); } else { throw new UnsupportedOperationException("The first parameter should be an integer"); } parameterInfo = new ArrayList<Object[]>(); eventComparator = new EventComparator(); for (int i = 1, parametersLength = attributeExpressionExecutors.length; i < parametersLength; i++) { if (!(attributeExpressionExecutors[i] instanceof VariableExpressionExecutor)) { throw new UnsupportedOperationException("Required a variable, but found a string parameter"); } else { ExpressionExecutor variableExpressionExecutor = attributeExpressionExecutors[i]; int order; String nextParameter; if (i + 1 < parametersLength && attributeExpressionExecutors[i + 1].getReturnType() == Attribute.Type .STRING) { nextParameter = (String) ((ConstantExpressionExecutor) attributeExpressionExecutors[i + 1]) .getValue(); if (nextParameter.equalsIgnoreCase(DESC)) { order = -1; i++; } else if (nextParameter.equalsIgnoreCase(ASC)) { order = 1; i++; } else { throw new UnsupportedOperationException("Parameter string literals should only be \"asc\" or " + "\"desc\""); } } else { order = 1; //assigning the default order: "asc" } parameterInfo.add(new Object[]{variableExpressionExecutor, order}); } } return () -> new WindowState(); }
Example #22
Source File: ScriptFunctionExecutor.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { returnType = siddhiQueryContext.getSiddhiAppContext().getScript(functionId).getReturnType(); script = siddhiQueryContext.getSiddhiAppContext().getScript(functionId); return null; }
Example #23
Source File: IncrementalShouldUpdateFunctionExecutor.java From siddhi with Apache License 2.0 | 5 votes |
@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 #24
Source File: IncrementalTimeGetTimeZone.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (!(attributeExpressionExecutors.length == 0 || attributeExpressionExecutors.length == 1)) { throw new SiddhiAppValidationException("incrementalAggregator:getTimeZone() function " + "accepts zero or one argument, but found " + attributeExpressionExecutors.length); } if (attributeExpressionExecutors.length == 1) { if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { throw new SiddhiAppValidationException("Time zone can be retrieved, only from " + "string values, but found " + attributeExpressionExecutors[0].getReturnType()); } } return null; }
Example #25
Source File: InstanceOfIntegerFunctionExecutor.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (attributeExpressionExecutors.length != 1) { throw new SiddhiAppValidationException("Invalid no of arguments passed to instanceOfInteger() " + "function, required only 1, but found " + attributeExpressionExecutors.length); } return null; }
Example #26
Source File: CastFunctionExecutor.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (attributeExpressionExecutors.length != 2) { throw new SiddhiAppValidationException("Invalid no of arguments passed to common:cast() function, " + "required 2 parameters, but found " + attributeExpressionExecutors.length); } if (!(attributeExpressionExecutors[1] instanceof ConstantExpressionExecutor)) { throw new SiddhiAppValidationException("The second argument has to be a string constant specifying " + "one of the supported data types " + "(int, long, float, double, string, bool)"); } else { String type = attributeExpressionExecutors[1].execute(null).toString(); if (type.toLowerCase().equals("int")) { returnType = Attribute.Type.INT; } else if (type.toLowerCase().equals("long")) { returnType = Attribute.Type.LONG; } else if (type.toLowerCase().equals("float")) { returnType = Attribute.Type.FLOAT; } else if (type.toLowerCase().equals("double")) { returnType = Attribute.Type.DOUBLE; } else if (type.toLowerCase().equals("bool")) { returnType = Attribute.Type.BOOL; } else if (type.toLowerCase().equals("string")) { returnType = Attribute.Type.STRING; } else { throw new SiddhiAppValidationException("Type must be one of int, long, float, double, bool, " + "string"); } } return null; }
Example #27
Source File: FaultFunctionExtension.java From siddhi with Apache License 2.0 | 5 votes |
@Override public StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { returnType = Attribute.Type.DOUBLE; return null; }
Example #28
Source File: AvgAttributeAggregatorExecutor.java From siddhi with Apache License 2.0 | 5 votes |
/** * The initialization method for FunctionExecutor * * @param attributeExpressionExecutors are the executors of each attributes in the function * @param processingMode query processing mode * @param outputExpectsExpiredEvents is expired events sent as output * @param configReader this hold the {@link AvgAttributeAggregatorExecutor} configuration reader. * @param siddhiQueryContext Siddhi query runtime context */ @Override protected StateFactory<AvgAttributeState> init(ExpressionExecutor[] attributeExpressionExecutors, ProcessingMode processingMode, boolean outputExpectsExpiredEvents, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (attributeExpressionExecutors.length != 1) { throw new OperationNotSupportedException("Avg aggregator has to have exactly 1 parameter, currently " + attributeExpressionExecutors.length + " parameters provided"); } returnType = Attribute.Type.DOUBLE; Attribute.Type type = attributeExpressionExecutors[0].getReturnType(); return () -> { switch (type) { case FLOAT: return new AvgAttributeAggregatorStateFloat(); case INT: return new AvgAttributeAggregatorStateInt(); case LONG: return new AvgAttributeAggregatorStateLong(); case DOUBLE: return new AvgAttributeAggregatorStateDouble(); default: throw new OperationNotSupportedException("Avg not supported for " + returnType); } }; }
Example #29
Source File: MinAttributeAggregatorExecutor.java From siddhi with Apache License 2.0 | 5 votes |
/** * The initialization method for FunctionExecutor * * @param attributeExpressionExecutors are the executors of each attributes in the function * @param processingMode query processing mode * @param outputExpectsExpiredEvents is expired events sent as output * @param configReader this hold the {@link MinAttributeAggregatorExecutor} configuration reader. * @param siddhiQueryContext Siddhi query runtime context */ @Override protected StateFactory<MinAggregatorState> init(ExpressionExecutor[] attributeExpressionExecutors, ProcessingMode processingMode, boolean outputExpectsExpiredEvents, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) { if (attributeExpressionExecutors.length != 1) { throw new OperationNotSupportedException("Min aggregator has to have exactly 1 parameter, currently " + attributeExpressionExecutors.length + " parameters provided"); } boolean trackFutureStates = false; if (processingMode == ProcessingMode.SLIDE || outputExpectsExpiredEvents) { trackFutureStates = true; } returnType = attributeExpressionExecutors[0].getReturnType(); boolean finalTrackFutureStates = trackFutureStates; return new StateFactory<MinAggregatorState>() { @Override public MinAggregatorState createNewState() { switch (returnType) { case FLOAT: return new MinAttributeAggregatorStateFloat(finalTrackFutureStates); case INT: return new MinAttributeAggregatorStateInt(finalTrackFutureStates); case LONG: return new MinAttributeAggregatorStateLong(finalTrackFutureStates); case DOUBLE: return new MinAttributeAggregatorStateDouble(finalTrackFutureStates); default: throw new OperationNotSupportedException("Min not supported for " + returnType); } } }; }
Example #30
Source File: WindowedPerSnapshotOutputRateLimiter.java From siddhi with Apache License 2.0 | 5 votes |
@Override protected StateFactory<RateLimiterState> init() { this.scheduler = SchedulerParser.parse(this, siddhiQueryContext); this.scheduler.setStreamEventFactory(new StreamEventFactory(0, 0, 0)); this.scheduler.init(lockWrapper, siddhiQueryContext.getName()); return () -> new RateLimiterState(); }