本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例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;
}
}