jamesstarr commented on a change in pull request #2538:
URL: https://github.com/apache/calcite/pull/2538#discussion_r718891270
##########
File path:
core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
##########
@@ -475,33 +356,15 @@ private static StringBuilder paramList(StringBuilder
buff, Method method) {
synchronized <M extends Metadata, H extends MetadataHandler<M>> H revise(
Class<? extends RelNode> rClass, MetadataDef<M> def) {
- if (ALL_RELS.add(rClass)) {
- HANDLERS.invalidateAll();
- }
//noinspection unchecked
return (H) create(def);
}
/** Registers some classes. Does not flush the providers, but next time we
* need to generate a provider, it will handle all of these classes. So,
* calling this method reduces the number of times we need to re-generate. */
+ @Deprecated
public void register(Iterable<Class<? extends RelNode>> classes) {
- // Register the classes and their base classes up to RelNode. Don't bother
Review comment:
There is no loss in functionality.
##########
File path:
core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
##########
@@ -193,41 +124,39 @@ public static JaninoRelMetadataProvider
of(RelMetadataProvider provider) {
}
private static <M extends Metadata> MetadataHandler<M> load3(
- MetadataDef<M> def, Multimap<Method, MetadataHandler<M>> map,
- ImmutableList<Class<? extends RelNode>> relClasses) {
+ MetadataDef<M> def, Multimap<Method, ? extends MetadataHandler<?>> map) {
final StringBuilder buff = new StringBuilder();
final String name =
- "GeneratedMetadataHandler_" + def.metadataClass.getSimpleName();
- final Set<MetadataHandler> providerSet = new HashSet<>();
- final List<Pair<String, MetadataHandler>> providerList = new ArrayList<>();
- //noinspection unchecked
- final ReflectiveRelMetadataProvider.Space space =
- new ReflectiveRelMetadataProvider.Space((Multimap) map);
- for (MetadataHandler provider : space.providerMap.values()) {
+ "GeneratedMetadata_" + simpleNameForHandler(def.handlerClass);
+ final Set<MetadataHandler<?>> providerSet = new HashSet<>();
+
+ final Map<MetadataHandler<?>, String> handlerToName = new
LinkedHashMap<>();
+ for (MetadataHandler<?> provider : map.values()) {
if (providerSet.add(provider)) {
Review comment:
Changed to getMetadataDelegateRel
##########
File path:
core/src/main/java/org/apache/calcite/rel/metadata/DelegatingMetadataRel.java
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.rel.metadata;
+
+import org.apache.calcite.rel.RelNode;
+
+/**
+ * Interface for {@link RelNode} where the metadata is derived from another
node.
+ */
+public interface DelegatingMetadataRel {
Review comment:
Ideally RelSubset would use this. However, JaninoRelMetadataProvider
explicitly calls out HepRelVertex, so this does not change the exist behavior.
Their is no such exception for RelSubset, so it would result in a change in
behavior. Thus moving RelSubset is worth it own ticker/PR to discuss all the
implications of the changes.
##########
File path:
core/src/main/java/org/apache/calcite/rel/metadata/DelegatingMetadataRel.java
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.rel.metadata;
+
+import org.apache.calcite.rel.RelNode;
+
+/**
+ * Interface for {@link RelNode} where the metadata is derived from another
node.
+ */
+public interface DelegatingMetadataRel {
Review comment:
Ideally, RelSubset would use this. However, JaninoRelMetadataProvider
explicitly calls out HepRelVertex, so this does not change the existing
behavior. There is no such exception for RelSubset, so it would result in a
change in behavior. Thus moving RelSubset is worth it own ticker/PR to discuss
all the implications of the changes.
##########
File path:
core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
##########
@@ -475,33 +356,15 @@ private static StringBuilder paramList(StringBuilder
buff, Method method) {
synchronized <M extends Metadata, H extends MetadataHandler<M>> H revise(
Class<? extends RelNode> rClass, MetadataDef<M> def) {
- if (ALL_RELS.add(rClass)) {
- HANDLERS.invalidateAll();
- }
//noinspection unchecked
return (H) create(def);
}
/** Registers some classes. Does not flush the providers, but next time we
* need to generate a provider, it will handle all of these classes. So,
* calling this method reduces the number of times we need to re-generate. */
+ @Deprecated
public void register(Iterable<Class<? extends RelNode>> classes) {
- // Register the classes and their base classes up to RelNode. Don't bother
Review comment:
There is no loss in functionality. No changes are needed.
##########
File path:
core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
##########
@@ -475,33 +356,15 @@ private static StringBuilder paramList(StringBuilder
buff, Method method) {
synchronized <M extends Metadata, H extends MetadataHandler<M>> H revise(
Class<? extends RelNode> rClass, MetadataDef<M> def) {
- if (ALL_RELS.add(rClass)) {
- HANDLERS.invalidateAll();
- }
//noinspection unchecked
return (H) create(def);
}
/** Registers some classes. Does not flush the providers, but next time we
* need to generate a provider, it will handle all of these classes. So,
* calling this method reduces the number of times we need to re-generate. */
+ @Deprecated
public void register(Iterable<Class<? extends RelNode>> classes) {
- // Register the classes and their base classes up to RelNode. Don't bother
Review comment:
There is no loss in functionality. No changes are needed. Hive and
other projects nodes are handle via instanceof for doing the dispatch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]