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


##########
flink-table-store-flink/flink-table-store-flink-common/src/main/java/org/apache/flink/table/store/connector/source/TableStoreSource.java:
##########
@@ -162,15 +164,47 @@ 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 = 
options.get(FlinkConnectorOptions.SCAN_PARALLELISM);
+
+        if (options.get(FlinkConnectorOptions.INFER_SCAN_PARALLELISM)) {
+            // for streaming mode, set the default parallelism to the bucket 
number.
+            if (streaming) {
+                parallelism = options.get(CoreOptions.BUCKET);
+            } else {
+                int splitSize = 
table.newScan().withFilter(predicate).plan().splits.size();

Review Comment:
   I have concern here, plan is a heavy work, can we have a conservative 
approach?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to