Class ChunkedFileProcessor.Builder
java.lang.Object
cloud.opencode.base.io.file.ChunkedFileProcessor.Builder
- Enclosing class:
ChunkedFileProcessor
Builder for ChunkedFileProcessor operations.
ChunkedFileProcessor 操作构建器。
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionchunkSize(int size) Sets the chunk size.maxBytes(long maxBytes) Sets the maximum bytes to read.onProgress(BiConsumer<Long, Long> callback) Sets a progress callback.parallel(boolean parallel) Enables parallel processing with virtual threads.parallelism(int level) Sets the parallelism level for parallel processing.Sets the file path.voidprocess(Consumer<ChunkedFileProcessor.Chunk> processor) Processes the file with the given processor.<T> List<T> processAndCollect(Function<ChunkedFileProcessor.Chunk, T> processor) Processes the file and collects results.progressInterval(long bytes) Sets the progress reporting interval.startOffset(long offset) Sets the starting offset for reading.stream()Creates a stream of chunks.useMemoryMapping(boolean use) Enables memory-mapped file processing.
-
Method Details
-
path
Sets the file path. 设置文件路径。- Parameters:
path- the file path - 文件路径- Returns:
- this builder
-
chunkSize
Sets the chunk size. 设置块大小。- Parameters:
size- the chunk size in bytes - 块大小(字节)- Returns:
- this builder
-
parallel
Enables parallel processing with virtual threads. 启用虚拟线程并行处理。- Parameters:
parallel- whether to enable parallel processing - 是否启用并行处理- Returns:
- this builder
-
parallelism
Sets the parallelism level for parallel processing. 设置并行处理的并行度。- Parameters:
level- the parallelism level - 并行度- Returns:
- this builder
-
useMemoryMapping
Enables memory-mapped file processing. 启用内存映射文件处理。- Parameters:
use- whether to use memory mapping - 是否使用内存映射- Returns:
- this builder
-
startOffset
Sets the starting offset for reading. 设置读取的起始偏移量。- Parameters:
offset- the starting offset - 起始偏移量- Returns:
- this builder
-
maxBytes
Sets the maximum bytes to read. 设置最大读取字节数。- Parameters:
maxBytes- the maximum bytes - 最大字节数- Returns:
- this builder
-
onProgress
Sets a progress callback. 设置进度回调。- Parameters:
callback- the callback (bytesProcessed, totalBytes) - 回调(已处理字节数,总字节数)- Returns:
- this builder
-
progressInterval
Sets the progress reporting interval. 设置进度报告间隔。- Parameters:
bytes- the interval in bytes - 间隔(字节)- Returns:
- this builder
-
process
Processes the file with the given processor. 使用给定的处理器处理文件。- Parameters:
processor- the chunk processor - 块处理器
-
processAndCollect
Processes the file and collects results. 处理文件并收集结果。- Type Parameters:
T- the result type - 结果类型- Parameters:
processor- the chunk processor that returns a result - 返回结果的块处理器- Returns:
- list of results - 结果列表
-
stream
Creates a stream of chunks. 创建块流。- Returns:
- a stream of chunks - 块流
-