Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Flink BlockSplittingRecursiveEnumerator ConvertToSourceSplits

From Leeroopedia


Knowledge Sources
Domains Distributed_Computing, File_IO
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete tool for enumerating files and creating block-aligned splits for parallel reading provided by the Apache Flink connector-files module.

Description

The BlockSplittingRecursiveEnumerator extends NonSplittingRecursiveEnumerator to add block-level splitting. When a file is splittable (not compressed, not matching non-splittable suffixes), it queries the filesystem for BlockLocation information and creates one FileSourceSplit per block, preserving host locality hints. Non-splittable files fall through to the parent class behavior (one split per file).

Usage

This is the default enumerator for splittable formats. It is selected automatically by the FileSource builder when the format reports itself as splittable.

Code Reference

Source Location

  • Repository: Apache Flink
  • File: flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/src/enumerate/BlockSplittingRecursiveEnumerator.java
  • Lines: L57-167

Signature

@PublicEvolving
public class BlockSplittingRecursiveEnumerator extends NonSplittingRecursiveEnumerator {

    public BlockSplittingRecursiveEnumerator();

    public BlockSplittingRecursiveEnumerator(
            final Predicate<Path> fileFilter, final String[] nonSplittableFileSuffixes);

    @Override
    protected void convertToSourceSplits(
            final FileStatus file, final FileSystem fs, final List<FileSourceSplit> target)
            throws IOException;

    protected boolean isFileSplittable(Path filePath);
}

Import

import org.apache.flink.connector.file.src.enumerate.BlockSplittingRecursiveEnumerator;

I/O Contract

Inputs

Name Type Required Description
file FileStatus Yes File metadata including path, length
fs FileSystem Yes Filesystem for querying block locations
target List<FileSourceSplit> Yes Output list to append splits to

Outputs

Name Type Description
splits List<FileSourceSplit> One split per block (splittable) or one per file (non-splittable)

Usage Examples

Automatic Block Splitting

// BlockSplittingRecursiveEnumerator is used automatically for splittable formats.
// For a 512 MB file on HDFS with 128 MB blocks:
// -> 4 splits created, each with block host locality hints
//
// For a compressed .gz file:
// -> 1 split covering the entire file (non-splittable)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment