iemejia commented on a change in pull request #10546:
URL: https://github.com/apache/beam/pull/10546#discussion_r416975426



##########
File path: 
sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/CassandraIO.java
##########
@@ -391,36 +393,57 @@ static Cluster getCluster(
                 .withSplitCount(splitCount)
                 .withMapperFactoryFn(this.mapperFactoryFn());
 
-        if (isMurmur3Partitioner(cluster)) {
-          LOG.info("Murmur3Partitioner detected, splitting");
-
-          List<BigInteger> tokens =
-              cluster.getMetadata().getTokenRanges().stream()
-                  .map(tokenRange -> new 
BigInteger(tokenRange.getEnd().getValue().toString()))
-                  .collect(Collectors.toList());
-
-          SplitGenerator splitGenerator =
-              new SplitGenerator(cluster.getMetadata().getPartitioner());
-
-          List<Read<T>> splits =
-              splitGenerator.generateSplits(splitCount, tokens).stream()
-                  .map(rr -> CassandraIO.<T>read().withRingRange(rr))
-                  .collect(Collectors.toList());
+        return input
+            .apply(Create.of(this))
+            .apply(ParDo.of(new SplitFn<T>()))
+            .setCoder(SerializableCoder.of(new TypeDescriptor<Read<T>>() {}))
+            .apply(Reshuffle.viaRandomKey())
+            .apply(readAll);
+      }
+    }
 
-          return input.apply("Creating splits", 
Create.of(splits)).apply("readAll", readAll);
+    private static class SplitFn<T> extends DoFn<Read<T>, Read<T>> {

Review comment:
       This looks perfect!




----------------------------------------------------------------
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]


Reply via email to