[
https://issues.apache.org/jira/browse/CALCITE-4539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17308162#comment-17308162
]
James Starr commented on CALCITE-4539:
--------------------------------------
[~julianhyde], I decide the interfaces should look like the following:
{code:java}
public interface MetadataHandlerProvider {
<H> H initialHandler(Class<H> handlerClass);
/** Re-generates the handler for a given kind of metadata, adding support for
* {@code class_} if it is not already present. */
<H extends MetadataHandler<M>, M extends Metadata> H revise(Class<H>
handlerClass);
MetadataCache buildCache();
...
}{code}
Removing RelNode and provider from revise method. Currently, I have a
prototype with passing the RelMetadataProvider to the revise call by putting in
a thread local in the initialHandler call. This would reduce the usage of a
thread local variable to be fully contained in one class instead of being part
of a public api. Also, the existing api of configuring the RelMetadataProvider
in the RelOptCluster is maintained. I feel
RelOptCluster.getRelMetadataProvider is problematic api as it contract has
changed over the evolution calcites metadata api, however, that can be
discussed separately.
{code:java}
public interface MetadataCache {
/**
* Removes cached metadata values for specified RelNode.
*
* @param rel RelNode whose cached metadata should be removed
* @return true if cache for the provided RelNode was not empty
*/
boolean clear(RelNode rel);
@Nullable Object remove(RelNode relNode, Object args);
@Nullable Object get(RelNode relNode, Object args);
@Nullable Object put(RelNode relNode, Object args, Object value);
}{code}
Changing the args from a List to an Object to allow for more efficient cache
keys to be selected.
My prototype is based on changes from:
CALCITE-4544 - Deprecating the java reflation base metadata,
CALCITE-4546 - Moving the janino backed metadata to instance of dispatch,
allowing the removal of rel Node from the revise call
CALCITE-4550 - Simplify JaninoRelMetadataProvider contract
CALCITE-4551 - Fly Weight for cache keys, why we should change the cache args
to an Object
Please let me know what would be the best way to package my changes for review
or if any the changes need to reworked/removed.
> Support pluggable metadata handlers and caching
> -----------------------------------------------
>
> Key: CALCITE-4539
> URL: https://issues.apache.org/jira/browse/CALCITE-4539
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: James Starr
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Calcite janino backed metadata does not support all the functionality that
> the java reflection backed metadata system, such as customizing the cache to
> use soft refs or have a max size. Furthermore, the janino backed metadata
> provider has many opinion that other are not universally shared, such as lazy
> loading, requiring all rels to registered to a global singleton, use of
> thread locals. There is no easy way to currently override these opinions.
> Calcites metadata system should consist of 3 APIs: metadata consumer,
> metadata implementors, metadata behavior. The metadata consumer need to able
> to fetch the appropriate metadata and invalidate the cache. Currently this
> is all done through RelMetadataQuery with some very leaky abstractions.
> Metadata implementors create functions that extract the metadata for
> particular node types. These functions are registered via
> ReflectiveRelMetadataProvider and ChainedRelMetadataProvider. Attempting to
> configure the internal behavior does not currently have an api. Currently
> porptions of it a scattered through out various class and are frequently not
> extensible.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)