Java源码示例:org.apache.flink.table.descriptors.FunctionDescriptorValidator

示例1
@Override
protected void validate(DescriptorProperties properties) {
	new FunctionDescriptorValidator().validate(properties);
}
 
示例2
@Override
protected void validate(DescriptorProperties properties) {
	new FunctionDescriptorValidator().validate(properties);
}
 
示例3
/**
 * Creates a user-defined function with the given properties.
 *
 * @param descriptor the descriptor that describes a function
 * @param classLoader the class loader to load the function and its parameter's classes
 * @param performValidation whether or not the descriptor should be validated
 * @param config the table configuration used to create the function
 * @return the generated user-defined function
 */
public static UserDefinedFunction createFunction(
		FunctionDescriptor descriptor,
		ClassLoader classLoader,
		boolean performValidation,
		ReadableConfig config) {

	DescriptorProperties properties = new DescriptorProperties(true);
	properties.putProperties(descriptor.toProperties());

	// validate
	if (performValidation) {
		new FunctionDescriptorValidator().validate(properties);
	}

	Object instance;
	switch (properties.getString(FunctionDescriptorValidator.FROM)) {
		case FunctionDescriptorValidator.FROM_VALUE_CLASS:
			// instantiate
			instance = generateInstance(
				HierarchyDescriptorValidator.EMPTY_PREFIX,
				properties,
				classLoader);
			break;
		case FunctionDescriptorValidator.FROM_VALUE_PYTHON:
			String fullyQualifiedName = properties.getString(PythonFunctionValidator.FULLY_QUALIFIED_NAME);
			instance = PythonFunctionUtils.getPythonFunction(fullyQualifiedName, config);
			break;
		default:
			throw new ValidationException(String.format(
					"Unsupported function descriptor: %s",
					properties.getString(FunctionDescriptorValidator.FROM)));
	}

	if (!UserDefinedFunction.class.isAssignableFrom(instance.getClass())) {
		throw new ValidationException(String.format(
				"Instantiated class '%s' is not a user-defined function.",
				instance.getClass().getName()));
	}
	return (UserDefinedFunction) instance;
}
 
示例4
private boolean containsPythonFunction(Environment environment) {
	return environment.getFunctions().values().stream().anyMatch(f ->
		FunctionDescriptorValidator.FROM_VALUE_PYTHON.equals(
			f.getDescriptor().toProperties().get(FunctionDescriptorValidator.FROM)));
}
 
示例5
@Override
protected void validate(DescriptorProperties properties) {
	new FunctionDescriptorValidator().validate(properties);
}