• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ConstantExpressionExecutor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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(new Attribute
                ("price", Attribute.Type.FLOAT), 0, 0);
        priceVariableExpressionExecutor.setPosition(new int[]{0, SiddhiConstants.UNKNOWN_STATE, SiddhiConstants
                .OUTPUT_DATA_INDEX, 1});

        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});

        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++;
            }
        }

        AssertJUnit.assertEquals("Two events should pass through executor", 2, count);
    }
 
开发者ID:wso2,项目名称:siddhi,代码行数:34,代码来源:EventTestCase.java


示例17: 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("price", streamDefinition);
    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});

    Assert.assertEquals("Result of adding should be 20.0", 20f, addExecutor.execute(event));
}
 
开发者ID:sacjaya,项目名称:siddhi-3,代码行数:13,代码来源:EventTest.java


示例18: testConditionExpressionExecutorValidation

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Test(expected = 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("volume", streamDefinition);
    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:sacjaya,项目名称:siddhi-3,代码行数:10,代码来源:EventTest.java


示例19: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected List<Attribute> init(AbstractDefinition abstractDefinition,
                               ExpressionExecutor[] expressionExecutors,
                               ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
    String siddhiAppName = siddhiAppContext.getName();
    String modelPrefix;
    noOfFeatures = inputDefinition.getAttributeList().size();

    if (attributeExpressionExecutors.length >= (minNoOfFeatures + minNoOfParameters)) {
        if (noOfFeatures < minNoOfFeatures) {
            throw new SiddhiAppValidationException(String.format("Invalid number of feature attributes for "
                            + "streamingml:hoeffdingTreeClassifier. This Stream Processor requires at least %s "
                            + "feature attributes, but found %s feature attributes",
                    minNoOfFeatures, noOfFeatures));
        }
        if (noOfFeatures != (attributeExpressionLength - minNoOfParameters)) {
            throw new SiddhiAppValidationException(String.format("Invalid number of feature attributes for "
                            + "streamingml:hoeffdingTreeClassifier. This Stream Processor is defined with %s "
                            + "features, but found %s feature attributes",
                    noOfFeatures, (attributeExpressionLength - minNoOfParameters)));
        }
        if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
            if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.STRING) {
                modelPrefix = (String) ((ConstantExpressionExecutor)
                        attributeExpressionExecutors[0])
                        .getValue();
                // model name = user given name + siddhi app name
                modelName = siddhiAppName + "." + modelPrefix;
            } else {
                throw new SiddhiAppValidationException(
                        "Invalid parameter type found for the model.name argument, "
                                + "required " + Attribute.Type.STRING
                                + " but found " + attributeExpressionExecutors[0].
                                getReturnType().toString());
            }
        } else {
            throw new SiddhiAppValidationException("Parameter model.name must be a constant but found "
                    + attributeExpressionExecutors[0].getClass().getCanonicalName());
        }

        featureVariableExpressionExecutors = CoreUtils
                .extractAndValidateFeatures(inputDefinition, attributeExpressionExecutors,
                        (attributeExpressionLength - noOfFeatures), noOfFeatures);

        AdaptiveHoeffdingTreeModel model
                = AdaptiveHoeffdingModelsHolder.getInstance().getHoeffdingModel(modelName);

        if (!CoreUtils.isInitialized(model, (noOfFeatures + 1))) {
            throw new SiddhiAppValidationException(String.format("Model [%s] needs to initialized "
                    + "prior to be used with streamingml:hoeffdingTreeClassifier. "
                    + "Perform streamingml:updateHoeffdingTree process first.", modelName));
        }
    } else {
        throw new SiddhiAppValidationException(String.format("Invalid number of parameters for "
                        + "streamingml:hoeffdingTreeClassifier. This Stream Processor requires "
                        + "at least %s parameters, namely, model.name and at least %s feature_attributes,"
                        + " but found %s parameters",
                (minNoOfParameters + minNoOfFeatures), minNoOfFeatures, attributeExpressionExecutors.length));
    }
    //set attributes for Output Stream
    List<Attribute> attributes = new ArrayList<Attribute>();
    attributes.add(new Attribute("prediction", Attribute.Type.STRING));
    attributes.add(new Attribute("confidenceLevel", Attribute.Type.DOUBLE));
    return attributes;
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:66,代码来源:HoeffdingClassifierStreamProcessorExtension.java


示例20: init

import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; //导入依赖的package包/类
@Override
protected List<Attribute> init(AbstractDefinition abstractDefinition, ExpressionExecutor[] expressionExecutors,
                               ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
    String modelPrefix;
    noOfFeatures = inputDefinition.getAttributeList().size();

    if (attributeExpressionLength > minNoOfParameters) {
        if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
            if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.STRING) {
                modelPrefix = (String) ((ConstantExpressionExecutor)
                        attributeExpressionExecutors[0]).getValue();
                // model name = user given name + siddhi app name
                modelName = siddhiAppContext.getName() + "." + modelPrefix;
            } else {
                throw new SiddhiAppValidationException(String.format("Invalid parameter type found for the "
                                + "model.name argument, required %s, but found %s.",
                        Attribute.Type.STRING, attributeExpressionExecutors[0].getReturnType().toString()));
            }
        } else {
            throw new SiddhiAppValidationException("Parameter model.name must be a constant but found "
                    + attributeExpressionExecutors[0].getClass().getCanonicalName());
        }
    } else {
        throw new SiddhiAppValidationException(String.format("streamingML:AMRulesRegressor needs exactly "
                        + "model.name and %s feature atttributes, but found %s.",
                noOfFeatures, attributeExpressionLength));
    }
    AdaptiveModelRulesModel model = RegressorModelHolder.getInstance().getAMRulesRegressorModel(modelName);
    if (model == null || !model.isInitialized()) {
        throw new SiddhiAppValidationException(String.format("Model [%s] needs to initialized "
                + "prior to be used with streamingml:AMRulesRegressor. "
                + "Perform streamingml:updateAMRulesRegressor process first.", modelName));
    }
    if (!model.isValidStreamHeader(noOfFeatures)) {
        throw new SiddhiAppValidationException(String.format("Invalid number of parameters for "
                        + "streamingml:AMRulesRegressor. Model [%s] expects %s features, but "
                        + "the input specifies %s features.",
                this.modelName, model.getNoOfFeatures(), noOfFeatures));
    }
    if (attributeExpressionLength != ((model.getNoOfFeatures()) + minNoOfParameters)) {
        throw new SiddhiAppValidationException(String.format("Invalid number of parameters for "
                        + "streamingml:AMRulesRegressor. This Stream Processor requires  %s "
                        + "parameters, namely, model.name and %s feature_attributes, "
                        + "but found %s parameters", (minNoOfParameters + (model.getNoOfFeatures())),
                model.getNoOfFeatures(), (attributeExpressionExecutors.length - minNoOfParameters)));
    }
    featureVariableExpressionExecutors = CoreUtils.extractAndValidateFeatures(inputDefinition,
            attributeExpressionExecutors, (attributeExpressionLength - noOfFeatures), noOfFeatures);

    cepEvent = new double[noOfFeatures + 1];

    //set attributes for Output Stream
    List<Attribute> attributes = new ArrayList<>();
    attributes.add(new Attribute("prediction", Attribute.Type.DOUBLE));
    attributes.add(new Attribute("meanSquaredError", Attribute.Type.DOUBLE));
    return attributes;

}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:59,代码来源:AdaptiveModelRulesRegressorStreamProcessorExtension.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComponentDefinitionException类代码示例发布时间:2022-05-15
下一篇:
Java AmountConverter类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap