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/05/27 03:19:52 UTC

[GitHub] [beam] aromanenko-dev commented on a change in pull request #11357: [BEAM-7770] Add ReadAll transform for SolrIO

aromanenko-dev commented on a change in pull request #11357:
URL: https://github.com/apache/beam/pull/11357#discussion_r430364065



##########
File path: sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/SolrIO.java
##########
@@ -364,36 +372,41 @@ Read withBatchSize(int batchSize) {
       // by tuning batchSize when pipelines run.
       checkArgument(
           batchSize > 0 && batchSize < MAX_BATCH_SIZE,
-          "Valid values for batchSize are 1 (inclusize) to %s (exclusive), but was: %s ",
+          "Valid values for batchSize are 1 (inclusive) to %s (exclusive), but was: %s ",
           MAX_BATCH_SIZE,
           batchSize);
       return builder().setBatchSize(batchSize).build();
     }
 
+    /** Read from a specific Replica (partition). */
+    public Read withReplicaInfo(ReplicaInfo replicaInfo) {
+      checkArgument(replicaInfo != null, "replicaInfo can not be null");
+      return builder().setReplicaInfo(replicaInfo).build();
+    }
+
     @Override
     public PCollection<SolrDocument> expand(PBegin input) {
       checkArgument(
           getConnectionConfiguration() != null, "withConnectionConfiguration() is required");
       checkArgument(getCollection() != null, "from() is required");
-
-      return input
-          .apply("Create", Create.of(this))
-          .apply("Split", ParDo.of(new SplitFn()))
-          .apply("Reshuffle", Reshuffle.viaRandomKey())
-          .apply("Read", ParDo.of(new ReadFn()));
+      return input.apply("Create", Create.of(this)).apply("ReadAll", readAll());

Review comment:
       Is `withReplicaInfo()` required here? If yes, please, add a check here.

##########
File path: sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/SolrIO.java
##########
@@ -364,36 +372,41 @@ Read withBatchSize(int batchSize) {
       // by tuning batchSize when pipelines run.
       checkArgument(
           batchSize > 0 && batchSize < MAX_BATCH_SIZE,
-          "Valid values for batchSize are 1 (inclusize) to %s (exclusive), but was: %s ",
+          "Valid values for batchSize are 1 (inclusive) to %s (exclusive), but was: %s ",
           MAX_BATCH_SIZE,
           batchSize);
       return builder().setBatchSize(batchSize).build();
     }
 
+    /** Read from a specific Replica (partition). */
+    public Read withReplicaInfo(ReplicaInfo replicaInfo) {
+      checkArgument(replicaInfo != null, "replicaInfo can not be null");
+      return builder().setReplicaInfo(replicaInfo).build();
+    }
+
     @Override
     public PCollection<SolrDocument> expand(PBegin input) {
       checkArgument(
           getConnectionConfiguration() != null, "withConnectionConfiguration() is required");
       checkArgument(getCollection() != null, "from() is required");
-
-      return input
-          .apply("Create", Create.of(this))
-          .apply("Split", ParDo.of(new SplitFn()))
-          .apply("Reshuffle", Reshuffle.viaRandomKey())
-          .apply("Read", ParDo.of(new ReadFn()));
+      return input.apply("Create", Create.of(this)).apply("ReadAll", readAll());

Review comment:
       Is `withReplicaInfo()` required here? If yes, please, add a check.

##########
File path: sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/SolrIO.java
##########
@@ -364,36 +372,41 @@ Read withBatchSize(int batchSize) {
       // by tuning batchSize when pipelines run.
       checkArgument(
           batchSize > 0 && batchSize < MAX_BATCH_SIZE,
-          "Valid values for batchSize are 1 (inclusize) to %s (exclusive), but was: %s ",
+          "Valid values for batchSize are 1 (inclusive) to %s (exclusive), but was: %s ",
           MAX_BATCH_SIZE,
           batchSize);
       return builder().setBatchSize(batchSize).build();
     }
 
+    /** Read from a specific Replica (partition). */
+    public Read withReplicaInfo(ReplicaInfo replicaInfo) {
+      checkArgument(replicaInfo != null, "replicaInfo can not be null");
+      return builder().setReplicaInfo(replicaInfo).build();
+    }
+
     @Override
     public PCollection<SolrDocument> expand(PBegin input) {
       checkArgument(
           getConnectionConfiguration() != null, "withConnectionConfiguration() is required");
       checkArgument(getCollection() != null, "from() is required");
-
-      return input
-          .apply("Create", Create.of(this))
-          .apply("Split", ParDo.of(new SplitFn()))
-          .apply("Reshuffle", Reshuffle.viaRandomKey())
-          .apply("Read", ParDo.of(new ReadFn()));
+      return input.apply("Create", Create.of(this)).apply("ReadAll", readAll());

Review comment:
       My bad, I think we don't it here since anyway it will pass through `SplitFn` downstream

##########
File path: sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/SolrIO.java
##########
@@ -364,36 +372,41 @@ Read withBatchSize(int batchSize) {
       // by tuning batchSize when pipelines run.
       checkArgument(
           batchSize > 0 && batchSize < MAX_BATCH_SIZE,
-          "Valid values for batchSize are 1 (inclusize) to %s (exclusive), but was: %s ",
+          "Valid values for batchSize are 1 (inclusive) to %s (exclusive), but was: %s ",
           MAX_BATCH_SIZE,
           batchSize);
       return builder().setBatchSize(batchSize).build();
     }
 
+    /** Read from a specific Replica (partition). */
+    public Read withReplicaInfo(ReplicaInfo replicaInfo) {
+      checkArgument(replicaInfo != null, "replicaInfo can not be null");
+      return builder().setReplicaInfo(replicaInfo).build();
+    }
+
     @Override
     public PCollection<SolrDocument> expand(PBegin input) {
       checkArgument(
           getConnectionConfiguration() != null, "withConnectionConfiguration() is required");
       checkArgument(getCollection() != null, "from() is required");
-
-      return input
-          .apply("Create", Create.of(this))
-          .apply("Split", ParDo.of(new SplitFn()))
-          .apply("Reshuffle", Reshuffle.viaRandomKey())
-          .apply("Read", ParDo.of(new ReadFn()));
+      return input.apply("Create", Create.of(this)).apply("ReadAll", readAll());

Review comment:
       My bad, I think we don't need it here since anyway it will pass through `SplitFn` downstream




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