You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2023/01/11 07:58:45 UTC
[GitHub] [flink] WencongLiu opened a new pull request, #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
WencongLiu opened a new pull request, #21645:
URL: https://github.com/apache/flink/pull/21645
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
-->
## What is the purpose of the change
Improve the logic for enumerating splits for Hive source to avoid potential OOM
## Brief change log
- *Introduce the HiveSourceSplitIterator in MRSplitsGetter.*
- *Modify the interface of FileEnumerator.*
## Verifying this change
This change added tests and can be verified as follows:
- *Existing IT tests.*
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no )
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
--
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
[GitHub] [flink] flinkbot commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1378371092
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "7162b2dbc3219a744e6be798d5b11215dda5cf74",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "7162b2dbc3219a744e6be798d5b11215dda5cf74",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 7162b2dbc3219a744e6be798d5b11215dda5cf74 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1467973582
@flinkbot run azure
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1469930720
cc @luoyuxia
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1469719488
@flinkbot run azure
--
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
[GitHub] [flink] luoyuxia commented on a diff in pull request #21645: [FLINK-30556] Introduce the StaticPartitionFileSplitEnumerator
Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia commented on code in PR #21645:
URL: https://github.com/apache/flink/pull/21645#discussion_r1142880392
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/impl/StaticPartitionFileSplitEnumerator.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.file.src.impl;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.connector.source.SourceEvent;
+import org.apache.flink.api.connector.source.SplitEnumerator;
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+import org.apache.flink.connector.file.src.FileSource;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.PendingSplitsCheckpoint;
+import org.apache.flink.connector.file.src.assigners.FileSplitAssigner;
+import org.apache.flink.connector.file.src.enumerate.FileEnumerator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * An improved SplitEnumerator implementation for bounded / batch {@link FileSource} input. This
+ * enumerator uses the iterator of splits to allocate small batches of FileSourceSplits, which helps
+ * to avoid Java's out-of-memory (OOM) issue. All files present in the configured input directories
+ * are assigned to the readers. Once all files are processed, the source is finished. This class has
+ * a thin implementation. The actual logic for creating the set of FileSourceSplits
+ *
+ * <p>to process, and the logic to decide which reader gets what split, are still in {@link
+ * FileEnumerator} and in {@link FileSplitAssigner}, respectively.
+ */
+@Internal
+public class StaticPartitionFileSplitEnumerator
+ implements SplitEnumerator<FileSourceSplit, PendingSplitsCheckpoint<FileSourceSplit>> {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(StaticPartitionFileSplitEnumerator.class);
+
+ private final SplitEnumeratorContext<FileSourceSplit> context;
+
+ private final Iterator<List<FileSourceSplit>> splitsIterator;
+
+ private final FileSplitAssigner.Provider assignerFactory;
+
+ private FileSplitAssigner splitAssigner;
+
+ // ------------------------------------------------------------------------
+
+ public StaticPartitionFileSplitEnumerator(
Review Comment:
Do you mean invoke `createInputSplitsIterator` to create `StaticPartitionFileSplitEnumerator` in method `HiveSource#createEnumerator` or others? Do do intend to modify the interface `FileEnumerator#enumerateSplits`
to make it return `Iterator<List<FileSourceSplit>>`?
Also, for `StaticPartitionFileSplitEnumerator#snapshotState`, seems it will only snapshot `remainingSplits` in `splitAssigner` and one next element of `splitsIterator`. How the source can restore from that? I mean isn't needed to know the partitions the `StaticPartitionFileSplitEnumerator` has processed so that it can skip these partition after restore?
--
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
[GitHub] [flink] luoyuxia commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1471204585
Here, I would like to shard my idea for it.
First of all, we can pass a iterator to `SimpleSplitAssigner`, then in method `SimpleSplitAssigner#getNext`, we advance the iterator and then return a `FileSourceSplit`. In such way, we won't need to iterate the iterator to maintain all splits in memory at begining.
But it'll need to modify public interface and more worse, it will make `LocalityAwareSplitAssigner` impossible. Because we only pass an iterator to `LocalityAwareSplitAssigner` and then in `#getNext` method, we will always return the next split by advancing the iterator, as a result of which, we can't make use of locality aware.
Considering locality aware may be import and it will also touch public interfaces, I think the more pratical way will be modify the logic for splits enumeration/assignment in Hive connector with touching any public interface.
That's saying we can do such changes in Hive connector:
We have `StaticFileSplitEnumerator` which will get all splits at once, but it's not good when there're so many splits. So I think we can introduce `StaticPartitionFileSplitEnumerator`. In `StaticPartitionFileSplitEnumerator`, we maintains `remainingPartitions` and others any thing we may need.
In method `handleSplitRequest`, we call `splitAssigner.getNext(hostname)` to assign a split, if it return empty,
we then pop a partition from `remainingPartitions`, and get the splits from the partition, and create a new splitAssigner with the splits, so on.
`StaticPartitionFileSplitEnumerator` is more like something between `ContinuousHivePendingSplitsCheckpoint` and `StaticFileSplitEnumerator`.
Also, please remeber to implement to a `SplitsCheckpoint` for StaticFileSplitEnumerator` like `ContinuousHivePendingSplitsCheckpoint`/ `PendingSplitsCheckpoint` to make sure it can restore correctly when using `StaticPartitionFileSplitEnumerator`.
For implementation, I would to advice to open a pull request first to introduce such `StaticPartitionFileSplitEnumerator`;
and then make HiveSource use the `StaticPartitionFileSplitEnumerator`.
WDYT? @WencongLiu
--
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
[GitHub] [flink] luoyuxia commented on a diff in pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia commented on code in PR #21645:
URL: https://github.com/apache/flink/pull/21645#discussion_r1138014049
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/assigners/LocalityAwareSplitAssigner.java:
##########
@@ -69,9 +70,10 @@ public class LocalityAwareSplitAssigner implements FileSplitAssigner {
// --------------------------------------------------------------------------------------------
- public LocalityAwareSplitAssigner(Collection<FileSourceSplit> splits) {
- for (FileSourceSplit split : splits) {
- this.unassigned.add(new SplitWithInfo(split));
+ public LocalityAwareSplitAssigner(Iterator<FileSourceSplit> splits) {
+ while (splits.hasNext()) {
Review Comment:
Actaully, it'll still cause OOM for in here we will still maintain **all splits** in memory.
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1467302863
@flinkbot run azure
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1469274967
@flinkbot run azure
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1467731605
@flinkbot run azure
--
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
[GitHub] [flink] WencongLiu closed pull request #21645: [FLINK-30556][hive] Introduce the StaticHivePartitionSplitEnumerator
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu closed pull request #21645: [FLINK-30556][hive] Introduce the StaticHivePartitionSplitEnumerator
URL: https://github.com/apache/flink/pull/21645
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Introduce the StaticHivePartitionSplitEnumerator
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1482208760
cc @luoyuxia
--
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
[GitHub] [flink] WencongLiu commented on pull request #21645: [FLINK-30556] Improve the logic for enumerating splits for Hive source to avoid potential OOM
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on PR #21645:
URL: https://github.com/apache/flink/pull/21645#issuecomment-1473291171
Thank you for your suggestion @luoyuxia . I appreciate it and will implement it.
--
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
[GitHub] [flink] WencongLiu commented on a diff in pull request #21645: [FLINK-30556] Introduce the StaticPartitionFileSplitEnumerator
Posted by "WencongLiu (via GitHub)" <gi...@apache.org>.
WencongLiu commented on code in PR #21645:
URL: https://github.com/apache/flink/pull/21645#discussion_r1141937294
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/impl/StaticPartitionFileSplitEnumerator.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.file.src.impl;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.connector.source.SourceEvent;
+import org.apache.flink.api.connector.source.SplitEnumerator;
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+import org.apache.flink.connector.file.src.FileSource;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.PendingSplitsCheckpoint;
+import org.apache.flink.connector.file.src.assigners.FileSplitAssigner;
+import org.apache.flink.connector.file.src.enumerate.FileEnumerator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * An improved SplitEnumerator implementation for bounded / batch {@link FileSource} input. This
+ * enumerator uses the iterator of splits to allocate small batches of FileSourceSplits, which helps
+ * to avoid Java's out-of-memory (OOM) issue. All files present in the configured input directories
+ * are assigned to the readers. Once all files are processed, the source is finished. This class has
+ * a thin implementation. The actual logic for creating the set of FileSourceSplits
+ *
+ * <p>to process, and the logic to decide which reader gets what split, are still in {@link
+ * FileEnumerator} and in {@link FileSplitAssigner}, respectively.
+ */
+@Internal
+public class StaticPartitionFileSplitEnumerator
+ implements SplitEnumerator<FileSourceSplit, PendingSplitsCheckpoint<FileSourceSplit>> {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(StaticPartitionFileSplitEnumerator.class);
+
+ private final SplitEnumeratorContext<FileSourceSplit> context;
+
+ private final Iterator<List<FileSourceSplit>> splitsIterator;
+
+ private final FileSplitAssigner.Provider assignerFactory;
+
+ private FileSplitAssigner splitAssigner;
+
+ // ------------------------------------------------------------------------
+
+ public StaticPartitionFileSplitEnumerator(
Review Comment:
I prepare to add a new method `createInputSplitsIterator` with the return type `Iterator<List<FileSourceSplit>>`
in `HiveSourceFileEnumerator`. Then we can modify the overwritten methods `createEnumerator` and `restoreEnumerator` in `HiveSource`. In the overwritten methods, we can invoke`createInputSplitsIterator` to create `StaticPartitionFileSplitEnumerator `.
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/impl/StaticPartitionFileSplitEnumerator.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.file.src.impl;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.connector.source.SourceEvent;
+import org.apache.flink.api.connector.source.SplitEnumerator;
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+import org.apache.flink.connector.file.src.FileSource;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.PendingSplitsCheckpoint;
+import org.apache.flink.connector.file.src.assigners.FileSplitAssigner;
+import org.apache.flink.connector.file.src.enumerate.FileEnumerator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * An improved SplitEnumerator implementation for bounded / batch {@link FileSource} input. This
+ * enumerator uses the iterator of splits to allocate small batches of FileSourceSplits, which helps
+ * to avoid Java's out-of-memory (OOM) issue. All files present in the configured input directories
+ * are assigned to the readers. Once all files are processed, the source is finished. This class has
+ * a thin implementation. The actual logic for creating the set of FileSourceSplits
+ *
+ * <p>to process, and the logic to decide which reader gets what split, are still in {@link
+ * FileEnumerator} and in {@link FileSplitAssigner}, respectively.
+ */
+@Internal
+public class StaticPartitionFileSplitEnumerator
+ implements SplitEnumerator<FileSourceSplit, PendingSplitsCheckpoint<FileSourceSplit>> {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(StaticPartitionFileSplitEnumerator.class);
+
+ private final SplitEnumeratorContext<FileSourceSplit> context;
+
+ private final Iterator<List<FileSourceSplit>> splitsIterator;
+
+ private final FileSplitAssigner.Provider assignerFactory;
+
+ private FileSplitAssigner splitAssigner;
+
+ // ------------------------------------------------------------------------
+
+ public StaticPartitionFileSplitEnumerator(
Review Comment:
I prepare to add a new method `createInputSplitsIterator` with the return type `Iterator<List<FileSourceSplit>>`
in `HiveSourceFileEnumerator`. Then we can modify the overwritten methods `createEnumerator` and `restoreEnumerator` in `HiveSource`. In the overwritten methods, we can invoke`createInputSplitsIterator` to create `StaticPartitionFileSplitEnumerator `. @luoyuxia
--
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
[GitHub] [flink] luoyuxia commented on a diff in pull request #21645: [FLINK-30556] Introduce the StaticPartitionFileSplitEnumerator
Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia commented on code in PR #21645:
URL: https://github.com/apache/flink/pull/21645#discussion_r1141913618
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/impl/StaticPartitionFileSplitEnumerator.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.file.src.impl;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.connector.source.SourceEvent;
+import org.apache.flink.api.connector.source.SplitEnumerator;
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+import org.apache.flink.connector.file.src.FileSource;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.PendingSplitsCheckpoint;
+import org.apache.flink.connector.file.src.assigners.FileSplitAssigner;
+import org.apache.flink.connector.file.src.enumerate.FileEnumerator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * An improved SplitEnumerator implementation for bounded / batch {@link FileSource} input. This
+ * enumerator uses the iterator of splits to allocate small batches of FileSourceSplits, which helps
+ * to avoid Java's out-of-memory (OOM) issue. All files present in the configured input directories
+ * are assigned to the readers. Once all files are processed, the source is finished. This class has
+ * a thin implementation. The actual logic for creating the set of FileSourceSplits
+ *
+ * <p>to process, and the logic to decide which reader gets what split, are still in {@link
+ * FileEnumerator} and in {@link FileSplitAssigner}, respectively.
+ */
+@Internal
+public class StaticPartitionFileSplitEnumerator
+ implements SplitEnumerator<FileSourceSplit, PendingSplitsCheckpoint<FileSourceSplit>> {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(StaticPartitionFileSplitEnumerator.class);
+
+ private final SplitEnumeratorContext<FileSourceSplit> context;
+
+ private final Iterator<List<FileSourceSplit>> splitsIterator;
+
+ private final FileSplitAssigner.Provider assignerFactory;
+
+ private FileSplitAssigner splitAssigner;
+
+ // ------------------------------------------------------------------------
+
+ public StaticPartitionFileSplitEnumerator(
Review Comment:
I'm wondering how the HiveSoure will use `StaticPartitionFileSplitEnumerator`?
--
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