1717
1818#pragma once
1919
20+ #include < any>
2021#include < chrono>
2122#include < cstdint>
2223#include < functional>
2829
2930#include " arrow/filesystem/type_fwd.h"
3031#include " arrow/io/interfaces.h"
32+ #include " arrow/result.h"
3133#include " arrow/type_fwd.h"
3234#include " arrow/util/compare.h"
3335#include " arrow/util/macros.h"
@@ -359,11 +361,34 @@ class ARROW_EXPORT FileSystem
359361
360362struct FileSystemFactory {
361363 std::function<Result<std::shared_ptr<FileSystem>>(
362- const Uri& uri, const io::IOContext& io_context, std::string* out_path)>
364+ const Uri& uri, const std::vector<std::pair<std::string, std::any>>& options,
365+ const io::IOContext& io_context, std::string* out_path)>
363366 function;
364367 std::string_view file;
365368 int line;
366369
370+ // / Construct from an options-aware factory function.
371+ FileSystemFactory (std::function<Result<std::shared_ptr<FileSystem>>(
372+ const Uri&, const std::vector<std::pair<std::string, std::any>>&,
373+ const io::IOContext&, std::string*)>
374+ fn,
375+ std::string_view file, int line)
376+ : function(std::move(fn)), file(file), line(line) {}
377+
378+ // / Construct from a non-options aware factory function maintaing source compatibility
379+ // / with existing factories.
380+ FileSystemFactory (std::function<Result<std::shared_ptr<FileSystem>>(
381+ const Uri&, const io::IOContext&, std::string*)>
382+ fn,
383+ std::string_view file, int line)
384+ : function([fn = std::move(fn)](
385+ const Uri& uri,
386+ const std::vector<std::pair<std::string, std::any>>& /* ignored*/ ,
387+ const io::IOContext& ctx,
388+ std::string* out_path) { return fn (uri, ctx, out_path); }),
389+ file (file),
390+ line (line) {}
391+
367392 bool operator ==(const FileSystemFactory& other) const {
368393 // In the case where libarrow is linked statically both to the executable and to a
369394 // dynamically loaded filesystem implementation library, the library contains a
@@ -547,6 +572,26 @@ ARROW_EXPORT
547572Result<std::shared_ptr<FileSystem>> FileSystemFromUri (const std::string& uri,
548573 std::string* out_path = NULLPTR );
549574
575+ // / \brief Create a new FileSystem by URI with extended backend-specific filesystem
576+ // / options
577+ // /
578+ // / Recognized schemes are "file", "mock", "hdfs", "viewfs", "s3",
579+ // / "gs" and "gcs".
580+ // /
581+ // / Support for other schemes can be added using RegisterFileSystemFactory.
582+ // /
583+ // / \param[in] uri the URI to give access to
584+ // / \param[in] options a list of backend-specific filesystem options
585+ // / Each option is a (name, value) pair.
586+ // / The expected type is specific to the backend and
587+ // / option name.
588+ // / \param[out] out_path (optional) Path inside the filesystem.
589+ // / \return out_fs FileSystem instance.
590+ ARROW_EXPORT
591+ Result<std::shared_ptr<FileSystem>> FileSystemFromUri (
592+ const std::string& uri, const std::vector<std::pair<std::string, std::any>>& options,
593+ std::string* out_path = NULLPTR );
594+
550595// / \brief Create a new FileSystem by URI with a custom IO context
551596// /
552597// / Recognized schemes are "file", "mock", "hdfs", "viewfs", "s3",
@@ -563,6 +608,27 @@ Result<std::shared_ptr<FileSystem>> FileSystemFromUri(const std::string& uri,
563608 const io::IOContext& io_context,
564609 std::string* out_path = NULLPTR );
565610
611+ // / \brief Create a new FileSystem by URI with a custom IO context with backend-specific
612+ // / filesystem options
613+ // /
614+ // / Recognized schemes are "file", "mock", "hdfs", "viewfs", "s3",
615+ // / "gs" and "gcs".
616+ // /
617+ // / Support for other schemes can be added using RegisterFileSystemFactory.
618+ // /
619+ // / \param[in] uri a URI-based path, ex: file:///some/local/path
620+ // / \param[in] options a list of backend-specific filesystem options
621+ // / Each option is a (name, value) pair.
622+ // / The expected type is specific to the backend and
623+ // / option name.
624+ // / \param[in] io_context an IOContext which will be associated with the filesystem
625+ // / \param[out] out_path (optional) Path inside the filesystem.
626+ // / \return out_fs FileSystem instance.
627+ ARROW_EXPORT
628+ Result<std::shared_ptr<FileSystem>> FileSystemFromUri (
629+ const std::string& uri, const std::vector<std::pair<std::string, std::any>>& options,
630+ const io::IOContext& io_context, std::string* out_path = NULLPTR );
631+
566632// / \brief Create a new FileSystem by URI
567633// /
568634// / Support for other schemes can be added using RegisterFileSystemFactory.
0 commit comments