[
https://issues.apache.org/jira/browse/BEAM-12378?focusedWorklogId=601444&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-601444
]
ASF GitHub Bot logged work on BEAM-12378:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 24/May/21 22:37
Start Date: 24/May/21 22:37
Worklog Time Spent: 10m
Work Description: reuvenlax commented on a change in pull request #14852:
URL: https://github.com/apache/beam/pull/14852#discussion_r638333913
##########
File path:
runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/DataflowRunnerTest.java
##########
@@ -1728,24 +1733,93 @@ private void verifyGroupIntoBatchesOverride(
}
PAssert.thatMultimap(output)
.satisfies(
- new SerializableFunction<Map<String, Iterable<Iterable<Integer>>>,
Void>() {
- @Override
- public Void apply(Map<String, Iterable<Iterable<Integer>>>
input) {
- assertEquals(2, input.size());
- assertThat(input.keySet(), containsInAnyOrder("A", "B"));
- Map<String, Integer> sums = new HashMap<>();
- for (Map.Entry<String, Iterable<Iterable<Integer>>> entry :
input.entrySet()) {
- for (Iterable<Integer> batch : entry.getValue()) {
- assertThat(Iterables.size(batch),
lessThanOrEqualTo(batchSize));
- for (Integer value : batch) {
- sums.put(entry.getKey(), value +
sums.getOrDefault(entry.getKey(), 0));
- }
+ i -> {
+ assertEquals(2, i.size());
+ assertThat(i.keySet(), containsInAnyOrder("A", "B"));
+ Map<String, Integer> sums = new HashMap<>();
+ for (Map.Entry<String, Iterable<Iterable<Integer>>> entry :
i.entrySet()) {
+ for (Iterable<Integer> batch : entry.getValue()) {
+ assertThat(Iterables.size(batch),
lessThanOrEqualTo(batchSize));
+ for (Integer value : batch) {
+ sums.put(entry.getKey(), value +
sums.getOrDefault(entry.getKey(), 0));
}
}
- assertEquals(15, (int) sums.get("A"));
- assertEquals(0, (int) sums.get("B"));
- return null;
}
+ assertEquals(15, (int) sums.get("A"));
+ assertEquals(0, (int) sums.get("B"));
+ return null;
+ });
+ p.run();
+
+ AtomicBoolean sawGroupIntoBatchesOverride = new AtomicBoolean(false);
+ p.traverseTopologically(
+ new PipelineVisitor.Defaults() {
+
+ @Override
+ public CompositeBehavior enterCompositeTransform(Node node) {
+ if (p.getOptions().as(StreamingOptions.class).isStreaming()
+ && node.getTransform()
+ instanceof
GroupIntoBatchesOverride.StreamingGroupIntoBatchesWithShardedKey) {
+ sawGroupIntoBatchesOverride.set(true);
+ }
+ if (!p.getOptions().as(StreamingOptions.class).isStreaming()
+ && node.getTransform() instanceof
GroupIntoBatchesOverride.BatchGroupIntoBatches) {
+ sawGroupIntoBatchesOverride.set(true);
+ }
+ if (!p.getOptions().as(StreamingOptions.class).isStreaming()
+ && node.getTransform()
+ instanceof
GroupIntoBatchesOverride.BatchGroupIntoBatchesWithShardedKey) {
+ sawGroupIntoBatchesOverride.set(true);
+ }
+ return CompositeBehavior.ENTER_TRANSFORM;
+ }
+ });
+ if (expectOverriden) {
+ assertTrue(sawGroupIntoBatchesOverride.get());
+ } else {
+ assertFalse(sawGroupIntoBatchesOverride.get());
+ }
+ }
+
+ private void verifyGroupIntoBatchesOverrideBytes(
+ Pipeline p, Boolean withShardedKey, Boolean expectOverriden) {
+ final long batchSizeBytes = 2;
+ List<KV<String, String>> testValues =
+ Arrays.asList(
+ KV.of("A", "a"),
+ KV.of("A", "ab"),
+ KV.of("A", "abc"),
+ KV.of("A", "abcd"),
+ KV.of("A", "abcde"));
+ PCollection<KV<String, String>> input = p.apply(Create.of(testValues));
+ PCollection<KV<String, Iterable<String>>> output;
+ if (withShardedKey) {
+ output =
+ input
+ .apply(GroupIntoBatches.<String,
String>ofSize(batchSizeBytes).withShardedKey())
Review comment:
done
--
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 601444)
Time Spent: 3h 40m (was: 3.5h)
> GroupIntoBatches should support byte-size batches
> -------------------------------------------------
>
> Key: BEAM-12378
> URL: https://issues.apache.org/jira/browse/BEAM-12378
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Reporter: Reuven Lax
> Priority: P2
> Time Spent: 3h 40m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)