ATHARVA262005 commented on code in PR #37411:
URL: https://github.com/apache/beam/pull/37411#discussion_r2724606753
##########
sdks/java/io/sparkreceiver/3/src/test/java/org/apache/beam/sdk/io/sparkreceiver/SparkReceiverIOTest.java:
##########
@@ -241,4 +241,31 @@ public void testReadFromReceiverIteratorData() {
PAssert.that(actual).containsInAnyOrder(expected);
pipeline.run().waitUntilFinish(Duration.standardSeconds(15));
}
+
+ @Test
+ public void testReadFromCustomReceiverWithParallelism() {
+ CustomReceiverWithOffset.shouldFailInTheMiddle = false;
+ ReceiverBuilder<String, CustomReceiverWithOffset> receiverBuilder =
+ new
ReceiverBuilder<>(CustomReceiverWithOffset.class).withConstructorArgs();
+ SparkReceiverIO.Read<String> reader =
+ SparkReceiverIO.<String>read()
+ .withGetOffsetFn(Long::valueOf)
+ .withTimestampFn(Instant::parse)
+ .withPullFrequencySec(PULL_FREQUENCY_SEC)
+ .withStartPollTimeoutSec(START_POLL_TIMEOUT_SEC)
+ .withStartOffset(START_OFFSET)
+ .withSparkReceiverBuilder(receiverBuilder)
+ .withNumReaders(3);
+
+ List<String> expected = new ArrayList<>();
+ for (int j = 0; j < 3; j++) {
+ for (int i = 0; i < CustomReceiverWithOffset.RECORDS_COUNT; i++) {
+ expected.add(String.valueOf(i));
+ }
Review Comment:
Agreed. I have updated
[CustomReceiverWithOffset](cci:2://file:///d:/open%20souce/beam/sdks/java/io/sparkreceiver/3/src/test/java/org/apache/beam/sdk/io/sparkreceiver/CustomReceiverWithOffset.java:31:0-100:1)
to implement the
[setShard](cci:1://file:///d:/open%20souce/beam/sdks/java/io/sparkreceiver/3/src/test/java/org/apache/beam/sdk/io/sparkreceiver/CustomReceiverWithOffset.java:57:2-61:3)
logic (using simple modulo partitioning).
I also updated the test assertion to expect **20 unique records** total
strings '0' to '19' exactly once), verifying that the work is correctly
distributed without duplication.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]