Java源码示例:org.apache.flink.table.functions.TableAggregateFunction

示例1
public <T, ACC> void registerAggregateFunction(
		String name,
		UserDefinedAggregateFunction<T, ACC> function,
		TypeInformation<T> resultType,
		TypeInformation<ACC> accType) {
	// check if class not Scala object
	UserFunctionsTypeHelper.validateNotSingleton(function.getClass());
	// check if class could be instantiated
	UserFunctionsTypeHelper.validateInstantiation(function.getClass());

	final FunctionDefinition definition;
	if (function instanceof AggregateFunction) {
		definition = new AggregateFunctionDefinition(
			name,
			(AggregateFunction<?, ?>) function,
			resultType,
			accType);
	} else if (function instanceof TableAggregateFunction) {
		definition = new TableAggregateFunctionDefinition(
			name,
			(TableAggregateFunction<?, ?>) function,
			resultType,
			accType);
	} else {
		throw new TableException("Unknown function class: " + function.getClass());
	}

	registerFunction(
		name,
		definition
	);
}
 
示例2
@Override
public <T, ACC> void registerFunction(String name, TableAggregateFunction<T, ACC> tableAggregateFunction) {
	TypeInformation<T> typeInfo = UserFunctionsTypeHelper.getReturnTypeOfAggregateFunction(
		tableAggregateFunction);
	TypeInformation<ACC> accTypeInfo = UserFunctionsTypeHelper
		.getAccumulatorTypeOfAggregateFunction(tableAggregateFunction);

	functionCatalog.registerAggregateFunction(
		name,
		tableAggregateFunction,
		typeInfo,
		accTypeInfo
	);
}
 
示例3
/**
 * Extracts a type inference from a {@link TableAggregateFunction}.
 */
public static TypeInference forTableAggregateFunction(
		DataTypeFactory typeFactory,
		Class<? extends TableAggregateFunction<?, ?>> function) {
	final FunctionMappingExtractor mappingExtractor = new FunctionMappingExtractor(
		typeFactory,
		function,
		UserDefinedFunctionHelper.TABLE_AGGREGATE_ACCUMULATE,
		createParameterSignatureExtraction(1),
		createGenericResultExtraction(TableAggregateFunction.class, 1),
		createGenericResultExtraction(TableAggregateFunction.class, 0),
		createParameterWithAccumulatorVerification());
	return extractTypeInference(mappingExtractor);
}
 
示例4
public <T, ACC> void registerTempSystemAggregateFunction(
		String name,
		UserDefinedAggregateFunction<T, ACC> function,
		TypeInformation<T> resultType,
		TypeInformation<ACC> accType) {
	UserDefinedFunctionHelper.prepareInstance(config, function);

	final FunctionDefinition definition;
	if (function instanceof AggregateFunction) {
		definition = new AggregateFunctionDefinition(
			name,
			(AggregateFunction<?, ?>) function,
			resultType,
			accType);
	} else if (function instanceof TableAggregateFunction) {
		definition = new TableAggregateFunctionDefinition(
			name,
			(TableAggregateFunction<?, ?>) function,
			resultType,
			accType);
	} else {
		throw new TableException("Unknown function class: " + function.getClass());
	}

	registerTempSystemFunction(
		name,
		definition
	);
}
 
示例5
@Override
public <T, ACC> void registerFunction(String name, TableAggregateFunction<T, ACC> tableAggregateFunction) {
	TypeInformation<T> typeInfo = UserDefinedFunctionHelper.getReturnTypeOfAggregateFunction(
		tableAggregateFunction);
	TypeInformation<ACC> accTypeInfo = UserDefinedFunctionHelper
		.getAccumulatorTypeOfAggregateFunction(tableAggregateFunction);

	functionCatalog.registerTempSystemAggregateFunction(
		name,
		tableAggregateFunction,
		typeInfo,
		accTypeInfo
	);
}
 
示例6
@Override
public void registerTableAggregateFunction(Object btenv, String name, Object tableAggregateFunction) {
  ((StreamTableEnvironmentImpl)(btenv)).registerFunction(name, (TableAggregateFunction) tableAggregateFunction);
}
 
示例7
@Override
public void registerTableAggregateFunction(Object btenv, String name, Object tableAggregateFunction) {
  ((StreamTableEnvironmentImpl)(btenv)).registerFunction(name, (TableAggregateFunction) tableAggregateFunction);
}
 
示例8
static TestSpec forTableAggregateFunction(Class<? extends TableAggregateFunction<?, ?>> function) {
	return forTableAggregateFunction(null, function);
}
 
示例9
static TestSpec forTableAggregateFunction(String description, Class<? extends TableAggregateFunction<?, ?>> function) {
	return new TestSpec(
		description == null ? function.getSimpleName() : description,
		() -> TypeInferenceExtractor.forTableAggregateFunction(new DataTypeFactoryMock(), function));
}
 
示例10
/**
 * Registers an {@link TableAggregateFunction} under a unique name in the TableEnvironment's
 * catalog. Registered functions can only be referenced in Table API.
 *
 * @param name The name under which the function is registered.
 * @param tableAggregateFunction The TableAggregateFunction to register.
 * @param <T> The type of the output value.
 * @tparam ACC The type of aggregate accumulator.
 */
<T, ACC> void registerFunction(String name, TableAggregateFunction<T, ACC> tableAggregateFunction);
 
示例11
/**
 * Registers an {@link TableAggregateFunction} under a unique name in the TableEnvironment's
 * catalog. Registered functions can only be referenced in Table API.
 *
 * @param name The name under which the function is registered.
 * @param tableAggregateFunction The TableAggregateFunction to register.
 * @param <T> The type of the output value.
 * @param <ACC> The type of aggregate accumulator.
 */
<T, ACC> void registerFunction(String name, TableAggregateFunction<T, ACC> tableAggregateFunction);