Apache Flink - time between events












0















I am starting to experiment with Apache Flink and have achieved some very basic stuff. Now am I looking forward to finding out the time difference between consecutive elements.



My idea was to use countWindowAll(2) on a stream so that I could evaluate windows with 2 consecutive events. However, I don't understand how I can get access to the timestamps of the 2 events in the window to emit / map this into time difference.



Does someone have a good reference or even some example code for what I am trying to achieve ?



Lars










share|improve this question























  • Do your events have event-time timestamps that you want to compare, or are you wanting to use the CPU clock to measure the interval between processing one event and the next?

    – David Anderson
    Nov 17 '18 at 9:45













  • I intend to use event-time timestamps. So far, I am experimenting with the Twitter stream to gather some experience - do the tweet events have event timestamps ?

    – Lars
    Nov 18 '18 at 20:49











  • Make a window with size 2 and apply the function to get the difference, something looks like this: text.flatMap(_.toLowerCase.split("\W+")).map((_, System.currentTimeMillis())).countWindowAll(2).apply[Long]((_, iter, c) => c.collect(iter.last._2 - iter.head._2)).print()

    – David
    Nov 19 '18 at 2:32











  • Keep in mind that most applications with event-time timestamps end up processing events that are out-of-order, in which case comparing the timestamps on consecutive events may not be very meaningful.

    – David Anderson
    Nov 19 '18 at 8:09











  • BTW, the WikipediaEditEvent objects used in ci.apache.org/projects/flink/flink-docs-release-1.6/quickstart/… do have timestamps.

    – David Anderson
    Nov 19 '18 at 8:13
















0















I am starting to experiment with Apache Flink and have achieved some very basic stuff. Now am I looking forward to finding out the time difference between consecutive elements.



My idea was to use countWindowAll(2) on a stream so that I could evaluate windows with 2 consecutive events. However, I don't understand how I can get access to the timestamps of the 2 events in the window to emit / map this into time difference.



Does someone have a good reference or even some example code for what I am trying to achieve ?



Lars










share|improve this question























  • Do your events have event-time timestamps that you want to compare, or are you wanting to use the CPU clock to measure the interval between processing one event and the next?

    – David Anderson
    Nov 17 '18 at 9:45













  • I intend to use event-time timestamps. So far, I am experimenting with the Twitter stream to gather some experience - do the tweet events have event timestamps ?

    – Lars
    Nov 18 '18 at 20:49











  • Make a window with size 2 and apply the function to get the difference, something looks like this: text.flatMap(_.toLowerCase.split("\W+")).map((_, System.currentTimeMillis())).countWindowAll(2).apply[Long]((_, iter, c) => c.collect(iter.last._2 - iter.head._2)).print()

    – David
    Nov 19 '18 at 2:32











  • Keep in mind that most applications with event-time timestamps end up processing events that are out-of-order, in which case comparing the timestamps on consecutive events may not be very meaningful.

    – David Anderson
    Nov 19 '18 at 8:09











  • BTW, the WikipediaEditEvent objects used in ci.apache.org/projects/flink/flink-docs-release-1.6/quickstart/… do have timestamps.

    – David Anderson
    Nov 19 '18 at 8:13














0












0








0








I am starting to experiment with Apache Flink and have achieved some very basic stuff. Now am I looking forward to finding out the time difference between consecutive elements.



My idea was to use countWindowAll(2) on a stream so that I could evaluate windows with 2 consecutive events. However, I don't understand how I can get access to the timestamps of the 2 events in the window to emit / map this into time difference.



Does someone have a good reference or even some example code for what I am trying to achieve ?



Lars










share|improve this question














I am starting to experiment with Apache Flink and have achieved some very basic stuff. Now am I looking forward to finding out the time difference between consecutive elements.



My idea was to use countWindowAll(2) on a stream so that I could evaluate windows with 2 consecutive events. However, I don't understand how I can get access to the timestamps of the 2 events in the window to emit / map this into time difference.



Does someone have a good reference or even some example code for what I am trying to achieve ?



Lars







apache events time streaming apache-flink






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 21:41









LarsLars

1




1













  • Do your events have event-time timestamps that you want to compare, or are you wanting to use the CPU clock to measure the interval between processing one event and the next?

    – David Anderson
    Nov 17 '18 at 9:45













  • I intend to use event-time timestamps. So far, I am experimenting with the Twitter stream to gather some experience - do the tweet events have event timestamps ?

    – Lars
    Nov 18 '18 at 20:49











  • Make a window with size 2 and apply the function to get the difference, something looks like this: text.flatMap(_.toLowerCase.split("\W+")).map((_, System.currentTimeMillis())).countWindowAll(2).apply[Long]((_, iter, c) => c.collect(iter.last._2 - iter.head._2)).print()

    – David
    Nov 19 '18 at 2:32











  • Keep in mind that most applications with event-time timestamps end up processing events that are out-of-order, in which case comparing the timestamps on consecutive events may not be very meaningful.

    – David Anderson
    Nov 19 '18 at 8:09











  • BTW, the WikipediaEditEvent objects used in ci.apache.org/projects/flink/flink-docs-release-1.6/quickstart/… do have timestamps.

    – David Anderson
    Nov 19 '18 at 8:13



















  • Do your events have event-time timestamps that you want to compare, or are you wanting to use the CPU clock to measure the interval between processing one event and the next?

    – David Anderson
    Nov 17 '18 at 9:45













  • I intend to use event-time timestamps. So far, I am experimenting with the Twitter stream to gather some experience - do the tweet events have event timestamps ?

    – Lars
    Nov 18 '18 at 20:49











  • Make a window with size 2 and apply the function to get the difference, something looks like this: text.flatMap(_.toLowerCase.split("\W+")).map((_, System.currentTimeMillis())).countWindowAll(2).apply[Long]((_, iter, c) => c.collect(iter.last._2 - iter.head._2)).print()

    – David
    Nov 19 '18 at 2:32











  • Keep in mind that most applications with event-time timestamps end up processing events that are out-of-order, in which case comparing the timestamps on consecutive events may not be very meaningful.

    – David Anderson
    Nov 19 '18 at 8:09











  • BTW, the WikipediaEditEvent objects used in ci.apache.org/projects/flink/flink-docs-release-1.6/quickstart/… do have timestamps.

    – David Anderson
    Nov 19 '18 at 8:13

















Do your events have event-time timestamps that you want to compare, or are you wanting to use the CPU clock to measure the interval between processing one event and the next?

– David Anderson
Nov 17 '18 at 9:45







Do your events have event-time timestamps that you want to compare, or are you wanting to use the CPU clock to measure the interval between processing one event and the next?

– David Anderson
Nov 17 '18 at 9:45















I intend to use event-time timestamps. So far, I am experimenting with the Twitter stream to gather some experience - do the tweet events have event timestamps ?

– Lars
Nov 18 '18 at 20:49





I intend to use event-time timestamps. So far, I am experimenting with the Twitter stream to gather some experience - do the tweet events have event timestamps ?

– Lars
Nov 18 '18 at 20:49













Make a window with size 2 and apply the function to get the difference, something looks like this: text.flatMap(_.toLowerCase.split("\W+")).map((_, System.currentTimeMillis())).countWindowAll(2).apply[Long]((_, iter, c) => c.collect(iter.last._2 - iter.head._2)).print()

– David
Nov 19 '18 at 2:32





Make a window with size 2 and apply the function to get the difference, something looks like this: text.flatMap(_.toLowerCase.split("\W+")).map((_, System.currentTimeMillis())).countWindowAll(2).apply[Long]((_, iter, c) => c.collect(iter.last._2 - iter.head._2)).print()

– David
Nov 19 '18 at 2:32













Keep in mind that most applications with event-time timestamps end up processing events that are out-of-order, in which case comparing the timestamps on consecutive events may not be very meaningful.

– David Anderson
Nov 19 '18 at 8:09





Keep in mind that most applications with event-time timestamps end up processing events that are out-of-order, in which case comparing the timestamps on consecutive events may not be very meaningful.

– David Anderson
Nov 19 '18 at 8:09













BTW, the WikipediaEditEvent objects used in ci.apache.org/projects/flink/flink-docs-release-1.6/quickstart/… do have timestamps.

– David Anderson
Nov 19 '18 at 8:13





BTW, the WikipediaEditEvent objects used in ci.apache.org/projects/flink/flink-docs-release-1.6/quickstart/… do have timestamps.

– David Anderson
Nov 19 '18 at 8:13












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345815%2fapache-flink-time-between-events%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345815%2fapache-flink-time-between-events%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()