[GitHub] incubator-gearpump pull request #78: [GEARPUMP-192] refactor example sources...
Github user asfgit closed the pull request at: https://github.com/apache/incubator-gearpump/pull/78 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-gearpump pull request #78: [GEARPUMP-192] refactor example sources...
Github user manuzhang commented on a diff in the pull request: https://github.com/apache/incubator-gearpump/pull/78#discussion_r77342296 --- Diff: examples/streaming/wordcount/src/main/scala/org/apache/gearpump/streaming/examples/wordcount/Split.scala --- @@ -19,34 +19,45 @@ package org.apache.gearpump.streaming.examples.wordcount import java.time.Instant -import java.util.concurrent.TimeUnit import org.apache.gearpump.Message -import org.apache.gearpump.cluster.UserConfig -import org.apache.gearpump.streaming.source.{DataSource, DataSourceTask, Watermark} -import org.apache.gearpump.streaming.task.{Task, TaskContext} +import org.apache.gearpump.streaming.source.DataSource +import org.apache.gearpump.streaming.task.TaskContext +import scala.collection.mutable.ArrayBuffer -class Split() extends DataSource { +class Split extends DataSource { + + val result = ArrayBuffer[Message]() + var item = -1 + Split.TEXT_TO_SPLIT.lines.foreach { line => +line.split("[\\s]+").filter(_.nonEmpty).foreach { msg => // => 为å¿åå½æ°,ä¼ å ¥ä¸ä¸ªmsgåæ°æ§è¡å³è¾¹çæä½ --- End diff -- please remove this comment. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-gearpump pull request #78: [GEARPUMP-192] refactor example sources...
Github user huafengw commented on a diff in the pull request: https://github.com/apache/incubator-gearpump/pull/78#discussion_r77100932 --- Diff: examples/streaming/wordcount/src/main/scala/org/apache/gearpump/streaming/examples/wordcount/Split.scala --- @@ -23,29 +23,34 @@ import java.util.concurrent.TimeUnit import org.apache.gearpump.Message import org.apache.gearpump.cluster.UserConfig -import org.apache.gearpump.streaming.source.Watermark +import org.apache.gearpump.streaming.source.{DataSource, DataSourceTask, Watermark} import org.apache.gearpump.streaming.task.{Task, TaskContext} -class Split(taskContext: TaskContext, conf: UserConfig) extends Task(taskContext, conf) { - import taskContext.output - override def onStart(startTime: Instant): Unit = { -self ! Watermark(Instant.now) - } +class Split() extends DataSource { --- End diff -- I prefer `class Split extends DataSource`, no braces. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-gearpump pull request #78: [GEARPUMP-192] refactor example sources...
Github user huafengw commented on a diff in the pull request: https://github.com/apache/incubator-gearpump/pull/78#discussion_r77101042 --- Diff: examples/streaming/wordcount/src/main/scala/org/apache/gearpump/streaming/examples/wordcount/Split.scala --- @@ -23,29 +23,34 @@ import java.util.concurrent.TimeUnit import org.apache.gearpump.Message import org.apache.gearpump.cluster.UserConfig -import org.apache.gearpump.streaming.source.Watermark +import org.apache.gearpump.streaming.source.{DataSource, DataSourceTask, Watermark} import org.apache.gearpump.streaming.task.{Task, TaskContext} -class Split(taskContext: TaskContext, conf: UserConfig) extends Task(taskContext, conf) { - import taskContext.output - override def onStart(startTime: Instant): Unit = { -self ! Watermark(Instant.now) - } +class Split() extends DataSource { + + + override def open(context: TaskContext, startTime: Instant): Unit = {} - override def onNext(msg: Message): Unit = { + + override def read(): Message = { Split.TEXT_TO_SPLIT.lines.foreach { line => line.split("[\\s]+").filter(_.nonEmpty).foreach { msg => -output(new Message(msg, System.currentTimeMillis())) +new Message(msg, System.currentTimeMillis()) } } - -import scala.concurrent.duration._ -taskContext.scheduleOnce(Duration(100, TimeUnit.MILLISECONDS))(self ! - Watermark(Instant.now)) +Message("message") } + + override def close(): Unit = {} + + override def getWatermark: Instant = Instant.now() + + Watermark(Instant.now) --- End diff -- What's this line of code used for? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---