You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "JingsongLi (via GitHub)" <gi...@apache.org> on 2023/03/10 06:46:59 UTC

[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #584: [FLINK-31338] support infer parallelism for flink table store

JingsongLi commented on code in PR #584:
URL: https://github.com/apache/flink-table-store/pull/584#discussion_r1132003909


##########
flink-table-store-flink/flink-table-store-flink-common/src/main/java/org/apache/flink/table/store/connector/source/TableStoreSource.java:
##########
@@ -162,15 +164,49 @@ public ScanRuntimeProvider getScanRuntimeProvider(ScanContext scanContext) {
                         .withProjection(projectFields)
                         .withPredicate(predicate)
                         .withLimit(limit)
-                        .withParallelism(
-                                Options.fromMap(table.schema().options())
-                                        .get(FlinkConnectorOptions.SCAN_PARALLELISM))
+                        .withParallelism(inferParallelism(table, predicate, limit, streaming))
                         .withWatermarkStrategy(watermarkStrategy);
 
         return new TableStoreDataStreamScanProvider(
                 !streaming, env -> sourceBuilder.withEnv(env).build());
     }
 
+    private Integer inferParallelism(
+            FileStoreTable table, Predicate predicate, Long limitCount, boolean streaming) {
+        Options options = Options.fromMap(this.table.schema().options());
+        Integer parallelism = null;
+
+        // for streaming mode, set the default parallelism to the bucket number.
+        if (streaming) {
+            parallelism = options.get(CoreOptions.BUCKET);
+        }
+
+        if (options.containsKey(FlinkConnectorOptions.SCAN_PARALLELISM.key())) {
+            parallelism = options.get(FlinkConnectorOptions.SCAN_PARALLELISM);
+        }
+
+        // batch mode
+        if (options.get(FlinkConnectorOptions.INFER_SCAN_PARALLELISM) && !streaming) {

Review Comment:
   How about:
   ```
   if (options.get(FlinkConnectorOptions.INFER_SCAN_PARALLELISM)) {
      if (streaming) {
           parallelism = options.get(CoreOptions.BUCKET);
      } else {
           // infer parallelism for batch
      }
   }
   ```



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org