本文整理汇总了Java中com.espertech.esper.epl.spec.MatchRecognizeDefineItem类的典型用法代码示例。如果您正苦于以下问题:Java MatchRecognizeDefineItem类的具体用法?Java MatchRecognizeDefineItem怎么用?Java MatchRecognizeDefineItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MatchRecognizeDefineItem类属于com.espertech.esper.epl.spec包,在下文中一共展示了MatchRecognizeDefineItem类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildDefineStreamTypeServiceDefine
import com.espertech.esper.epl.spec.MatchRecognizeDefineItem; //导入依赖的package包/类
public static StreamTypeService buildDefineStreamTypeServiceDefine(StatementContext statementContext,
LinkedHashMap<String, Pair<Integer, Boolean>> variableStreams,
MatchRecognizeDefineItem defineItem,
Map<String, Set<String>> visibilityByIdentifier,
EventType parentViewType)
throws ExprValidationException {
if (!variableStreams.containsKey(defineItem.getIdentifier())) {
throw new ExprValidationException("Variable '" + defineItem.getIdentifier() + "' does not occur in pattern");
}
String[] streamNamesDefine = new String[variableStreams.size() + 1];
EventType[] typesDefine = new EventType[variableStreams.size() + 1];
boolean[] isIStreamOnly = new boolean[variableStreams.size() + 1];
Arrays.fill(isIStreamOnly, true);
int streamNumDefine = variableStreams.get(defineItem.getIdentifier()).getFirst();
streamNamesDefine[streamNumDefine] = defineItem.getIdentifier();
typesDefine[streamNumDefine] = parentViewType;
// add visible single-value
Set<String> visibles = visibilityByIdentifier.get(defineItem.getIdentifier());
boolean hasVisibleMultimatch = false;
if (visibles != null) {
for (String visible : visibles) {
Pair<Integer, Boolean> def = variableStreams.get(visible);
if (!def.getSecond()) {
streamNamesDefine[def.getFirst()] = visible;
typesDefine[def.getFirst()] = parentViewType;
} else {
hasVisibleMultimatch = true;
}
}
}
// compile multi-matching event type (in last position), if any are used
if (hasVisibleMultimatch) {
Map<String, Object> multievent = new LinkedHashMap<String, Object>();
for (Map.Entry<String, Pair<Integer, Boolean>> entry : variableStreams.entrySet()) {
String identifier = entry.getKey();
if (entry.getValue().getSecond()) {
if (visibles.contains(identifier)) {
multievent.put(identifier, new EventType[]{parentViewType});
} else {
multievent.put("esper_matchrecog_internal", null);
}
}
}
EventType multimatch = statementContext.getEventAdapterService().createAnonymousObjectArrayType(
"esper_matchrecog_internal", multievent);
typesDefine[typesDefine.length - 1] = multimatch;
streamNamesDefine[streamNamesDefine.length - 1] = multimatch.getName();
}
return new StreamTypeServiceImpl(typesDefine, streamNamesDefine, isIStreamOnly, statementContext.getEngineURI(), false, true);
}