ExArrow. FileSystem behaviour
(ex_arrow v0.9.0)
View Source
Capability-oriented filesystem abstraction for Dataset discovery.
Reads still go through path-based NIFs (Parquet, IPC). This module only
answers discovery questions: what paths exist, which match a glob, and
whether a path is present.
Implementations
ExArrow.FileSystem.Local— OS filesystem (default for Dataset)ExArrow.FileSystem.Memory— in-memory tree for tests (no tmp dirs)
S3 / object-store adapters are out of scope for 0.9.0; the behaviour leaves room for them later.
Hidden entries
When ignore_hidden: true (the default), any path component whose basename
starts with . or _ is skipped. That matches Dataset's
:ignore_hidden option (dotfiles and _-prefixed Hive / staging dirs).
Typical usage
fs = ExArrow.FileSystem.Local.new()
{:ok, entries} = ExArrow.FileSystem.list(fs, "/data/events", recursive: true)
{:ok, paths} = ExArrow.FileSystem.glob(fs, "/data/events/**/*.parquet")
true = ExArrow.FileSystem.exists?(fs, "/data/events")
{:ok, dataset} = ExArrow.Dataset.open("/data/events", filesystem: fs)
Summary
Types
One discovered path.
Option for glob/3.
Option for list/3.
Filesystem handle (struct whose module implements this behaviour).
Functions
Return whether path exists as a file or directory.
Return file paths matching pattern (sorted).
List entries under path.
Types
@type entry() :: %{ path: String.t(), type: :file | :directory, size: non_neg_integer() }
One discovered path.
Keys
:path— absolute or normalized path string:type—:fileor:directory:size— byte size for files;0for directories (and when unknown)
@type glob_opt() :: {:ignore_hidden, boolean()}
Option for glob/3.
Option for list/3.
@type t() :: struct()
Filesystem handle (struct whose module implements this behaviour).
Callbacks
Functions
Return whether path exists as a file or directory.
Parameters
fs— filesystem handlepath— path string (non-binaries returnfalse)
Examples
fs = ExArrow.FileSystem.Local.new()
ExArrow.FileSystem.exists?(fs, "/data/events")
Return file paths matching pattern (sorted).
Patterns use / separators. * matches within one path segment; **
matches across segments (including zero segments).
Parameters
fs— filesystem handlepattern— glob string (for example"/data/**/*.parquet")opts::ignore_hidden— whentrue(default), skip matches with a./_-prefixed path component
Returns
{:ok, paths}— sorted list of matching file paths{:error, message}— invalid pattern or opts
Examples
fs = ExArrow.FileSystem.Local.new()
{:ok, paths} = ExArrow.FileSystem.glob(fs, "/data/events/year=*/**/*.parquet")
List entries under path.
Parameters
fs— filesystem handle (LocalorMemory)path— directory or file to listopts::recursive— whentrue(default), walk the whole tree; whenfalse, only immediate children:ignore_hidden— whentrue(default), skip./_-prefixed names
Returns
{:ok, entries}— list ofentry/0maps, typically path-sorted{:error, message}— missing path, invalid opts, or backend failure
Examples
fs = ExArrow.FileSystem.Local.new()
{:ok, entries} = ExArrow.FileSystem.list(fs, "/data/events", recursive: false)
Enum.map(entries, &{&1.type, &1.path})