You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/08/02 08:48:02 UTC
[jira] [Commented] (FLINK-7293) Support custom order by in
PatternStream
[ https://issues.apache.org/jira/browse/FLINK-7293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16110557#comment-16110557 ]
ASF GitHub Bot commented on FLINK-7293:
---------------------------------------
Github user dawidwys commented on a diff in the pull request:
https://github.com/apache/flink/pull/4418#discussion_r130816980
--- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/operator/AbstractKeyedCEPPatternOperator.java ---
@@ -257,7 +289,32 @@ public void onEventTime(InternalTimer<KEY, VoidNamespace> timer) throws Exceptio
@Override
public void onProcessingTime(InternalTimer<KEY, VoidNamespace> timer) throws Exception {
- // not used
+ NFA<IN> nfa = getNFA();
+
+ // emit the events in order
+ for (IN event : sort(bufferedEvents.get())) {
+ processEvent(nfa, event, getProcessingTimeService().getCurrentProcessingTime());
+ }
+
+ // remove all buffered rows
+ bufferedEvents.clear();
+
+ updateNFA(nfa);
+ }
+
+ private Iterable<IN> sort(Iterable<IN> iter) {
+ if (comparator == null) {
+ return iter;
+ } else {
+ // insert all events into the sort buffer
+ List<IN> sortBuffer = new ArrayList<>();
--- End diff --
As we dropped support of Java 7, we could use `Stream` here. That way we won't need to create the temporary buffer.
Sth like:
private Stream<IN> sort(Iterable<IN> iter) {
Stream<IN> stream = StreamSupport.stream(iter.spliterator(), false);
if (comparator == null) {
return stream;
} else {
return stream.sorted(comparator);
}
And use it like this:
sort(bufferedEvents.get()).forEachOrdered(
event -> processEvent(nfa, event, getProcessingTimeService().getCurrentProcessingTime())
);
What do you think?
> Support custom order by in PatternStream
> ----------------------------------------
>
> Key: FLINK-7293
> URL: https://issues.apache.org/jira/browse/FLINK-7293
> Project: Flink
> Issue Type: Sub-task
> Components: CEP
> Reporter: Dian Fu
> Assignee: Dian Fu
>
> Currently, when {{ProcessingTime}} is configured, the events are fed to NFA in the order of the arriving time and when {{EventTime}} is configured, the events are fed to NFA in the order of the event time. It should also allow custom {{order by}} to allow users to define the order of the events besides the above factors.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)