Class ChunkedFileProcessor.Builder

java.lang.Object
cloud.opencode.base.io.file.ChunkedFileProcessor.Builder
Enclosing class:
ChunkedFileProcessor

public static final class ChunkedFileProcessor.Builder extends Object
Builder for ChunkedFileProcessor operations. ChunkedFileProcessor 操作构建器。
Since:
JDK 25, opencode-base-io V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • path

      public ChunkedFileProcessor.Builder path(Path path)
      Sets the file path. 设置文件路径。
      Parameters:
      path - the file path - 文件路径
      Returns:
      this builder
    • chunkSize

      public ChunkedFileProcessor.Builder chunkSize(int size)
      Sets the chunk size. 设置块大小。
      Parameters:
      size - the chunk size in bytes - 块大小(字节)
      Returns:
      this builder
    • parallel

      public ChunkedFileProcessor.Builder parallel(boolean parallel)
      Enables parallel processing with virtual threads. 启用虚拟线程并行处理。
      Parameters:
      parallel - whether to enable parallel processing - 是否启用并行处理
      Returns:
      this builder
    • parallelism

      public ChunkedFileProcessor.Builder parallelism(int level)
      Sets the parallelism level for parallel processing. 设置并行处理的并行度。
      Parameters:
      level - the parallelism level - 并行度
      Returns:
      this builder
    • useMemoryMapping

      public ChunkedFileProcessor.Builder useMemoryMapping(boolean use)
      Enables memory-mapped file processing. 启用内存映射文件处理。
      Parameters:
      use - whether to use memory mapping - 是否使用内存映射
      Returns:
      this builder
    • startOffset

      public ChunkedFileProcessor.Builder startOffset(long offset)
      Sets the starting offset for reading. 设置读取的起始偏移量。
      Parameters:
      offset - the starting offset - 起始偏移量
      Returns:
      this builder
    • maxBytes

      public ChunkedFileProcessor.Builder maxBytes(long maxBytes)
      Sets the maximum bytes to read. 设置最大读取字节数。
      Parameters:
      maxBytes - the maximum bytes - 最大字节数
      Returns:
      this builder
    • onProgress

      public ChunkedFileProcessor.Builder onProgress(BiConsumer<Long,Long> callback)
      Sets a progress callback. 设置进度回调。
      Parameters:
      callback - the callback (bytesProcessed, totalBytes) - 回调(已处理字节数,总字节数)
      Returns:
      this builder
    • progressInterval

      public ChunkedFileProcessor.Builder progressInterval(long bytes)
      Sets the progress reporting interval. 设置进度报告间隔。
      Parameters:
      bytes - the interval in bytes - 间隔(字节)
      Returns:
      this builder
    • process

      public void process(Consumer<ChunkedFileProcessor.Chunk> processor)
      Processes the file with the given processor. 使用给定的处理器处理文件。
      Parameters:
      processor - the chunk processor - 块处理器
    • processAndCollect

      public <T> List<T> processAndCollect(Function<ChunkedFileProcessor.Chunk, T> processor)
      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 - 块流