本文整理汇总了Java中com.espertech.esper.client.EventBean类的典型用法代码示例。如果您正苦于以下问题:Java EventBean类的具体用法?Java EventBean怎么用?Java EventBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventBean类属于com.espertech.esper.client包,在下文中一共展示了EventBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
@Override
public void update(EventBean[] newEvents, EventBean[] oldEvents) {
if (newEvents != null) {
Map<String, Object> statisticEvent = (Map<String, Object>) newEvents[0].getUnderlying();
String alertTemplate = alarm.getAlertTemplate();
String message = TextUtils.replaceStrVar(statisticEvent, alertTemplate);
String startTime = statisticEvent.containsKey("start_time") ? DateUtils.getDateTime(Long.parseLong(statisticEvent.get("start_time").toString())) : DateUtils.getDateTime(System.currentTimeMillis());
String endTime = statisticEvent.containsKey("end_time") ? DateUtils.getDateTime(Long.parseLong(statisticEvent.get("end_time").toString())) : DateUtils.getDateTime(System.currentTimeMillis());
System.out.println(message);
if(alarm.getAlertType() == 1) {
// this.smsClient.send(alert.getPhone(), message);
DBUtils.insertAlarmRecord(alarmEplId, eplId, eplName, message, startTime, endTime);
} else {
}
}
}
示例2: main
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
@SuppressWarnings("Convert2Lambda")
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<String> dataStream = streamExecutionEnvironment.readTextFile("file:///tmp/flink-esper-input");
EsperStream<String> esperStream = Esper.pattern(dataStream, "select bytes from String");
DataStream<String> result = esperStream.select(new EsperSelectFunction<String>() {
private static final long serialVersionUID = 7093943872082195786L;
@Override
public String select(EventBean eventBean) throws Exception {
return new String((byte[]) eventBean.get("bytes"));
}
});
result.writeAsText("file:///tmp/flink-esper-output");
streamExecutionEnvironment.execute("Simple Flink Esper Example");
}
示例3: evaluateEnumMethod
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public Object evaluateEnumMethod(EventBean[] eventsLambda, Collection enumcoll, boolean isNewData, ExprEvaluatorContext context) {
if (enumcoll.isEmpty()) {
return Collections.emptyMap();
}
Map map = new HashMap();
ObjectArrayEventBean resultEvent = new ObjectArrayEventBean(new Object[1], forge.resultEventType);
eventsLambda[forge.streamNumLambda] = resultEvent;
Object[] props = resultEvent.getProperties();
Collection<Object> values = (Collection<Object>) enumcoll;
for (Object next : values) {
props[0] = next;
Object key = innerExpression.evaluate(eventsLambda, isNewData, context);
Object value = secondExpression.evaluate(eventsLambda, isNewData, context);
map.put(key, value);
}
return map;
}
示例4: getValueCodegen
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public void getValueCodegen(AggregationAccessorForgeGetCodegenContext context) {
CodegenMember eventToPublic = context.getClassScope().makeAddMember(TableMetadataInternalEventToPublic.class, tableMetadata.getEventToPublic());
AggregationStateSortedForge sorted = (AggregationStateSortedForge) context.getAccessStateForge();
CodegenExpression size = sorted.sizeCodegen(context.getColumn());
CodegenExpression iterator = max ? sorted.getReverseIteratorCodegen(context.getColumn()) : sorted.iteratorCodegen(context.getColumn());
context.getMethod().getBlock().ifCondition(equalsIdentity(size, constant(0))).blockReturn(constantNull())
.declareVar(JavaClassHelper.getArrayType(componentType), "array", newArrayByLength(componentType, size))
.declareVar(int.class, "count", constant(0))
.declareVar(Iterator.class, "it", iterator)
.whileLoop(exprDotMethod(ref("it"), "hasNext"))
.declareVar(EventBean.class, "bean", cast(EventBean.class, exprDotMethod(ref("it"), "next")))
.assignArrayElement(ref("array"), ref("count"), exprDotMethod(member(eventToPublic.getMemberId()), "convertToUnd", ref("bean"), REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT))
.increment("count")
.blockEnd()
.methodReturn(ref("array"));
}
示例5: testFlatten
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public void testFlatten() {
// test many arrays
EventBean[] testEvents = makeEventArray(new String[]{"a1", "a2", "b1", "b2", "b3", "c1", "c2"});
ArrayDeque<EventBean[]> eventVector = new ArrayDeque<EventBean[]>();
eventVector.add(new EventBean[]{testEvents[0], testEvents[1]});
eventVector.add(new EventBean[]{testEvents[2]});
eventVector.add(new EventBean[]{testEvents[3], testEvents[4], testEvents[5]});
eventVector.add(new EventBean[]{testEvents[6]});
EventBean[] events = EventBeanUtility.flatten(eventVector);
assertEquals(7, events.length);
for (int i = 0; i < testEvents.length; i++) {
assertEquals(events[i], testEvents[i]);
}
// test just one array
eventVector.clear();
eventVector.add(new EventBean[]{testEvents[2]});
events = EventBeanUtility.flatten(eventVector);
assertEquals(events[0], testEvents[2]);
// test empty vector
eventVector.clear();
events = EventBeanUtility.flatten(eventVector);
assertNull(events);
}
示例6: assertEvents
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
private void assertEvents(SupportUpdateListener listener, String symbolOld, Long countAllOld, Long countDistVolOld, Long countVolOld,
String symbolNew, Long countAllNew, Long countDistVolNew, Long countVolNew) {
EventBean[] oldData = listener.getLastOldData();
EventBean[] newData = listener.getLastNewData();
assertEquals(1, oldData.length);
assertEquals(1, newData.length);
assertEquals(symbolOld, oldData[0].get("symbol"));
assertEquals(countAllOld, oldData[0].get("countAll"));
assertEquals(countDistVolOld, oldData[0].get("countDistVol"));
assertEquals(countVolOld, oldData[0].get("countVol"));
assertEquals(symbolNew, newData[0].get("symbol"));
assertEquals(countAllNew, newData[0].get("countAll"));
assertEquals(countDistVolNew, newData[0].get("countDistVol"));
assertEquals(countVolNew, newData[0].get("countVol"));
listener.reset();
assertFalse(listener.isInvoked());
}
示例7: processJoinResult
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public UniformPair<EventBean[]> processJoinResult(Set<MultiKey<EventBean>> newEvents, Set<MultiKey<EventBean>> oldEvents, boolean isSynthesize) {
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().qResultSetProcessGroupedRowPerEvent();
}
// Generate group-by keys for all events
Object[] newDataGroupByKeys = generateGroupKeyArrayJoin(newEvents, true);
Object[] oldDataGroupByKeys = generateGroupKeyArrayJoin(oldEvents, false);
// generate old events
if (prototype.isUnidirectional()) {
this.clear();
}
ResultSetProcessorGroupedUtil.applyAggJoinResultKeyedJoin(aggregationService, agentInstanceContext, newEvents, newDataGroupByKeys, oldEvents, oldDataGroupByKeys);
EventBean[] selectOldEvents = null;
if (prototype.isSelectRStream()) {
selectOldEvents = generateOutputEventsJoin(oldEvents, oldDataGroupByKeys, false, isSynthesize);
}
EventBean[] selectNewEvents = generateOutputEventsJoin(newEvents, newDataGroupByKeys, true, isSynthesize);
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().aResultSetProcessGroupedRowPerEvent(selectNewEvents, selectOldEvents);
}
return ResultSetProcessorUtil.toPairNullIfAllNull(selectNewEvents, selectOldEvents);
}
示例8: remove
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public void remove(EventBean theEvent, ExprEvaluatorContext exprEvaluatorContext) {
MultiKeyUntyped key = getMultiKey(theEvent);
Set<EventBean> events = propertyIndex.get(key);
if (events == null) {
return;
}
if (!events.remove(theEvent)) {
// Not an error, its possible that an old-data event is artificial (such as for statistics) and
// thus did not correspond to a new-data event raised earlier.
return;
}
if (events.isEmpty()) {
propertyIndex.remove(key);
}
}
示例9: tryOrAndNot
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
private void tryOrAndNot(EPServiceProvider epService, String pattern) {
String expression =
"select * " +
"from pattern [" + pattern + "]";
EPStatement statement = epService.getEPAdministrator().createEPL(expression);
SupportUpdateListener listener = new SupportUpdateListener();
statement.addListener(listener);
Object eventA1 = new SupportBean_A("A1");
epService.getEPRuntime().sendEvent(eventA1);
EventBean theEvent = listener.assertOneGetNewAndReset();
assertEquals(eventA1, theEvent.get("a"));
assertNull(theEvent.get("b"));
Object eventB1 = new SupportBean_B("B1");
epService.getEPRuntime().sendEvent(eventB1);
theEvent = listener.assertOneGetNewAndReset();
assertEquals(eventA1, theEvent.get("a"));
assertEquals(eventB1, theEvent.get("b"));
statement.destroy();
}
示例10: getExprEvaluator
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public ExprEvaluator getExprEvaluator() {
if (isAlwaysFalse) {
return new ExprEvaluator() {
public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) {
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().qExprBetween(parent);
InstrumentationHelper.get().aExprBetween(false);
}
return false;
}
};
}
ExprNode[] nodes = parent.getChildNodes();
return new ExprBetweenNodeForgeEval(this, nodes[0].getForge().getExprEvaluator(), nodes[1].getForge().getExprEvaluator(), nodes[2].getForge().getExprEvaluator());
}
示例11: getDeclaredExpressionLastValue
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public ExpressionResultCacheEntryEventBeanArrayAndObj getDeclaredExpressionLastValue(Object node, EventBean[] eventsPerStream) {
SoftReference<RollingTwoValueBuffer<EventBean[], Object>> cacheRef = cache.get(node);
if (cacheRef == null) {
return null;
}
RollingTwoValueBuffer<EventBean[], Object> entry = cacheRef.get();
if (entry == null) {
return null;
}
for (int i = 0; i < entry.getBufferA().length; i++) {
EventBean[] key = entry.getBufferA()[i];
if (key != null && EventBeanUtility.compareEventReferences(key, eventsPerStream)) {
resultCacheEntry.setReference(key);
resultCacheEntry.setResult(entry.getBufferB()[i]);
return resultCacheEntry;
}
}
return null;
}
示例12: applyAggViewResult
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
/**
* NOTE: Code-generation-invoked method, method name and parameter order matters
*
* @param aggregationService aggregations
* @param exprEvaluatorContext ctx
* @param newData istream
* @param oldData rstream
* @param eventsPerStream buf
*/
public static void applyAggViewResult(AggregationService aggregationService, ExprEvaluatorContext exprEvaluatorContext, EventBean[] newData, EventBean[] oldData, EventBean[] eventsPerStream) {
if (newData != null) {
// apply new data to aggregates
for (int i = 0; i < newData.length; i++) {
eventsPerStream[0] = newData[i];
aggregationService.applyEnter(eventsPerStream, null, exprEvaluatorContext);
}
}
if (oldData != null) {
// apply old data to aggregates
for (int i = 0; i < oldData.length; i++) {
eventsPerStream[0] = oldData[i];
aggregationService.applyLeave(eventsPerStream, null, exprEvaluatorContext);
}
}
}
示例13: evaluateEnumMethod
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public Object evaluateEnumMethod(EventBean[] eventsLambda, Collection enumcoll, boolean isNewData, ExprEvaluatorContext context) {
double sum = 0d;
int count = 0;
Collection<EventBean> beans = (Collection<EventBean>) enumcoll;
for (EventBean next : beans) {
eventsLambda[forge.streamNumLambda] = next;
Number num = (Number) innerExpression.evaluate(eventsLambda, isNewData, context);
if (num == null) {
continue;
}
count++;
sum += num.doubleValue();
}
if (count == 0) {
return null;
}
return sum / count;
}
示例14: getValueCodegen
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
public void getValueCodegen(AggregationAccessorForgeGetCodegenContext context) {
AggregationStateSortedForge sorted = (AggregationStateSortedForge) context.getAccessStateForge();
CodegenExpression size = sorted.sizeCodegen(context.getColumn());
CodegenExpression iterator = max ? sorted.getReverseIteratorCodegen(context.getColumn()) : sorted.iteratorCodegen(context.getColumn());
context.getMethod().getBlock().ifCondition(equalsIdentity(size, constant(0))).blockReturn(constantNull())
.declareVar(JavaClassHelper.getArrayType(componentType), "array", newArrayByLength(componentType, size))
.declareVar(int.class, "count", constant(0))
.declareVar(Iterator.class, "it", iterator)
.whileLoop(exprDotMethod(ref("it"), "hasNext"))
.declareVar(EventBean.class, "bean", cast(EventBean.class, exprDotMethod(ref("it"), "next")))
.assignArrayElement(ref("array"), ref("count"), cast(componentType, exprDotUnderlying(ref("bean"))))
.increment("count")
.blockEnd()
.methodReturn(ref("array"));
}
示例15: update
import com.espertech.esper.client.EventBean; //导入依赖的package包/类
@Override
public void update(EventBean[] newEvents, EventBean[] oldEvents) {
if (newEvents != null) {
EventType eventType = newEvents[0].getEventType();
String outputStreamName = eventType.getName();
Map<String, Object> statisticEvent = (Map<String, Object>) newEvents[0].getUnderlying();
if(epl.isAlarm()) collector.emit(new Values(outputStreamName, statisticEvent));
DBUtils.insertTriggerRecord(this.epl.getId(), this.epl.getEplName(), statisticEvent);
}
}