You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2022/02/08 10:27:14 UTC
[ignite] branch sql-calcite updated: IGNITE-16119 Refactor IgniteBuiltInMethod and IgniteMethod classes - Fixes #9803.
This is an automated email from the ASF dual-hosted git repository.
alexpl pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/sql-calcite by this push:
new fd839a3 IGNITE-16119 Refactor IgniteBuiltInMethod and IgniteMethod classes - Fixes #9803.
fd839a3 is described below
commit fd839a3508c90d2e6df3070140174335d84e10ae
Author: Aleksey Plekhanov <pl...@gmail.com>
AuthorDate: Tue Feb 8 13:21:04 2022 +0300
IGNITE-16119 Refactor IgniteBuiltInMethod and IgniteMethod classes - Fixes #9803.
Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
.../calcite/exec/exp/IgniteBuiltInMethod.java | 60 ----------------------
.../query/calcite/exec/exp/RexImpTable.java | 5 +-
.../query/calcite/exec/exp/RexToLixTranslator.java | 9 ++--
.../query/calcite/util/IgniteMethod.java | 38 ++++++++++++--
4 files changed, 42 insertions(+), 70 deletions(-)
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteBuiltInMethod.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteBuiltInMethod.java
deleted file mode 100644
index 5187386..0000000
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/IgniteBuiltInMethod.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.ignite.internal.processors.query.calcite.exec.exp;
-
-import java.lang.reflect.Method;
-
-import org.apache.calcite.avatica.util.ByteString;
-import org.apache.calcite.linq4j.tree.Types;
-import org.apache.calcite.sql.SqlIntervalQualifier;
-import org.apache.calcite.sql.parser.SqlParserUtil;
-
-/**
- * Built-in methods.
- */
-public enum IgniteBuiltInMethod {
- /** */
- SYSTEM_RANGE2(IgniteSqlFunctions.class, "systemRange", Object.class, Object.class),
-
- /** */
- SYSTEM_RANGE3(IgniteSqlFunctions.class, "systemRange", Object.class, Object.class, Object.class),
-
- /** */
- PARSE_INTERVAL_YEAR_MONTH(SqlParserUtil.class, "intervalToMonths", String.class, SqlIntervalQualifier.class),
-
- /** */
- PARSE_INTERVAL_DAY_TIME(SqlParserUtil.class, "intervalToMillis", String.class, SqlIntervalQualifier.class),
-
- /** */
- BYTESTRING_TO_STRING(IgniteSqlFunctions.class, "toString", ByteString.class),
-
- /** */
- STRING_TO_BYTESTRING(IgniteSqlFunctions.class, "toByteString", String.class);
-
- /** */
- public final Method method;
-
- /** */
- IgniteBuiltInMethod(Method method) {
- this.method = method;
- }
-
- /** Defines a method. */
- IgniteBuiltInMethod(Class clazz, String methodName, Class... argumentTypes) {
- this(Types.lookupMethod(clazz, methodName, argumentTypes));
- }
-}
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexImpTable.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexImpTable.java
index 6c8ae50..cf9aa9b 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexImpTable.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexImpTable.java
@@ -72,6 +72,7 @@ import org.apache.calcite.sql.validate.SqlUserDefinedTableFunction;
import org.apache.calcite.sql.validate.SqlUserDefinedTableMacro;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.Util;
+import org.apache.ignite.internal.processors.query.calcite.util.IgniteMethod;
import static org.apache.calcite.adapter.enumerable.EnumUtils.generateCollatorExpression;
import static org.apache.calcite.linq4j.tree.ExpressionType.Add;
@@ -1676,11 +1677,11 @@ public class RexImpTable {
return Expressions.call(BuiltInMethod.LOCAL_TIME.method, root);
else if (op == SYSTEM_RANGE) {
if (call.getOperands().size() == 2)
- return createTableFunctionImplementor(IgniteBuiltInMethod.SYSTEM_RANGE2.method)
+ return createTableFunctionImplementor(IgniteMethod.SYSTEM_RANGE2.method())
.implement(translator, call, NullAs.NULL);
if (call.getOperands().size() == 3)
- return createTableFunctionImplementor(IgniteBuiltInMethod.SYSTEM_RANGE3.method)
+ return createTableFunctionImplementor(IgniteMethod.SYSTEM_RANGE3.method())
.implement(translator, call, NullAs.NULL);
}
else if (op == TYPEOF) {
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexToLixTranslator.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexToLixTranslator.java
index 9962507..19f1b48 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexToLixTranslator.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/RexToLixTranslator.java
@@ -70,6 +70,7 @@ import org.apache.calcite.sql.validate.SqlConformance;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.ControlFlowException;
import org.apache.calcite.util.Pair;
+import org.apache.ignite.internal.processors.query.calcite.util.IgniteMethod;
import static org.apache.calcite.sql.fun.SqlStdOperatorTable.CASE;
import static org.apache.calcite.sql.fun.SqlStdOperatorTable.SEARCH;
@@ -506,7 +507,7 @@ public class RexToLixTranslator implements RexVisitor<RexToLixTranslator.Result>
case VARBINARY:
convert = RexImpTable.optimize2(
operand,
- Expressions.call(IgniteBuiltInMethod.BYTESTRING_TO_STRING.method, operand));
+ Expressions.call(IgniteMethod.BYTESTRING_TO_STRING.method(), operand));
break;
}
break;
@@ -528,8 +529,8 @@ public class RexToLixTranslator implements RexVisitor<RexToLixTranslator.Result>
SqlIntervalQualifier intervalQualifier = targetType.getIntervalQualifier();
Method method = intervalQualifier.isYearMonth() ?
- IgniteBuiltInMethod.PARSE_INTERVAL_YEAR_MONTH.method :
- IgniteBuiltInMethod.PARSE_INTERVAL_DAY_TIME.method;
+ IgniteMethod.PARSE_INTERVAL_YEAR_MONTH.method() :
+ IgniteMethod.PARSE_INTERVAL_DAY_TIME.method();
convert = Expressions.call(
method,
@@ -548,7 +549,7 @@ public class RexToLixTranslator implements RexVisitor<RexToLixTranslator.Result>
case VARBINARY:
switch (sourceType.getSqlTypeName().getFamily()) {
case CHARACTER:
- convert = Expressions.call(IgniteBuiltInMethod.STRING_TO_BYTESTRING.method, operand);
+ convert = Expressions.call(IgniteMethod.STRING_TO_BYTESTRING.method(), operand);
}
break;
}
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteMethod.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteMethod.java
index b1ac6cd..8e065c7 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteMethod.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteMethod.java
@@ -18,10 +18,14 @@
package org.apache.ignite.internal.processors.query.calcite.util;
import java.lang.reflect.Method;
+import org.apache.calcite.avatica.util.ByteString;
import org.apache.calcite.linq4j.tree.Types;
+import org.apache.calcite.sql.SqlIntervalQualifier;
+import org.apache.calcite.sql.parser.SqlParserUtil;
import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext;
import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler;
import org.apache.ignite.internal.processors.query.calcite.exec.exp.BiScalar;
+import org.apache.ignite.internal.processors.query.calcite.exec.exp.IgniteSqlFunctions;
import org.apache.ignite.internal.processors.query.calcite.exec.exp.SingleScalar;
import org.apache.ignite.internal.processors.query.calcite.metadata.IgniteMetadata.FragmentMappingMetadata;
import org.apache.ignite.internal.processors.query.calcite.prepare.MappingQueryContext;
@@ -32,23 +36,49 @@ import org.apache.ignite.internal.processors.query.calcite.prepare.MappingQueryC
public enum IgniteMethod {
/** See {@link RowHandler#set(int, Object, Object)} */
ROW_HANDLER_SET(RowHandler.class, "set", int.class, Object.class, Object.class),
+
/** See {@link RowHandler#get(int, Object)} */
ROW_HANDLER_GET(RowHandler.class, "get", int.class, Object.class),
+
/** See {@link Commons#getFieldFromBiRows(RowHandler, int, Object, Object)} */
ROW_HANDLER_BI_GET(Commons.class, "getFieldFromBiRows", RowHandler.class, int.class,
Object.class, Object.class),
+
/** See {@link ExecutionContext#rowHandler()} */
CONTEXT_ROW_HANDLER(ExecutionContext.class, "rowHandler"),
+
/** See {@link ExecutionContext#unspecifiedValue()} */
CONTEXT_UNSPECIFIED_VALUE(ExecutionContext.class, "unspecifiedValue"),
+
/** See {@link ExecutionContext#getCorrelated(int)} */
CONTEXT_GET_CORRELATED_VALUE(ExecutionContext.class, "getCorrelated", int.class),
+
/** See {@link SingleScalar#execute(ExecutionContext, Object, Object)} */
SCALAR_EXECUTE(SingleScalar.class, "execute", ExecutionContext.class, Object.class, Object.class),
+
/** See {@link BiScalar#execute(ExecutionContext, Object, Object, Object)} */
BI_SCALAR_EXECUTE(BiScalar.class, "execute", ExecutionContext.class, Object.class, Object.class, Object.class),
+
/** See {@link FragmentMappingMetadata#fragmentMapping(MappingQueryContext)} */
- FRAGMENT_MAPPING(FragmentMappingMetadata.class, "fragmentMapping", MappingQueryContext.class);
+ FRAGMENT_MAPPING(FragmentMappingMetadata.class, "fragmentMapping", MappingQueryContext.class),
+
+ /** See {@link IgniteSqlFunctions#systemRange(Object, Object)} */
+ SYSTEM_RANGE2(IgniteSqlFunctions.class, "systemRange", Object.class, Object.class),
+
+ /** See {@link IgniteSqlFunctions#systemRange(Object, Object, Object)} */
+ SYSTEM_RANGE3(IgniteSqlFunctions.class, "systemRange", Object.class, Object.class, Object.class),
+
+ /** See {@link SqlParserUtil#intervalToMonths(String, SqlIntervalQualifier)} */
+ PARSE_INTERVAL_YEAR_MONTH(SqlParserUtil.class, "intervalToMonths", String.class, SqlIntervalQualifier.class),
+
+ /** See {@link SqlParserUtil#intervalToMillis(String, SqlIntervalQualifier)} */
+ PARSE_INTERVAL_DAY_TIME(SqlParserUtil.class, "intervalToMillis", String.class, SqlIntervalQualifier.class),
+
+ /** See {@link IgniteSqlFunctions#toString(ByteString)} */
+ BYTESTRING_TO_STRING(IgniteSqlFunctions.class, "toString", ByteString.class),
+
+ /** See {@link IgniteSqlFunctions#toByteString(String)} */
+ STRING_TO_BYTESTRING(IgniteSqlFunctions.class, "toByteString", String.class);
/** */
private final Method method;
@@ -56,10 +86,10 @@ public enum IgniteMethod {
/**
* @param clazz Class where to lookup method.
* @param methodName Method name.
- * @param argumentTypes Method parameters types.
+ * @param argTypes Method parameters types.
*/
- IgniteMethod(Class<?> clazz, String methodName, Class<?>... argumentTypes) {
- method = Types.lookupMethod(clazz, methodName, argumentTypes);
+ IgniteMethod(Class<?> clazz, String methodName, Class<?>... argTypes) {
+ method = Types.lookupMethod(clazz, methodName, argTypes);
}
/**