You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/06/03 04:41:26 UTC

[GitHub] [beam] vmarquez commented on a change in pull request #10546: [BEAM-9008] Add CassandraIO readAll method

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



##########
File path: sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/CassandraIO.java
##########
@@ -326,7 +371,78 @@ private CassandraIO() {}
       checkArgument(entity() != null, "withEntity() is required");
       checkArgument(coder() != null, "withCoder() is required");
 
-      return input.apply(org.apache.beam.sdk.io.Read.from(new CassandraSource<>(this, null)));
+      ReadAll<T> readAll = CassandraIO.<T>readAll().withCoder(this.coder());
+
+      return input
+          .apply(Create.of(this))
+          .apply(ParDo.of(new SplitFn()))
+          .setCoder(SerializableCoder.of(new TypeDescriptor<Read<T>>() {}))
+          // .apply(Reshuffle.viaRandomKey())
+          .apply(readAll);
+    }
+
+    private class SplitFn extends DoFn<Read<T>, Read<T>> {
+
+      @ProcessElement
+      public void process(
+          @Element CassandraIO.Read<T> read, OutputReceiver<Read<T>> outputReceiver) {
+
+        try (Cluster cluster =
+            getCluster(
+                read.hosts(),
+                read.port(),
+                read.username(),
+                read.password(),
+                read.localDc(),
+                read.consistencyLevel())) {
+          if (isMurmur3Partitioner(cluster)) {

Review comment:
       Oops I did forget that, I will add. Good catch. 




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