Search in sources :

Example 1 with StaticFileSplitEnumerator

use of org.apache.flink.connector.file.src.impl.StaticFileSplitEnumerator in project flink by apache.

the class AbstractFileSource method createSplitEnumerator.

// ------------------------------------------------------------------------
// helpers
// ------------------------------------------------------------------------
private SplitEnumerator<SplitT, PendingSplitsCheckpoint<SplitT>> createSplitEnumerator(SplitEnumeratorContext<SplitT> context, FileEnumerator enumerator, Collection<FileSourceSplit> splits, @Nullable Collection<Path> alreadyProcessedPaths) {
    // cast this to a collection of FileSourceSplit because the enumerator code work
    // non-generically just on that base split type
    @SuppressWarnings("unchecked") final SplitEnumeratorContext<FileSourceSplit> fileSplitContext = (SplitEnumeratorContext<FileSourceSplit>) context;
    final FileSplitAssigner splitAssigner = assignerFactory.create(splits);
    if (continuousEnumerationSettings == null) {
        // bounded case
        return castGeneric(new StaticFileSplitEnumerator(fileSplitContext, splitAssigner));
    } else {
        // unbounded case
        if (alreadyProcessedPaths == null) {
            alreadyProcessedPaths = splitsToPaths(splits);
        }
        return castGeneric(new ContinuousFileSplitEnumerator(fileSplitContext, enumerator, splitAssigner, inputPaths, alreadyProcessedPaths, continuousEnumerationSettings.getDiscoveryInterval().toMillis()));
    }
}
Also used : SplitEnumeratorContext(org.apache.flink.api.connector.source.SplitEnumeratorContext) ContinuousFileSplitEnumerator(org.apache.flink.connector.file.src.impl.ContinuousFileSplitEnumerator) StaticFileSplitEnumerator(org.apache.flink.connector.file.src.impl.StaticFileSplitEnumerator) FileSplitAssigner(org.apache.flink.connector.file.src.assigners.FileSplitAssigner)

Aggregations

SplitEnumeratorContext (org.apache.flink.api.connector.source.SplitEnumeratorContext)1 FileSplitAssigner (org.apache.flink.connector.file.src.assigners.FileSplitAssigner)1 ContinuousFileSplitEnumerator (org.apache.flink.connector.file.src.impl.ContinuousFileSplitEnumerator)1 StaticFileSplitEnumerator (org.apache.flink.connector.file.src.impl.StaticFileSplitEnumerator)1