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


Java ExpressionExecutor.execute方法代码示例

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


在下文中一共展示了ExpressionExecutor.execute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAggregateSelectionEventChunk

import org.wso2.siddhi.core.executor.ExpressionExecutor; //导入方法依赖的package包/类
private ComplexEventChunk<StreamEvent> createAggregateSelectionEventChunk(
        ComplexEventChunk<StreamEvent> complexEventChunkToHoldMatches,
        List<ExpressionExecutor> outputExpressionExecutors) {
    ComplexEventChunk<StreamEvent> aggregateSelectionComplexEventChunk = new ComplexEventChunk<>(true);
    StreamEvent resetEvent = streamEventPoolForTableMeta.borrowEvent();
    resetEvent.setType(ComplexEvent.Type.RESET);

    while (complexEventChunkToHoldMatches.hasNext()) {
        StreamEvent streamEvent = complexEventChunkToHoldMatches.next();
        StreamEvent newStreamEvent = streamEventPoolForAggregateMeta.borrowEvent();
        Object outputData[] = new Object[newStreamEvent.getOutputData().length];
        for (int i = 0; i < outputExpressionExecutors.size(); i++) {
            outputData[i] = outputExpressionExecutors.get(i).execute(streamEvent);
        }
        newStreamEvent.setTimestamp(streamEvent.getTimestamp());
        newStreamEvent.setOutputData(outputData);
        aggregateSelectionComplexEventChunk.add(newStreamEvent);
    }

    for (ExpressionExecutor expressionExecutor : outputExpressionExecutors) {
        expressionExecutor.execute(resetEvent);
    }

    return aggregateSelectionComplexEventChunk;
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:26,代码来源:IncrementalAggregateCompileCondition.java

示例2: testConditionExpressionExecutors

import org.wso2.siddhi.core.executor.ExpressionExecutor; //导入方法依赖的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

示例3: cleanBaseIncrementalValueStore

import org.wso2.siddhi.core.executor.ExpressionExecutor; //导入方法依赖的package包/类
private void cleanBaseIncrementalValueStore(long startTimeOfNewAggregates,
                                            BaseIncrementalValueStore baseIncrementalValueStore) {
    baseIncrementalValueStore.clearValues();
    baseIncrementalValueStore.setTimestamp(startTimeOfNewAggregates);
    baseIncrementalValueStore.setProcessed(false);
    for (ExpressionExecutor expressionExecutor : baseIncrementalValueStore.getExpressionExecutors()) {
        expressionExecutor.execute(resetEvent);
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:10,代码来源:IncrementalExecutor.java

示例4: process

import org.wso2.siddhi.core.executor.ExpressionExecutor; //导入方法依赖的package包/类
@Override
public void process(ComplexEventChunk complexEventChunk) {
    ComplexEventChunk<StreamEvent> streamEventChunk =
            new ComplexEventChunk<>(complexEventChunk.isBatch());
    try {
        int noOfEvents = 0;
        if (latencyTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
            latencyTrackerInsert.markIn();
        }
        while (complexEventChunk.hasNext()) {
            ComplexEvent complexEvent = complexEventChunk.next();
            StreamEvent borrowedEvent = streamEventPool.borrowEvent();
            for (int i = 0; i < incomingExpressionExecutors.size(); i++) {
                ExpressionExecutor expressionExecutor = incomingExpressionExecutors.get(i);
                Object outputData = expressionExecutor.execute(complexEvent);
                if (expressionExecutor instanceof IncrementalUnixTimeFunctionExecutor && outputData == null) {
                    throw new SiddhiAppRuntimeException("Cannot retrieve the timestamp of event");
                }
                borrowedEvent.setOutputData(outputData, i);
            }
            streamEventChunk.add(borrowedEvent);
            noOfEvents++;
        }
        incrementalExecutor.execute(streamEventChunk);
        if (throughputTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
            throughputTrackerInsert.eventsIn(noOfEvents);
        }
    } finally {
        if (latencyTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
            latencyTrackerInsert.markOut();
        }
    }

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

示例5: testConditionExpressionExecutors

import org.wso2.siddhi.core.executor.ExpressionExecutor; //导入方法依赖的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

示例6: compare

import org.wso2.siddhi.core.executor.ExpressionExecutor; //导入方法依赖的package包/类
@Override
public int compare(ComplexEvent complexEvent1, ComplexEvent complexEvent2) {
    if (groupByExecutors != null) {
        for (int i = 0, groupByExecutorsLength = groupByExecutors.length; i < groupByExecutorsLength; i++) {
            ExpressionExecutor executor = groupByExecutors[i];
            boolean isAscending = isAscendingArray[i];
            Object value1 = executor.execute(complexEvent1);
            Object value2 = executor.execute(complexEvent2);
            if (value1 != null && value2 != null) {
                int results = 0;
                Attribute.Type type = executor.getReturnType();
                switch (type) {
                    case STRING:
                        results = ((String) value1).compareTo(((String) value2));
                        break;
                    case INT:
                        results = ((Integer) value1).compareTo(((Integer) value2));
                        break;
                    case LONG:
                        results = ((Long) value1).compareTo(((Long) value2));
                        break;
                    case FLOAT:
                        results = ((Float) value1).compareTo(((Float) value2));
                        break;
                    case DOUBLE:
                        results = ((Double) value1).compareTo(((Double) value2));
                        break;
                    case BOOL:
                        results = ((Boolean) value1).compareTo(((Boolean) value2));
                        break;
                    case OBJECT:
                        int hashDiff = value1.hashCode() - value2.hashCode();
                        if (hashDiff < 0) {
                            results = -1;
                        } else if (hashDiff > 0) {
                            results = 1;
                        }
                }
                if (!isAscending) {
                    results = results * -1;
                }
                if (results != 0) {
                    return results;
                }
            } else if (value1 != null) {
                return -1;
            } else if (value2 != null) {
                return 1;
            }
        }
        return 0;
    } else {
        return 0;
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:56,代码来源:OrderByEventComparator.java


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