use of org.apache.samza.sql.udf.ReflectionBasedUdfResolver in project samza by apache.
the class SamzaSqlApplicationConfig method createUdfResolver.
private UdfResolver createUdfResolver(Map<String, String> config) {
String udfResolveValue = config.get(CFG_UDF_RESOLVER);
Validate.notEmpty(udfResolveValue, "udfResolver config is not set or empty");
HashMap<String, String> domainConfig = getDomainProperties(config, String.format(CFG_FMT_UDF_RESOLVER_DOMAIN, udfResolveValue), false);
Properties props = new Properties();
props.putAll(domainConfig);
HashMap<String, String> udfConfig = getDomainProperties(config, CFG_UDF_CONFIG_DOMAIN, false);
// TODO: SAMZA-2355: Make the UDFResolver pluggable.
return new ReflectionBasedUdfResolver(new MapConfig(udfConfig));
}
use of org.apache.samza.sql.udf.ReflectionBasedUdfResolver in project samza by apache.
the class TestReflectionBasedUdfResolver method testUDfResolverShouldReturnAllUDFInClassPath.
@Test
public void testUDfResolverShouldReturnAllUDFInClassPath() throws NoSuchMethodException {
Config config = new MapConfig(ImmutableMap.of("samza.sql.udf.resolver.package.filter", "org.apache.samza.sql.udf.impl"));
ReflectionBasedUdfResolver reflectionBasedUdfResolver = new ReflectionBasedUdfResolver(config);
Collection<UdfMetadata> udfMetadataList = reflectionBasedUdfResolver.getUdfs();
Method method = TestSamzaSqlUdf.class.getMethod("execute", String.class);
UdfMetadata udfMetadata = new UdfMetadata("TestSamzaSqlUdf", "Test samza sql udf implementation", method, new MapConfig(), ImmutableList.of(SamzaSqlFieldType.STRING), SamzaSqlFieldType.STRING, true);
Assert.assertArrayEquals(new UdfMetadata[] { udfMetadata }, udfMetadataList.toArray(new UdfMetadata[0]));
}
use of org.apache.samza.sql.udf.ReflectionBasedUdfResolver in project samza by apache.
the class TestReflectionBasedUdfResolver method testShouldReturnNothingWhenNoUDFIsInPackagePrefix.
@Test
public void testShouldReturnNothingWhenNoUDFIsInPackagePrefix() {
Config config = new MapConfig(ImmutableMap.of("samza.sql.udf.resolver.package.prefix", "org.apache.samza.udf.blah.blah"));
ReflectionBasedUdfResolver reflectionBasedUdfResolver = new ReflectionBasedUdfResolver(config);
Collection<UdfMetadata> udfMetadataList = reflectionBasedUdfResolver.getUdfs();
Assert.assertEquals(0, udfMetadataList.size());
}
Aggregations