@@ -32,6 +32,7 @@ namespace paimon {
3232class Executor ;
3333class MemoryPool ;
3434class Predicate ;
35+ class FileSystem ;
3536
3637// / `ReadContext` is some configuration for read operations.
3738// /
@@ -48,6 +49,7 @@ class PAIMON_EXPORT ReadContext {
4849 uint32_t row_to_batch_thread_number, const std::optional<std::string>& table_schema,
4950 const std::shared_ptr<MemoryPool>& memory_pool,
5051 const std::shared_ptr<Executor>& executor,
52+ const std::shared_ptr<FileSystem>& specific_file_system,
5153 const std::map<std::string, std::string>& fs_scheme_to_identifier_map,
5254 const std::map<std::string, std::string>& options);
5355 ~ReadContext ();
@@ -103,6 +105,9 @@ class PAIMON_EXPORT ReadContext {
103105 std::shared_ptr<Executor> GetExecutor () const {
104106 return executor_;
105107 }
108+ std::shared_ptr<FileSystem> GetSpecificFileSystem () const {
109+ return specific_file_system_;
110+ }
106111
107112 private:
108113 std::string path_;
@@ -118,6 +123,7 @@ class PAIMON_EXPORT ReadContext {
118123 std::optional<std::string> table_schema_;
119124 std::shared_ptr<MemoryPool> memory_pool_;
120125 std::shared_ptr<Executor> executor_;
126+ std::shared_ptr<FileSystem> specific_file_system_;
121127 std::map<std::string, std::string> fs_scheme_to_identifier_map_;
122128 std::map<std::string, std::string> options_;
123129};
@@ -258,15 +264,29 @@ class PAIMON_EXPORT ReadContextBuilder {
258264 // / @note Default branch is "main" if not specified.
259265 ReadContextBuilder& WithBranch (const std::string& branch);
260266
261- // / Set the file system scheme to identifier mapping for custom file system configurations.
262- // / This allows using different file system implementations for different URI schemes.
267+ // / Sets a mapping from URI schemes (e.g., "file", "oss") to registered file system
268+ // / identifiers. This allows selecting different pre-registered file system implementations
269+ // / based on the URI scheme at runtime.
263270 // /
264- // / @param fs_scheme_to_identifier_map Map from URI scheme to file system identifier.
271+ // / @param fs_scheme_to_identifier_map Map from URI scheme (like "oss") to the corresponding
272+ // / file system identifier.
265273 // / @return Reference to this builder for method chaining.
266- // / @note If not set, use default file system (configured in `Options::FILE_SYSTEM`).
274+ // / @note
275+ // / - This method is intended for environments where multiple file systems are pre-registered.
276+ // / - The specified identifiers must correspond to file systems that have been registered at
277+ // / compile time or initialization.
278+ // / - Cannot be used together with `WithFileSystem()`.
279+ // / - If not set, use default file system (configured in `Options::FILE_SYSTEM`).
280+ // / Example:
281+ // / builder.WithFileSystemSchemeToIdentifierMap({{"oss", "jindo"}, {"file", "local"}});
282+ // /
267283 ReadContextBuilder& WithFileSystemSchemeToIdentifierMap (
268284 const std::map<std::string, std::string>& fs_scheme_to_identifier_map);
269285
286+ // / Sets a custom file system instance to be used for all file operations in this read context.
287+ // / This bypasses the global file system registry and uses the provided implementation directly.
288+ ReadContextBuilder& WithFileSystem (const std::shared_ptr<FileSystem>& file_system);
289+
270290 // / Build and return a `ReadContext` instance with input validation.
271291 // / @return Result containing the constructed `ReadContext` or an error status.
272292 Result<std::unique_ptr<ReadContext>> Finish ();
0 commit comments