io.siddhi.core.util.config.ConfigReader Java Examples

The following examples show how to use io.siddhi.core.util.config.ConfigReader. 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: FunctionExecutor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public void initExecutor(ExpressionExecutor[] attributeExpressionExecutors,
                         ProcessingMode processingMode, ConfigReader configReader,
                         boolean groupBy, SiddhiQueryContext siddhiQueryContext) {
    this.processingMode = processingMode;
    this.configReader = configReader;
    this.siddhiQueryContext = siddhiQueryContext;
    try {
        this.attributeExpressionExecutors = attributeExpressionExecutors;
        attributeSize = attributeExpressionExecutors.length;
        InputParameterValidator.validateExpressionExecutors(this, attributeExpressionExecutors);
        StateFactory<S> stateFactory = init(attributeExpressionExecutors, configReader, this.siddhiQueryContext);
        stateHolder = this.siddhiQueryContext.generateStateHolder(this.getClass().getName(), groupBy, stateFactory);
    } catch (Throwable t) {
        throw new SiddhiAppCreationException(t.getMessage(), t);
    }
}
 
Example #2
Source File: IfThenElseFunctionExecutor.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 != 3) {
        // check whether all the arguments passed
        throw new SiddhiAppValidationException("Invalid no of arguments passed to ifThenElse() function, " +
                "required only 3, but found " + attributeExpressionExecutors.length);
    } else if (!attributeExpressionExecutors[0].getReturnType().equals(Attribute.Type.BOOL)) {
        // check whether first argument Boolean or not
        throw new SiddhiAppValidationException("Input type of if in ifThenElse function should be of " +
                "type BOOL, but found " + attributeExpressionExecutors[0].getReturnType());
    } else if (!attributeExpressionExecutors[1].getReturnType().equals(
            attributeExpressionExecutors[2].getReturnType())) {
        // check whether second and thirds argument's return type are equivalent.
        throw new SiddhiAppValidationException("Input type of then in ifThenElse function and else in " +
                "ifThenElse function should be of equivalent type. but found then type: " +
                attributeExpressionExecutors[1].getReturnType() + " and else type: " +
                attributeExpressionExecutors[2].getReturnType());
    } else {
        returnType = attributeExpressionExecutors[1].getReturnType();
    }
    return null;
}
 
Example #3
Source File: PartitionedDistributionStrategy.java    From siddhi with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the Distribution strategy with the information it will require to make decisions.
 *
 * @param streamDefinition         The stream attached to the sink this DistributionStrategy is used in
 * @param transportOptionHolder    Sink options of the sink which uses this DistributionStrategy
 * @param destinationOptionHolders The list of options under @destination of the relevant sink.
 * @param configReader             This hold the {@link PartitionedDistributionStrategy} configuration reader.
 */
@Override
public void init(StreamDefinition streamDefinition, OptionHolder transportOptionHolder,
                 OptionHolder distributionOptionHolder, List<OptionHolder> destinationOptionHolders,
                 ConfigReader configReader) {
    totalDestinationCount = destinationOptionHolders.size();
    String partitionKey = distributionOptionHolder.validateAndGetStaticValue(SiddhiConstants
            .PARTITION_KEY_FIELD_KEY);

    if (partitionKey == null || partitionKey.isEmpty()) {
        throw new SiddhiAppValidationException("PartitionKey is required for partitioned distribution " +
                "strategy.");
    }
    try {
        int partitionKeyFieldPosition = streamDefinition.getAttributePosition(partitionKey);
        partitionOption = new Option(partitionKeyFieldPosition);
    } catch (AttributeNotExistException e) {
        throw new SiddhiAppValidationException("Could not find partition key attribute", e);
    }

}
 
Example #4
Source File: DefaultFunctionExecutor.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) {
        // 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 #5
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 #6
Source File: StringSubtractFunctionExtension.java    From eagle with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #7
Source File: StringEmptyFunctionExtension.java    From eagle with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #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: JsonSinkMapper.java    From siddhi-map-json with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the mapper and the mapping configurations.
 *
 * @param streamDefinition          The stream definition
 * @param optionHolder              Option holder containing static and dynamic options
 * @param payloadTemplateBuilderMap Unmapped list of payloads for reference
 */
@Override
public void init(StreamDefinition streamDefinition, OptionHolder optionHolder,
                 Map<String, TemplateBuilder> payloadTemplateBuilderMap, ConfigReader mapperConfigReader,
                 SiddhiAppContext siddhiAppContext) {

    this.attributeNameArray = streamDefinition.getAttributeNameArray();
    this.enclosingElement = optionHolder.validateAndGetStaticValue(ENCLOSING_ELEMENT_IDENTIFIER, null);
    this.isJsonValidationEnabled = Boolean.parseBoolean(optionHolder
            .validateAndGetStaticValue(JSON_VALIDATION_IDENTIFIER, "false"));

    //if @payload() is added there must be at least 1 element in it, otherwise a SiddhiParserException raised
    if (payloadTemplateBuilderMap != null && payloadTemplateBuilderMap.size() != 1) {
        throw new SiddhiAppCreationException("Json sink-mapper does not support multiple @payload mappings, " +
                "error at the mapper of '" + streamDefinition.getId() + "'");
    }
    if (payloadTemplateBuilderMap != null &&
            payloadTemplateBuilderMap.get(payloadTemplateBuilderMap.keySet().iterator().next()).isObjectMessage()) {
        throw new SiddhiAppCreationException("Json sink-mapper does not support object @payload mappings, " +
                "error at the mapper of '" + streamDefinition.getId() + "'");
    }
}
 
Example #10
Source File: ContainsIgnoreCaseExtension.java    From eagle with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #11
Source File: LossyFrequentWindowProcessor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@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: CoalesceFunctionExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public StateFactory init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                         SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length == 0) {
        throw new SiddhiAppValidationException("Coalesce must have at least one parameter");
    }
    Attribute.Type type = attributeExpressionExecutors[0].getReturnType();
    for (ExpressionExecutor expressionExecutor : attributeExpressionExecutors) {
        if (type != expressionExecutor.getReturnType()) {
            throw new SiddhiAppValidationException("Coalesce cannot have parameters with different type");
        }
    }
    returnType = type;
    return null;
}
 
Example #13
Source File: IncrementalTimeGetTimeZone.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 == 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 #14
Source File: MinForeverAttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
/**
 * 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 MinForeverAttributeAggregatorExecutor}
 *                                     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("MinForever aggregator has to have exactly 1 parameter, " +
                "currently " + attributeExpressionExecutors.length + " parameters provided");
    }
    returnType = attributeExpressionExecutors[0].getReturnType();
    return new StateFactory<MinAggregatorState>() {
        @Override
        public MinAggregatorState createNewState() {
            switch (returnType) {
                case FLOAT:
                    return new MinForeverAttributeAggregatorStateFloat();
                case INT:
                    return new MinForeverAttributeAggregatorStateInt();
                case LONG:
                    return new MinForeverAttributeAggregatorStateLong();
                case DOUBLE:
                    return new MinForeverAttributeAggregatorStateDouble();
                default:
                    throw new OperationNotSupportedException("MinForever not supported for " + returnType);
            }
        }
    };

}
 
Example #15
Source File: SortWindowProcessor.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[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 #16
Source File: ExpressionBatchWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory<WindowState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                         ConfigReader configReader,
                                         StreamEventClonerHolder streamEventClonerHolder,
                                         boolean outputExpectsExpiredEvents, boolean findToBeExecuted,
                                         SiddhiQueryContext siddhiQueryContext) {
    //will not be called.
    return null;
}
 
Example #17
Source File: BatchingWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory<S> init(MetaStreamEvent metaStreamEvent, AbstractDefinition inputDefinition,
                               ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                               StreamEventClonerHolder streamEventClonerHolder,
                               boolean outputExpectsExpiredEvents, boolean findToBeExecuted,
                               SiddhiQueryContext siddhiQueryContext) {
    return init(attributeExpressionExecutors, configReader, streamEventClonerHolder,
            outputExpectsExpiredEvents, findToBeExecuted, siddhiQueryContext);
}
 
Example #18
Source File: CurrentTimeMillisFunctionExecutor.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 != 0) {
        throw new SiddhiAppValidationException("Invalid no of arguments passed to eventTimestamp() function, " +
                "required 0 parameters, but found " +
                attributeExpressionExecutors.length);
    }
    timestampGenerator = siddhiQueryContext.getSiddhiAppContext().getTimestampGenerator();
    return null;
}
 
Example #19
Source File: ConcatFunctionExtension.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 < 2) {
        throw new SiddhiAppValidationException("str:concat() function requires at least two arguments, " +
                "but found only " + attributeExpressionExecutors.length);
    }
    return null;
}
 
Example #20
Source File: GroupingWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@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 #21
Source File: MaxForeverAttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
/**
 * 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 MaxForeverAttributeAggregatorExecutor}
 *                                     configuration reader.
 * @param siddhiQueryContext           Siddhi query runtime context
 */
@Override
protected StateFactory<MaxAggregatorState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                                ProcessingMode processingMode,
                                                boolean outputExpectsExpiredEvents, ConfigReader configReader,
                                                SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new OperationNotSupportedException("MaxForever aggregator has to have exactly 1 parameter, " +
                "currently " +
                attributeExpressionExecutors.length + " parameters provided");
    }
    returnType = attributeExpressionExecutors[0].getReturnType();
    return new StateFactory<MaxAggregatorState>() {
        @Override
        public MaxAggregatorState createNewState() {
            switch (returnType) {
                case FLOAT:
                    return new MaxForeverAttributeAggregatorStateFloat();
                case INT:
                    return new MaxForeverAttributeAggregatorStateInt();
                case LONG:
                    return new MaxForeverAttributeAggregatorStateLong();
                case DOUBLE:
                    return new MaxForeverAttributeAggregatorStateDouble();
                default:
                    throw new OperationNotSupportedException("MaxForever not supported for " + returnType);
            }
        }
    };

}
 
Example #22
Source File: CountAttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
/**
 * 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 CountAttributeAggregatorExecutor} configuration reader.
 * @param siddhiQueryContext           Siddhi query runtime context
 */
@Override
protected StateFactory<AggregatorState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                             ProcessingMode processingMode,
                                             boolean outputExpectsExpiredEvents,
                                             ConfigReader configReader,
                                             SiddhiQueryContext siddhiQueryContext) {
    return () -> new AggregatorState();

}
 
Example #23
Source File: SlidingWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory<S> init(MetaStreamEvent metaStreamEvent,
                               AbstractDefinition inputDefinition,
                               ExpressionExecutor[] attributeExpressionExecutors,
                               ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder,
                               boolean outputExpectsExpiredEvents, boolean findToBeExecuted,
                               SiddhiQueryContext siddhiQueryContext) {
    return init(attributeExpressionExecutors, configReader, siddhiQueryContext);
}
 
Example #24
Source File: DistinctCountAttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
/**
 * 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 DistinctCountAttributeAggregatorExecutor}
 *                                     configuration reader.
 * @param siddhiQueryContext           Siddhi query runtime context
 */
@Override
protected StateFactory<AggregatorState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                             ProcessingMode processingMode,
                                             boolean outputExpectsExpiredEvents, ConfigReader configReader,
                                             SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new OperationNotSupportedException("Distinct count aggregator has to have exactly 1 parameter, " +
                "currently " + attributeExpressionExecutors.length +
                " parameters provided");
    }
    return () -> new AggregatorState();
}
 
Example #25
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;
}
 
Example #26
Source File: EventTimestampFunctionExecutor.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) {
        expectEventObject = true;
    }
    return null;
}
 
Example #27
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 #28
Source File: InMemorySource.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public StateFactory<State> init(SourceEventListener sourceEventListener, OptionHolder optionHolder,
                                String[] requestedTransportPropertyNames, ConfigReader configReader,
                                SiddhiAppContext siddhiAppContext) {
    this.sourceEventListener = sourceEventListener;
    String topic = optionHolder.validateAndGetStaticValue(TOPIC_KEY, "input inMemory source");
    this.subscriber = new InMemoryBroker.Subscriber() {
        @Override
        public void onMessage(Object event) {
            if (paused) {
                pauseLock.lock();
                try {
                    while (paused) {
                        unpaused.await();
                    }
                } catch (InterruptedException ie) {
                    Thread.currentThread().interrupt();
                } finally {
                    pauseLock.unlock();
                }
            }
            sourceEventListener.onEvent(event, null);
        }

        @Override
        public String getTopic() {
            return topic;
        }
    };
    return null;
}
 
Example #29
Source File: LengthBatchWindowProcessor.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;
    if (attributeExpressionExecutors.length >= 1) {
        if (!(attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor)) {
            throw new SiddhiAppValidationException("TimeBatch window's window.time (1st) parameter " +
                    "'window.length' should be a constant but found a dynamic parameter " +
                    attributeExpressionExecutors[0].getClass().getCanonicalName());
        }
        length = (Integer) (((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue());
    }
    if (attributeExpressionExecutors.length == 2) {
        if (!(attributeExpressionExecutors[1] instanceof ConstantExpressionExecutor)) {
            throw new SiddhiAppValidationException("TimeBatch window's window.time (2nd) parameter " +
                    "'stream.current.event' should be a constant but found a dynamic parameter " +
                    attributeExpressionExecutors[1].getClass().getCanonicalName());
        }
        isStreamCurrentEvents = (Boolean) (((ConstantExpressionExecutor)
                attributeExpressionExecutors[1]).getValue());
    }
    if (attributeExpressionExecutors.length > 2) {
        throw new SiddhiAppValidationException("LengthBatch window should have one parameter (<int> " +
                "window.length) or two parameters (<int> window.length, <bool> stream.current.event), " +
                "but found " + attributeExpressionExecutors.length + " input parameters.");
    }
    return () -> new WindowState(streamEventClonerHolder, isStreamCurrentEvents,
            outputExpectsExpiredEvents, findToBeExecuted);
}
 
Example #30
Source File: OrAttributeAggregatorExecutor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
/**
 * 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 OrAttributeAggregatorExecutor} configuration reader.
 * @param siddhiQueryContext           Siddhi query runtime context
 */
@Override
protected StateFactory<AggregatorState> init(ExpressionExecutor[] attributeExpressionExecutors,
                                             ProcessingMode processingMode,
                                             boolean outputExpectsExpiredEvents, ConfigReader configReader,
                                             SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors.length != 1) {
        throw new OperationNotSupportedException("And aggregator has to have exactly 1 parameter, currently " +
                attributeExpressionExecutors.length
                + " parameters provided");
    }
    return () -> new AggregatorState();
}