You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/08/11 03:44:59 UTC

[GitHub] [flink] JingsongLi commented on a change in pull request #13010: [FLINK-18735][table] Add support for more types to DataGen source

JingsongLi commented on a change in pull request #13010:
URL: https://github.com/apache/flink/pull/13010#discussion_r468305915



##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/datagen/DataGeneratorSource.java
##########
@@ -77,8 +102,11 @@ public void run(SourceContext<T> ctx) throws Exception {
 
 		while (isRunning) {
 			for (int i = 0; i < taskRowsPerSecond; i++) {
-				if (isRunning && generator.hasNext()) {
+				if (isRunning && generator.hasNext() && (numberOfRows == null || outputSoFar < toOutput)) {
 					synchronized (ctx.getCheckpointLock()) {
+						if (numberOfRows != null) {
+							outputSoFar++;

Review comment:
       I have an idea: print `outputSoFar` in `close`. It is good for debugging.

##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/datagen/DataGeneratorSource.java
##########
@@ -77,8 +102,11 @@ public void run(SourceContext<T> ctx) throws Exception {
 
 		while (isRunning) {
 			for (int i = 0; i < taskRowsPerSecond; i++) {
-				if (isRunning && generator.hasNext()) {
+				if (isRunning && generator.hasNext() && (numberOfRows == null || outputSoFar < toOutput)) {
 					synchronized (ctx.getCheckpointLock()) {
+						if (numberOfRows != null) {

Review comment:
       Remove this if?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org