java.lang.Object
com.darkcollective.relix.connectors.std.internal.FileResolver

public final class FileResolver extends Object
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's ETag 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 Details

    • DEFAULT_CACHE

      public static final Path DEFAULT_CACHE
      The cache directory a session uses by default.
  • Method Details

    • create

      public static FileResolver create(Path cacheDir, boolean fetch)
      A resolver for one session.
      Parameters:
      cacheDir - where fetched files are kept between sessions; must not be null
      fetch - whether an https URL may be downloaded at all
      Returns:
      the resolver
    • prepare

      public ConnectorConfig prepare(RelixConnector connector, ConnectorConfig config, Path baseDir)
      Returns config with its file named by an absolute local path. A connector that does not read a file is handed config unchanged.
      Parameters:
      connector - the connector the config is for
      config - the connection's settings
      baseDir - what a relative path resolves against
      Returns:
      config with its file named by an absolute local path
      Throws:
      EvaluationException - when the settings name no file, name one twice, or name a URL that cannot be fetched