ruanhang1993 commented on code in PR #22249:
URL: https://github.com/apache/flink/pull/22249#discussion_r1223886235
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemTableSource.java:
##########
@@ -269,10 +271,35 @@ private SourceProvider
createSourceProvider(BulkFormat<RowData, FileSourceSplit>
tableOptions
.getOptional(FileSystemConnectorOptions.SOURCE_MONITOR_INTERVAL)
.ifPresent(fileSourceBuilder::monitorContinuously);
+ tableOptions
+ .getOptional(FileSystemConnectorOptions.SOURCE_REGEX_PATTERN)
+ .ifPresent(
+ s -> {
+ String regexPath =
connectBasePathAndRegex(path.getPath(), s);
+ fileSourceBuilder.setFileEnumerator(
+ bulkFormat.isSplittable()
+ ? () -> new
BlockSplittingRegexEnumerator(regexPath)
+ : () -> new
NonSplittingRegexEnumerator(regexPath));
+ });
return SourceProvider.of(fileSourceBuilder.build());
}
+ private String connectBasePathAndRegex(String basePath, String regex) {
+ StringBuilder result = new StringBuilder();
+ result.append(basePath);
+ if (!basePath.endsWith(Path.SEPARATOR)) {
+ result.append(Path.SEPARATOR);
+ }
+ int startIndex = 0;
+ while (startIndex < regex.length()
Review Comment:
@luoyuxia Using a base path will help to reduce the search time.
If we only provide `source.regex-pattern` , we have to search files from
root path `/` when `source.regex-pattern` = `'/dir/t/.*/inner/.*'`.
If we provide base dir and `source.regex-pattern`, we will start to search
files under the base dir `/dir/t/` when base dir = `'/dir/t'` and
`source.regex-pattern` = `'.*/inner/.*'`.
--
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]