[
https://issues.apache.org/jira/browse/CALCITE-4942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17465853#comment-17465853
]
Jacques Nadeau commented on CALCITE-4942:
-----------------------------------------
[~jamesstarr], I actually did several iterations on how to construct handlers
to be cleaner/more modern/simpler. The best I came up with can be found in
[this gist|https://gist.github.com/jacques-n/19e06a39704d789a06cdd06cffacc8c1].
There are two different things that I think are ideal to accomplish:
- handlers are generic and declare the relnode interface they operate on. This
creates an explicit functional definition of what metadata methods should look
like (something that only exists implicitly today).
- handlers have a generic method for metadata and use a generic definition.
This allows a simplification of code that wants to invoke them since there are
only 6 total functional signatures that exist across all metadata operations.
(It's six to avoid boxing, otherwise it would be three.)
If we're doing breaking changes, I think it would be helpful to introduce these
patterns to not only clean up the old stuff but introducing a more standardized
way to express these things.
> Deprecate boilerplate for Rel Metadata
> --------------------------------------
>
> Key: CALCITE-4942
> URL: https://issues.apache.org/jira/browse/CALCITE-4942
> Project: Calcite
> Issue Type: Improvement
> Reporter: James Starr
> Assignee: James Starr
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> To define a Rel metadata type you need to create 2 class, 2 methods and a
> static variable. However, current implementation of RelMetadata back by
> Janino only require the Handler class a single method signature. The current
> metadata handler interface also has a generic that provides no type safety
> through out code.
> Currently to define a rel metadata type:
> {code:java}
> public class MyMetadata extends Metadata {
> MetadataDef DEF = ...
>
> VALUE myMethod1();
> class Handler extends RelHandler<MyMetadata> {
> VALUE myMethod2(RelNode, MetadataQuery)
> }
> }
> {code}
> What is actually needed to define a rel metadata type:
> {code:java}
> class MyMetadataHandler extends RelHandler {
> VALUE myMethod(RelNode, MetadataQuery)
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)