You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by GitBox <gi...@apache.org> on 2019/10/16 02:14:45 UTC

[GitHub] [samza] shanthoosh commented on a change in pull request #1192: SAMZA-2354: Improve UDF discovery in samza-sql.

shanthoosh commented on a change in pull request #1192: SAMZA-2354: Improve UDF discovery in samza-sql.
URL: https://github.com/apache/samza/pull/1192#discussion_r335250074
 
 

 ##########
 File path: samza-sql/src/main/java/org/apache/samza/sql/udf/ReflectionBasedUdfResolver.java
 ##########
 @@ -0,0 +1,97 @@
+/*
+ * 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.samza.sql.udf;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.lang3.reflect.MethodUtils;
+import org.apache.samza.SamzaException;
+import org.apache.samza.config.Config;
+import org.apache.samza.sql.interfaces.UdfMetadata;
+import org.apache.samza.sql.interfaces.UdfResolver;
+import org.apache.samza.sql.schema.SamzaSqlFieldType;
+import org.apache.samza.sql.udfs.SamzaSqlUdf;
+import org.apache.samza.sql.udfs.SamzaSqlUdfMethod;
+import org.reflections.Reflections;
+import org.reflections.util.ConfigurationBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An UDF resolver implementation that uses reflection to discover the subtypes
+ * of the {@link SamzaSqlUdf} from the classpath. Performs the validation to
+ * ensure that all subtypes of {@link SamzaSqlUdf} extend and implement the
+ * method annotated with {@link SamzaSqlUdfMethod}.
+ */
+public class ReflectionBasedUdfResolver implements UdfResolver {
 
 Review comment:
   By selectively searching for UDF's  only in selected package-prefixes from class-path for UDF's, it's a very minimal over-head.  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services