本文整理汇总了Java中com.espertech.esper.collection.UniformPair类的典型用法代码示例。如果您正苦于以下问题:Java UniformPair类的具体用法?Java UniformPair怎么用?Java UniformPair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UniformPair类属于com.espertech.esper.collection包,在下文中一共展示了UniformPair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processJoinResult
import com.espertech.esper.collection.UniformPair; //导入依赖的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);
}
示例2: handleOutputLimitFirstJoin
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
private UniformPair<EventBean[]> handleOutputLimitFirstJoin(List<UniformPair<Set<MultiKey<EventBean>>>> joinEventsSet, boolean generateSynthetic) {
for (Map<Object, EventBean[]> aGroupRepsView : groupRepsPerLevelBuf) {
aGroupRepsView.clear();
}
rstreamEventSortArrayBuf.reset();
int count;
if (prototype.getPerLevelExpression().getOptionalHavingNodes() == null) {
count = handleOutputLimitFirstJoinNoHaving(joinEventsSet, generateSynthetic, rstreamEventSortArrayBuf.getEventsPerLevel(), rstreamEventSortArrayBuf.getSortKeyPerLevel());
} else {
count = handleOutputLimitFirstJoinHaving(joinEventsSet, generateSynthetic, rstreamEventSortArrayBuf.getEventsPerLevel(), rstreamEventSortArrayBuf.getSortKeyPerLevel());
}
return generateAndSort(groupRepsPerLevelBuf, generateSynthetic, count);
}
示例3: runAssertionMaxTimeWindow
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
private void runAssertionMaxTimeWindow(EPServiceProvider epService) {
sendTimer(epService, 0);
String epl = "select irstream volume, max(price) as maxVol" +
" from " + SupportMarketDataBean.class.getName() + "#time(1 sec) " +
"output every 1 seconds";
EPStatement stmt = epService.getEPAdministrator().createEPL(epl);
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
sendEvent(epService, "SYM1", 1d);
sendEvent(epService, "SYM1", 2d);
listener.reset();
// moves all events out of the window,
sendTimer(epService, 1000); // newdata is 2 eventa, old data is the same 2 events, therefore the sum is null
UniformPair<EventBean[]> result = listener.getDataListsFlattened();
assertEquals(2, result.getFirst().length);
assertEquals(1.0, result.getFirst()[0].get("maxVol"));
assertEquals(2.0, result.getFirst()[1].get("maxVol"));
assertEquals(2, result.getSecond().length);
assertEquals(null, result.getSecond()[0].get("maxVol"));
assertEquals(null, result.getSecond()[1].get("maxVol"));
}
示例4: runAssertionMaxTimeWindow
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
private void runAssertionMaxTimeWindow(EPServiceProvider epService) {
sendTimer(epService, 0);
String epl = "select irstream max(price) as maxVol" +
" from " + SupportMarketDataBean.class.getName() + "#time(1.1 sec) " +
"output every 1 seconds";
EPStatement stmt = epService.getEPAdministrator().createEPL(epl);
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
sendEvent(epService, "SYM1", 1d);
sendEvent(epService, "SYM1", 2d);
listener.reset();
// moves all events out of the window,
sendTimer(epService, 1000); // newdata is 2 eventa, old data is the same 2 events, therefore the sum is null
UniformPair<EventBean[]> result = listener.getDataListsFlattened();
assertEquals(2, result.getFirst().length);
assertEquals(1.0, result.getFirst()[0].get("maxVol"));
assertEquals(2.0, result.getFirst()[1].get("maxVol"));
assertEquals(2, result.getSecond().length);
assertEquals(null, result.getSecond()[0].get("maxVol"));
assertEquals(1.0, result.getSecond()[1].get("maxVol"));
stmt.destroy();
}
示例5: processViewResult
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
public UniformPair<EventBean[]> processViewResult(EventBean[] newData, EventBean[] oldData, boolean isSynthesize) {
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().qResultSetProcessGroupedRowPerGroup();
}
resetEventPerGroupBufView();
Object[][] newDataMultiKey = generateGroupKeysView(newData, eventPerGroupBufView, true);
Object[][] oldDataMultiKey = generateGroupKeysView(oldData, eventPerGroupBufView, false);
EventBean[] selectOldEvents = null;
if (prototype.isSelectRStream()) {
selectOldEvents = generateOutputEventsView(eventPerGroupBufView, false, isSynthesize);
}
EventBean[] eventsPerStream = new EventBean[1];
ResultSetProcessorGroupedUtil.applyAggViewResultKeyedView(aggregationService, agentInstanceContext, newData, newDataMultiKey, oldData, oldDataMultiKey, eventsPerStream);
EventBean[] selectNewEvents = generateOutputEventsView(eventPerGroupBufView, true, isSynthesize);
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().aResultSetProcessGroupedRowPerGroup(selectNewEvents, selectOldEvents);
}
return ResultSetProcessorUtil.toPairNullIfAllNull(selectNewEvents, selectOldEvents);
}
示例6: processViewResultCodegen
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
public static void processViewResultCodegen(ResultSetProcessorRowForAllForge forge, CodegenClassScope classScope, CodegenMethodNode method, CodegenInstanceAux instance) {
CodegenMethodNode selectList = getSelectListEventsAsArrayCodegen(forge, classScope, instance);
CodegenExpression selectOld;
if (forge.isSelectRStream()) {
selectOld = localMethod(selectList, constantFalse(), REF_ISSYNTHESIZE, constantFalse());
} else {
selectOld = constantNull();
}
method.getBlock()
.declareVar(EventBean[].class, "selectOldEvents", selectOld)
.declareVar(EventBean[].class, "eventsPerStream", newArrayByLength(EventBean.class, constant(1)))
.staticMethod(ResultSetProcessorUtil.class, METHOD_APPLYAGGVIEWRESULT, REF_AGGREGATIONSVC, REF_AGENTINSTANCECONTEXT, REF_NEWDATA, REF_OLDDATA, ref("eventsPerStream"))
.declareVar(EventBean[].class, "selectNewEvents", localMethod(selectList, constantTrue(), REF_ISSYNTHESIZE, constantFalse()))
.ifCondition(and(equalsNull(ref("selectNewEvents")), equalsNull(ref("selectOldEvents"))))
.blockReturn(constantNull())
.methodReturn(newInstance(UniformPair.class, ref("selectNewEvents"), ref("selectOldEvents")));
}
示例7: assertPairGetIRAndReset
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
/**
* Asserts that exactly one insert stream event and exactly one remove stream event was received, resets the listener clearing all state and returns the received events as a pair.
*
* @return pair of insert-stream and remove-stream events
*/
public synchronized UniformPair<EventBean> assertPairGetIRAndReset() {
ScopeTestHelper.assertTrue("Listener invocation not received but expected", isInvoked);
ScopeTestHelper.assertEquals("Mismatch in the number of invocations", 1, newDataList.size());
ScopeTestHelper.assertEquals("Mismatch in the number of invocations", 1, oldDataList.size());
if (lastNewData == null) {
ScopeTestHelper.fail("No new-data events received");
}
if (lastOldData == null) {
ScopeTestHelper.fail("No old-data events received");
}
ScopeTestHelper.assertEquals("Mismatch in the number of new-data events", 1, lastNewData.length);
ScopeTestHelper.assertEquals("Mismatch in the number of old-data events", 1, lastOldData.length);
EventBean lastNew = lastNewData[0];
EventBean lastOld = lastOldData[0];
reset();
return new UniformPair<EventBean>(lastNew, lastOld);
}
示例8: output
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
private UniformPair<EventBean[]> output(boolean isSynthesize) {
// generate remaining key events
for (Map.Entry<Object, EventBean[]> entry : repsPerGroup.entrySet()) {
if (lastSeenKeys.contains(entry.getKey())) {
continue;
}
EventBean newEvent = processor.generateOutputBatchedSingle(entry.getKey(), entry.getValue(), true, isSynthesize);
if (newEvent != null) {
eventsNew.add(newEvent);
}
}
lastSeenKeys.clear();
EventBean[] newEventsArr = EventBeanUtility.toArray(eventsNew);
EventBean[] oldEventsArr = null;
if (processor.isSelectRStream()) {
oldEventsArr = EventBeanUtility.toArray(eventsOld);
}
eventsNew.clear();
eventsOld.clear();
if ((newEventsArr == null) && (oldEventsArr == null)) {
return null;
}
return new UniformPair<>(newEventsArr, oldEventsArr);
}
开发者ID:espertechinc,项目名称:esper,代码行数:26,代码来源:ResultSetProcessorAggregateGroupedOutputAllHelperImpl.java
示例9: addToChangeset
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
private static void addToChangeset(Set<MultiKey<EventBean>> newEvents, Set<MultiKey<EventBean>> oldEvents, OutputProcessViewConditionDeltaSet joinEventsSet) {
// add the incoming events to the event batches
Set<MultiKey<EventBean>> copyNew;
if (newEvents != null) {
copyNew = new LinkedHashSet<MultiKey<EventBean>>(newEvents);
} else {
copyNew = new LinkedHashSet<MultiKey<EventBean>>();
}
Set<MultiKey<EventBean>> copyOld;
if (oldEvents != null) {
copyOld = new LinkedHashSet<MultiKey<EventBean>>(oldEvents);
} else {
copyOld = new LinkedHashSet<MultiKey<EventBean>>();
}
joinEventsSet.addJoin(new UniformPair<Set<MultiKey<EventBean>>>(copyNew, copyOld));
}
示例10: processOutputLimitedView
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
public UniformPair<EventBean[]> processOutputLimitedView(List<UniformPair<EventBean[]>> viewEventsList, boolean generateSynthetic) {
if (prototype.isOutputLast()) {
return processOutputLimitedViewLast(viewEventsList, generateSynthetic);
} else {
return processOutputLimitedViewDefault(viewEventsList, generateSynthetic);
}
}
示例11: evaluate
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext) {
// Case 2 expression example:
// case p when p1 then x [when p2 then y...] [else z]
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().qExprCase(forge.getForgeRenderable());
}
Object checkResult = compareExprNode.evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
Object caseResult = null;
boolean matched = false;
for (UniformPair<ExprEvaluator> p : whenThenNodeList) {
Object whenResult = p.getFirst().evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
if (compare(checkResult, whenResult)) {
caseResult = p.getSecond().evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
matched = true;
break;
}
}
if ((!matched) && (optionalElseExprNode != null)) {
caseResult = optionalElseExprNode.evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
}
if (caseResult == null) {
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().aExprCase(null);
}
return null;
}
if ((caseResult.getClass() != forge.getEvaluationType()) && forge.isNumericResult()) {
caseResult = JavaClassHelper.coerceBoxed((Number) caseResult, forge.getEvaluationType());
}
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().aExprCase(caseResult);
}
return caseResult;
}
示例12: toPairNullIfAllNullSingle
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
/**
* NOTE: Code-generation-invoked method, method name and parameter order matters
* @param istream istream event
* @param rstream rstream event
* @return pair
*/
public static UniformPair<EventBean[]> toPairNullIfAllNullSingle(EventBean istream, EventBean rstream) {
if (istream != null) {
return new UniformPair<>(new EventBean[] {istream}, rstream == null ? null : new EventBean[] {rstream});
}
return rstream == null ? null : new UniformPair<>(null, new EventBean[] {rstream});
}
示例13: processOutputLimitedJoinDefaultCodegen
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
private static void processOutputLimitedJoinDefaultCodegen(ResultSetProcessorRowPerGroupForge forge, CodegenClassScope classScope, CodegenMethodNode method, CodegenInstanceAux instance) {
CodegenMethodNode generateGroupKeyArrayJoinTakingMap = generateGroupKeyArrayJoinTakingMapCodegen(forge, classScope, instance);
CodegenMethodNode generateOutputBatchedArrFromIterator = generateOutputBatchedArrFromIteratorCodegen(forge, classScope, instance);
ResultSetProcessorUtil.prefixCodegenNewOldEvents(method.getBlock(), forge.isSorting(), forge.isSelectRStream());
method.getBlock().declareVar(Map.class, "keysAndEvents", newInstance(HashMap.class));
{
CodegenBlock forEach = method.getBlock().forEach(UniformPair.class, "pair", REF_JOINEVENTSSET);
forEach.declareVar(Set.class, "newData", cast(Set.class, exprDotMethod(ref("pair"), "getFirst")))
.declareVar(Set.class, "oldData", cast(Set.class, exprDotMethod(ref("pair"), "getSecond")));
if (forge.isUnidirectional()) {
forEach.exprDotMethod(ref("this"), "clear");
}
forEach.declareVar(Object[].class, "newDataMultiKey", localMethod(generateGroupKeyArrayJoinTakingMap, ref("newData"), ref("keysAndEvents"), constantTrue()))
.declareVar(Object[].class, "oldDataMultiKey", localMethod(generateGroupKeyArrayJoinTakingMap, ref("oldData"), ref("keysAndEvents"), constantFalse()));
if (forge.isSelectRStream()) {
forEach.localMethod(generateOutputBatchedArrFromIterator, constantTrue(), exprDotMethodChain(ref("keysAndEvents")).add("entrySet").add("iterator"), constantFalse(), REF_ISSYNTHESIZE, ref("oldEvents"), ref("oldEventsSortKey"));
}
forEach.staticMethod(ResultSetProcessorGroupedUtil.class, METHOD_APPLYAGGJOINRESULTKEYEDJOIN, REF_AGGREGATIONSVC, REF_AGENTINSTANCECONTEXT, ref("newData"), ref("newDataMultiKey"), ref("oldData"), ref("oldDataMultiKey"))
.localMethod(generateOutputBatchedArrFromIterator, constantTrue(), exprDotMethodChain(ref("keysAndEvents")).add("entrySet").add("iterator"), constantTrue(), REF_ISSYNTHESIZE, ref("newEvents"), ref("newEventsSortKey"))
.exprDotMethod(ref("keysAndEvents"), "clear");
}
ResultSetProcessorUtil.finalizeOutputMaySortMayRStreamCodegen(method.getBlock(), ref("newEvents"), ref("newEventsSortKey"), ref("oldEvents"), ref("oldEventsSortKey"), forge.isSelectRStream(), forge.isSorting());
}
示例14: processOutputLimitedJoinDefaultCodegen
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
private static void processOutputLimitedJoinDefaultCodegen(ResultSetProcessorRowForAllForge forge, CodegenClassScope classScope, CodegenMethodNode method, CodegenInstanceAux instance) {
CodegenMethodNode getSelectListEventAddList = getSelectListEventsAddListCodegen(forge, classScope, instance);
CodegenMethodNode getSelectListEventAsArray = getSelectListEventsAsArrayCodegen(forge, classScope, instance);
ResultSetProcessorUtil.prefixCodegenNewOldEvents(method.getBlock(), forge.isSorting(), forge.isSelectRStream());
{
CodegenBlock forEach = method.getBlock().forEach(UniformPair.class, "pair", REF_JOINEVENTSSET);
if (forge.isUnidirectional()) {
forEach.exprDotMethod(ref("this"), "clear");
}
if (forge.isSelectRStream()) {
forEach.localMethod(getSelectListEventAddList, constantFalse(), REF_ISSYNTHESIZE, ref("oldEvents"));
if (forge.isSorting()) {
forEach.exprDotMethod(ref("oldEventsSortKey"), "add", exprDotMethod(REF_ORDERBYPROCESSOR, "getSortKey", constantNull(), constantFalse(), REF_AGENTINSTANCECONTEXT));
}
}
forEach.staticMethod(ResultSetProcessorUtil.class, METHOD_APPLYAGGJOINRESULT, REF_AGGREGATIONSVC, REF_AGENTINSTANCECONTEXT, cast(Set.class, exprDotMethod(ref("pair"), "getFirst")), cast(Set.class, exprDotMethod(ref("pair"), "getSecond")));
forEach.localMethod(getSelectListEventAddList, constantTrue(), REF_ISSYNTHESIZE, ref("newEvents"));
if (forge.isSorting()) {
forEach.exprDotMethod(ref("newEventsSortKey"), "add", exprDotMethod(REF_ORDERBYPROCESSOR, "getSortKey", constantNull(), constantTrue(), REF_AGENTINSTANCECONTEXT));
}
forEach.blockEnd();
}
CodegenBlock ifEmpty = method.getBlock().ifCondition(not(exprDotMethod(REF_JOINEVENTSSET, "isEmpty")));
ResultSetProcessorUtil.finalizeOutputMaySortMayRStreamCodegen(ifEmpty, ref("newEvents"), ref("newEventsSortKey"), ref("oldEvents"), ref("oldEventsSortKey"), forge.isSelectRStream(), forge.isSorting());
method.getBlock().declareVar(EventBean[].class, "newEventsArr", localMethod(getSelectListEventAsArray, constantTrue(), REF_ISSYNTHESIZE, constantFalse()))
.declareVar(EventBean[].class, "oldEventsArr", forge.isSelectRStream() ? localMethod(getSelectListEventAsArray, constantFalse(), REF_ISSYNTHESIZE, constantFalse()) : constantNull())
.methodReturn(staticMethod(ResultSetProcessorUtil.class, METHOD_TOPAIRNULLIFALLNULL, ref("newEventsArr"), ref("oldEventsArr")));
}
示例15: processOutputLimitedJoin
import com.espertech.esper.collection.UniformPair; //导入依赖的package包/类
public UniformPair<EventBean[]> processOutputLimitedJoin(List<UniformPair<Set<MultiKey<EventBean>>>> joinEventsSet, boolean generateSynthetic) {
OutputLimitLimitType outputLimitLimitType = prototype.getOutputLimitSpec().getDisplayLimit();
if (outputLimitLimitType == OutputLimitLimitType.DEFAULT) {
return processOutputLimitedJoinDefault(joinEventsSet, generateSynthetic);
} else if (outputLimitLimitType == OutputLimitLimitType.ALL) {
return processOutputLimitedJoinAll(joinEventsSet, generateSynthetic);
} else if (outputLimitLimitType == OutputLimitLimitType.FIRST) {
return processOutputLimitedJoinFirst(joinEventsSet, generateSynthetic);
} else if (outputLimitLimitType == OutputLimitLimitType.LAST) {
return processOutputLimitedJoinLast(joinEventsSet, generateSynthetic);
} else {
throw new IllegalStateException("Unrecognized output limit " + outputLimitLimitType);
}
}