当前位置: 首页>>代码示例>>Java>>正文


Java ConstantExpressionExecutor类代码示例

本文整理汇总了Java中org.wso2.siddhi.core.executor.ConstantExpressionExecutor的典型用法代码示例。如果您正苦于以下问题:Java ConstantExpressionExecutor类的具体用法?Java ConstantExpressionExecutor怎么用?Java ConstantExpressionExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConstantExpressionExecutor类属于org.wso2.siddhi.core.executor包,在下文中一共展示了ConstantExpressionExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    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);
    currentBucketId = 1;
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:24,代码来源:LossyFrequentWindowProcessor.java

示例2: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors,
                    ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
    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();
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:24,代码来源:DefaultFunctionExecutor.java

示例3: testExpressionExecutors

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Test
    public void testExpressionExecutors() {
//        StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute
// .Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);

        VariableExpressionExecutor priceVariableExpressionExecutor = new VariableExpressionExecutor(new Attribute
                ("price", Attribute.Type.FLOAT), 0, 0);
        priceVariableExpressionExecutor.setPosition(new int[]{0, SiddhiConstants.UNKNOWN_STATE, SiddhiConstants
                .OUTPUT_DATA_INDEX, 1});

        ExpressionExecutor addExecutor = new AddExpressionExecutorFloat(new ConstantExpressionExecutor(10f, Attribute
                .Type.FLOAT), priceVariableExpressionExecutor);

        StreamEvent event = new StreamEvent(0, 0, 3);
        event.setOutputData(new Object[]{"WSO2", 10f, 5});

        AssertJUnit.assertEquals("Result of adding should be 20.0", 20f, addExecutor.execute(event));
    }
 
开发者ID:wso2,项目名称:siddhi,代码行数:19,代码来源:EventTestCase.java

示例4: testConditionExpressionExecutorValidation

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Test(expectedExceptions = OperationNotSupportedException.class)
    public void testConditionExpressionExecutorValidation() {
//        StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute
// .Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);

        VariableExpressionExecutor volumeVariableExpressionExecutor = new VariableExpressionExecutor(new Attribute
                ("volume", Attribute.Type.INT), 0, 0);
        volumeVariableExpressionExecutor.setPosition(new int[]{0, SiddhiConstants.UNKNOWN_STATE, SiddhiConstants
                .OUTPUT_DATA_INDEX, 2});

        ConstantExpressionExecutor constantExpressionExecutor = new ConstantExpressionExecutor(10f, Attribute.Type
                .FLOAT);
        ExpressionExecutor compareGreaterThanExecutor = new GreaterThanCompareConditionExpressionExecutorIntInt(new
                ConstantExpressionExecutor(10, Attribute.Type.INT), volumeVariableExpressionExecutor);
        ExpressionExecutor andExecutor = new AndConditionExpressionExecutor(constantExpressionExecutor,
                compareGreaterThanExecutor);
    }
 
开发者ID:wso2,项目名称:siddhi,代码行数:18,代码来源:EventTestCase.java

示例5: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
public void init(List<ExpressionExecutor> attributeExpressionExecutors, SiddhiContext siddhiContext) {
    if (attributeSize != 2) {
        throw new OperationNotSupportedException("IsMatch has to have 2 expressions regex and the attribute, " +
                "currently " + attributeSize + " expressions provided");
    }
    ExpressionExecutor regexExecutor = attributeExpressionExecutors.get(0);
    if (regexExecutor.getReturnType() != Attribute.Type.STRING &&
            regexExecutor instanceof ConstantExpressionExecutor) {
        throw new OperationNotSupportedException("IsMatch expects regex string input expression but found " +
                regexExecutor.getReturnType());
    }
    expressionExecutor = attributeExpressionExecutors.get(1);

    pattern = Pattern.compile((String) regexExecutor.execute(null));

}
 
开发者ID:sacjaya,项目名称:siddhi-3,代码行数:18,代码来源:IsMatchFunctionExecutor.java

示例6: testConditionExpressionExecutors

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Test
public void testConditionExpressionExecutors() {
    StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);

    VariableExpressionExecutor priceVariableExpressionExecutor = new VariableExpressionExecutor("price", streamDefinition);
    VariableExpressionExecutor volumeVariableExpressionExecutor = new VariableExpressionExecutor("volume", streamDefinition);
    ExpressionExecutor compareLessThanExecutor = new LessThanCompareConditionExpressionExecutorFloatFloat(new ConstantExpressionExecutor(10f, Attribute.Type.FLOAT), priceVariableExpressionExecutor);
    ExpressionExecutor compareGreaterThanExecutor = new GreaterThanCompareConditionExpressionExecutorIntInt(new ConstantExpressionExecutor(10, Attribute.Type.INT), volumeVariableExpressionExecutor);
    ExpressionExecutor andExecutor = new AndConditionExpressionExecutor(compareLessThanExecutor, compareGreaterThanExecutor);

    int count = 0;
    for (int i = 0; i < 3; i++) {
        StreamEvent event = new StreamEvent(0, 0, 3);
        event.setOutputData(new Object[]{"WSO2", i * 11f, 5});
        if ((Boolean) andExecutor.execute(event)) {
            count++;
        }
    }

    Assert.assertEquals("Two events should pass through executor", 2, count);
}
 
开发者ID:sacjaya,项目名称:siddhi-3,代码行数:22,代码来源:EventTest.java

示例7: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    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];
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:11,代码来源:FrequentWindowProcessor.java

示例8: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    this.siddhiAppContext = siddhiAppContext;
    this.expiredEventChunk = new ComplexEventChunk<StreamEvent>(false);
    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");
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:28,代码来源:TimeWindowProcessor.java

示例9: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    expiredEventChunk = new ComplexEventChunk<StreamEvent>(false);
    if (attributeExpressionExecutors.length == 1) {
        length = (Integer) ((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue();
    } else {
        throw new SiddhiAppValidationException("Length window should only have one parameter (<int> " +
                "windowLength), but found " + attributeExpressionExecutors.length + " input attributes");
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:12,代码来源:LengthWindowProcessor.java

示例10: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    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});
        }
    }

}
 
开发者ID:wso2,项目名称:siddhi,代码行数:41,代码来源:SortWindowProcessor.java

示例11: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    this.outputExpectsExpiredEvents = outputExpectsExpiredEvents;
    this.siddhiAppContext = siddhiAppContext;
    if (outputExpectsExpiredEvents) {
        expiredEventChunk = new ComplexEventChunk<StreamEvent>(false);
    }
    if (attributeExpressionExecutors.length == 1) {
        length = (Integer) (((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue());
    } else {
        throw new SiddhiAppValidationException("Length batch window should only have one parameter (<int> " +
                "windowLength), but found " + attributeExpressionExecutors.length + " input attributes");
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:16,代码来源:LengthBatchWindowProcessor.java

示例12: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    this.siddhiAppContext = siddhiAppContext;
    expiredEventChunk = new ComplexEventChunk<StreamEvent>(false);
    if (attributeExpressionExecutors.length == 2) {
        length = (Integer) ((ConstantExpressionExecutor) attributeExpressionExecutors[1]).getValue();
        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("TimeLength window's first parameter attribute should " +
                        "be either int or long, but found " + attributeExpressionExecutors[0].getReturnType());
            }
        } else {
            throw new SiddhiAppValidationException("TimeLength window should have constant parameter " +
                    "attributes but found a dynamic attribute " + attributeExpressionExecutors[0].getClass()
                    .getCanonicalName());
        }
    } else {
        throw new SiddhiAppValidationException("TimeLength window should only have two parameters (<int> " +
                "windowTime,<int> windowLength), but found " + attributeExpressionExecutors.length + " input " +
                "attributes");
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:31,代码来源:TimeLengthWindowProcessor.java

示例13: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    this.siddhiAppContext = siddhiAppContext;
    if (attributeExpressionExecutors != null) {
        cronString = (String) (((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue());
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:9,代码来源:CronWindowProcessor.java

示例14: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean
        outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
    this.expiredEventChunk = new ComplexEventChunk<StreamEvent>(false);
    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");
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:28,代码来源:ExternalTimeWindowProcessor.java

示例15: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader,
                    SiddhiAppContext siddhiAppContext) {
    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");
        }
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:33,代码来源:CastFunctionExecutor.java


注:本文中的org.wso2.siddhi.core.executor.ConstantExpressionExecutor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。