Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Metadata is an umbrella term for various kinds of information used about relational expressions during the query-planning process. The most common kinds of metadata are statistics, such as the number of rows or whether a given set of columns uniquely identify a relational expression. But there are other kinds of metadata, and users (i.e. the people writing their own rules and adapters for Optiq) may want to write their own.
All such metadata is accessed via a `RelMetadataProvider`. There are implementations that find metadata reflectively (by looking for methods with particular signatures), walk a chain of providers, and cache results.
The metadata request is currently a string (method name) and an array of objects (arguments). This feature would convert the metadata request to an actual method. The method belongs to an interface that extends Metadata. Here is an example user-defined metadata:
```java
public interface ColType extends Metadata
```
The easiest way to implement this interface is using a reflective provider:
```java
public static class ColTypeImpl {
static final Method METHOD;
static {
try
catch (NoSuchMethodException e)
{ throw new RuntimeException(e); }}
public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(
METHOD, new ColTypeImpl());
public String getColType(AggregateRelBase rel, int column)
{ ... }public String getColType(RelNode rel, int column) { ... }
}
```
Then call `RelOptCluster.getMetadataProvider()` to add it.
User code, accessing the metadata, can use the user's interface and the new `T RelNode.metadata(Class<T>)` method and is type-safe:
```
RelNode rel;
String colType = rel.metadata(ColType.class);
```
Currently each request to a RelMetadataProvider is passed to all of its sub-providers, an expensive process. We will change this so that RelMetadataProvider.apply(Class<RelNode>, Class<Metadata>) returns a function, or null if it could never supply that metadata. Thus a lot of the sub-providers are eliminated at 'compile time', when acquiring the metadata interface. At run-time probably only one or two providers will be queried. This should yield significant performance improvements, and ease of debugging.
---------------- Imported from GitHub ----------------
Url: https://github.com/julianhyde/optiq/issues/131
Created by: julianhyde
Labels:
Created at: Wed Feb 12 20:58:20 CET 2014
State: closed