Class FileResolver
java.lang.Object
com.darkcollective.relix.connectors.std.internal.FileResolver
The one answer to give me a local file for this connection, for every
connector that reads a file.
A file-backed connection names its file by path or by url, never
both. A path is resolved against the session's base directory, which for a
script is the script's own directory, the rule a csv("…") source already
follows. A url is either file:, which is a path spelled as a URL, or
https:, which is fetched. A connector is handed an absolute path and
never learns which kind it was given.
A fetched file is pinned for the session
The engine treats a base relation as the same relation every time it is read: the planner shares a sub-plan on that strength, and a measured row count is replayed into the cost model. A URL can change underneath a running program, so each URL is fetched at most once per resolver, and a session owns one resolver: every scan in a session reads the same bytes. Between sessions the cached copy is revalidated with the server'sETag or Last-Modified, so an unchanged file is not
downloaded again. A session that cannot reach the server uses the cached copy when it
has one.
A connection may pin the file's content with sha256: "<hex>". A download,
or a cached copy, whose digest differs is refused.
Only https is fetched. A session can refuse fetching entirely, in which
case a connection naming an https URL is an error rather than a download.
Compressed files
openText(java.nio.file.Path) reads a gzip file transparently, recognising it by its content
rather than its name, so a rotated access.log.2.gz reads like any other file.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PathThe cache directory a session uses by default. -
Method Summary
Modifier and TypeMethodDescriptionstatic FileResolverA resolver for one session.prepare(RelixConnector connector, ConnectorConfig config, Path baseDir) Returnsconfigwith its file named by an absolute localpath.
-
Field Details
-
DEFAULT_CACHE
The cache directory a session uses by default.
-
-
Method Details
-
create
A resolver for one session.- Parameters:
cacheDir- where fetched files are kept between sessions; must not be nullfetch- whether anhttpsURL may be downloaded at all- Returns:
- the resolver
-
prepare
Returnsconfigwith its file named by an absolute localpath. A connector that does not read a file is handedconfigunchanged.- Parameters:
connector- the connector the config is forconfig- the connection's settingsbaseDir- what a relativepathresolves against- Returns:
configwith its file named by an absolute localpath- Throws:
EvaluationException- when the settings name no file, name one twice, or name a URL that cannot be fetched
-