java.lang.Object
com.darkcollective.relix.connectors.std.internal.ConnectorCatalogProvider
All Implemented Interfaces:
CatalogProvider, AutoCloseable

public final class ConnectorCatalogProvider extends Object implements CatalogProvider, AutoCloseable
A CatalogProvider that asks the connector to describe its own tables.

RelixConnector has declared schema introspection since the SPI shipped, and nothing called it: the only live catalog provider opened a JDBC connection, so a dotted reference resolved its columns for a jdbc connection and for no other type. A capability nothing reaches reads as supported and is not — so this dispatches by the connection's own type token and lets any connector that can describe itself do so.

It is a decorator: what a connector declines falls through to the delegate, which is how JDBC keeps the introspection it already had. That path is worth more than a schema lookup — it maps SQL types, reads statistics, and serves a bound DataSource as readily as a declared URL — so it is composed with rather than replaced.

Offline

A connector that cannot reach what it describes answers empty, and so does this, because analysing with nothing reachable is a supported mode rather than a failure. A missing file and an unreachable database degrade the same way.

Lifetime

The registry is built once and closed with this provider, not per call: a ConnectorRegistry costs a ServiceLoader scan and a plugin-directory read, and a catalog is consulted once per dotted reference in a script rather than once per script.
  • Constructor Details

    • ConnectorCatalogProvider

      public ConnectorCatalogProvider(CatalogProvider delegate)
      A provider over the discovered connectors, falling back to delegate.
      Parameters:
      delegate - answers what no connector describes; must not be null
    • ConnectorCatalogProvider

      public ConnectorCatalogProvider(ConnectorRegistry registry, CatalogProvider delegate)
      A provider over an explicit registry — for a test, or a host that assembled its own.
      Parameters:
      registry - the connectors to ask; must not be null, and is closed with this
      delegate - answers what no connector describes; must not be null
  • Method Details

    • tableSchema

      public Optional<Schema> tableSchema(ConnectionDeclaration connection, String table)
      Description copied from interface: CatalogProvider
      Returns the output schema of table within connection, or Optional.empty() if it cannot be determined.
      Specified by:
      tableSchema in interface CatalogProvider
      Parameters:
      connection - the declared connection the table belongs to
      table - the (possibly schema-qualified) remote table name
      Returns:
      the table's schema, or empty if unavailable
    • tableStatistics

      public Optional<RelationStatistics> tableStatistics(ConnectionDeclaration connection, String table)
      Description copied from interface: CatalogProvider
      Returns optimizer statistics (row count, keys) for table within connection, or Optional.empty() if none are available.

      The default returns empty; introspecting providers override this to query the live catalog. Statistics are advisory: a missing or partial value never affects correctness, only the quality of cost-based decisions.

      Specified by:
      tableStatistics in interface CatalogProvider
      Parameters:
      connection - the declared connection the table belongs to
      table - the (possibly schema-qualified) remote table name
      Returns:
      the table's statistics, or empty if unavailable
    • tables

      public Optional<List<String>> tables(ConnectionDeclaration connection)
      No connector enumerates its tables, so this is the delegate's answer.
      Specified by:
      tables in interface CatalogProvider
      Parameters:
      connection - the declared connection
      Returns:
      the table names, as a reference would spell them after the connection's name; or empty if this provider cannot enumerate them
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable