Class ConnectorCatalogProvider
- All Implemented Interfaces:
CatalogProvider,AutoCloseable
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: aConnectorRegistry 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.-
Field Summary
Fields inherited from interface com.darkcollective.relix.semantic.CatalogProvider
NONE -
Constructor Summary
ConstructorsConstructorDescriptionConnectorCatalogProvider(ConnectorRegistry registry, CatalogProvider delegate) A provider over an explicit registry — for a test, or a host that assembled its own.ConnectorCatalogProvider(CatalogProvider delegate) A provider over the discovered connectors, falling back todelegate. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()tables(ConnectionDeclaration connection) No connector enumerates its tables, so this is the delegate's answer.tableSchema(ConnectionDeclaration connection, String table) Returns the output schema oftablewithinconnection, orOptional.empty()if it cannot be determined.tableStatistics(ConnectionDeclaration connection, String table) Returns optimizer statistics (row count, keys) fortablewithinconnection, orOptional.empty()if none are available.
-
Constructor Details
-
ConnectorCatalogProvider
A provider over the discovered connectors, falling back todelegate.- Parameters:
delegate- answers what no connector describes; must not be null
-
ConnectorCatalogProvider
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 thisdelegate- answers what no connector describes; must not be null
-
-
Method Details
-
tableSchema
Description copied from interface:CatalogProviderReturns the output schema oftablewithinconnection, orOptional.empty()if it cannot be determined.- Specified by:
tableSchemain interfaceCatalogProvider- Parameters:
connection- the declared connection the table belongs totable- the (possibly schema-qualified) remote table name- Returns:
- the table's schema, or empty if unavailable
-
tableStatistics
Description copied from interface:CatalogProviderReturns optimizer statistics (row count, keys) fortablewithinconnection, orOptional.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:
tableStatisticsin interfaceCatalogProvider- Parameters:
connection- the declared connection the table belongs totable- the (possibly schema-qualified) remote table name- Returns:
- the table's statistics, or empty if unavailable
-
tables
No connector enumerates its tables, so this is the delegate's answer.- Specified by:
tablesin interfaceCatalogProvider- 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:
closein interfaceAutoCloseable
-