org.apache.calcite.util.ReflectUtil Java Examples
The following examples show how to use
org.apache.calcite.util.ReflectUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelFieldTrimmer.java From Bats with Apache License 2.0 | 5 votes |
/** * Creates a RelFieldTrimmer. * * @param validator Validator */ public RelFieldTrimmer(SqlValidator validator, RelBuilder relBuilder) { Util.discard(validator); // may be useful one day this.relBuilder = relBuilder; this.trimFieldsDispatcher = ReflectUtil.createMethodDispatcher(TrimResult.class, this, "trimFields", RelNode.class, ImmutableBitSet.class, Set.class); }
Example #2
Source File: ReflectiveFunctionBase.java From Bats with Apache License 2.0 | 5 votes |
public ParameterListBuilder addMethodParameters(Method method) { final Class<?>[] types = method.getParameterTypes(); for (int i = 0; i < types.length; i++) { add(types[i], ReflectUtil.getParameterName(method, i), ReflectUtil.isParameterOptional(method, i)); } return this; }
Example #3
Source File: RelFieldTrimmer.java From calcite with Apache License 2.0 | 5 votes |
/** * Creates a RelFieldTrimmer. * * @param validator Validator */ public RelFieldTrimmer(SqlValidator validator, RelBuilder relBuilder) { Util.discard(validator); // may be useful one day this.relBuilder = relBuilder; this.trimFieldsDispatcher = ReflectUtil.createMethodDispatcher( TrimResult.class, this, "trimFields", RelNode.class, ImmutableBitSet.class, Set.class); }
Example #4
Source File: ReflectiveFunctionBase.java From calcite with Apache License 2.0 | 5 votes |
public ParameterListBuilder addMethodParameters(Method method) { final Class<?>[] types = method.getParameterTypes(); for (int i = 0; i < types.length; i++) { add(types[i], ReflectUtil.getParameterName(method, i), ReflectUtil.isParameterOptional(method, i)); } return this; }
Example #5
Source File: DiffTestCase.java From calcite with Apache License 2.0 | 5 votes |
/** * Initializes a diff-based test. Any existing .log and .dif files * corresponding to this test case are deleted, and a new, empty .log file * is created. The default log file location is a subdirectory under the * result getTestlogRoot(), where the subdirectory name is based on the * unqualified name of the test class. The generated log file name will be * testMethodName.log, and the expected reference file will be * testMethodName.ref. * * @return Writer for log file, which caller should use as a destination for * test output to be diffed */ protected Writer openTestLog() throws Exception { File testClassDir = new File( getTestlogRoot(), ReflectUtil.getUnqualifiedClassName(getClass())); testClassDir.mkdirs(); File testLogFile = new File( testClassDir, testCaseName); return new OutputStreamWriter( openTestLogOutputStream(testLogFile), StandardCharsets.UTF_8); }
Example #6
Source File: RelToSqlConverter.java From Bats with Apache License 2.0 | 4 votes |
/** Creates a RelToSqlConverter. */ public RelToSqlConverter(SqlDialect dialect) { super(dialect); dispatcher = ReflectUtil.createMethodDispatcher(Result.class, this, "visit", RelNode.class); }
Example #7
Source File: RelToSqlConverter.java From dremio-oss with Apache License 2.0 | 4 votes |
/** * Creates a RelToSqlConverter. */ public RelToSqlConverter(SqlDialect dialect) { super(dialect); dispatcher = ReflectUtil.createMethodDispatcher(Result.class, this, "visit", RelNode.class); }
Example #8
Source File: RelToSqlConverter.java From calcite with Apache License 2.0 | 4 votes |
/** Creates a RelToSqlConverter. */ public RelToSqlConverter(SqlDialect dialect) { super(dialect); dispatcher = ReflectUtil.createMethodDispatcher(Result.class, this, "visit", RelNode.class); }
Example #9
Source File: AggregateFunctionImpl.java From calcite with Apache License 2.0 | 4 votes |
/** Creates an aggregate function, or returns null. */ public static AggregateFunctionImpl create(Class<?> clazz) { final Method initMethod = ReflectiveFunctionBase.findMethod(clazz, "init"); final Method addMethod = ReflectiveFunctionBase.findMethod(clazz, "add"); final Method mergeMethod = null; // TODO: final Method resultMethod = ReflectiveFunctionBase.findMethod( clazz, "result"); if (initMethod != null && addMethod != null) { // A is return type of init by definition final Class<?> accumulatorType = initMethod.getReturnType(); // R is return type of result by definition final Class<?> resultType = resultMethod != null ? resultMethod.getReturnType() : accumulatorType; // V is remaining args of add by definition final List<Class> addParamTypes = ImmutableList.copyOf((Class[]) addMethod.getParameterTypes()); if (addParamTypes.isEmpty() || addParamTypes.get(0) != accumulatorType) { throw RESOURCE.firstParameterOfAdd(clazz.getName()).ex(); } final ReflectiveFunctionBase.ParameterListBuilder params = ReflectiveFunctionBase.builder(); final ImmutableList.Builder<Class<?>> valueTypes = ImmutableList.builder(); for (int i = 1; i < addParamTypes.size(); i++) { final Class type = addParamTypes.get(i); final String name = ReflectUtil.getParameterName(addMethod, i); final boolean optional = ReflectUtil.isParameterOptional(addMethod, i); params.add(type, name, optional); valueTypes.add(type); } // A init() // A add(A, V) // A merge(A, A) // R result(A) // TODO: check add returns A // TODO: check merge returns A // TODO: check merge args are (A, A) // TODO: check result args are (A) return new AggregateFunctionImpl(clazz, params.build(), valueTypes.build(), accumulatorType, resultType, initMethod, addMethod, mergeMethod, resultMethod); } return null; }