You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/08/13 14:08:18 UTC

[GitHub] [drill] arina-ielchiieva commented on a change in pull request #1841: Drill-7344: Add Geo-IP Functions

arina-ielchiieva commented on a change in pull request #1841: Drill-7344: Add Geo-IP Functions
URL: https://github.com/apache/drill/pull/1841#discussion_r313416962
 
 

 ##########
 File path: contrib/udfs/src/main/java/org/apache/drill/exec/udfs/ProtocolFunctions.java
 ##########
 @@ -0,0 +1,368 @@
+/*
+ * 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.drill.exec.udfs;
+
+import io.netty.buffer.DrillBuf;
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.annotations.Workspace;
+import org.apache.drill.exec.expr.holders.IntHolder;
+import org.apache.drill.exec.expr.holders.VarCharHolder;
+
+import javax.inject.Inject;
+
+public class ProtocolFunctions {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ProtocolFunctions.class);
+
+  private ProtocolFunctions() {
+  }
+
+  /* This function takes a port number and protocol and returns the associated service name, and "Unknown if there is an error */
+
+  @FunctionTemplate(name = "get_service_name", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+
+  public static class ServiceNameLookup implements DrillSimpleFunc {
+    @Param
+    IntHolder portNumber;
+
+    @Param
+    VarCharHolder protocol;
+
+    @Output
+    VarCharHolder out;
+
+    @Inject
+    DrillBuf buffer;
+
+    @Workspace
+    java.util.HashMap<String, String> serviceInfo;
+
+
+    @Override
+    public void setup() {
+      java.io.InputStream serviceFile = getClass().getClassLoader().getResourceAsStream("service-names-port-numbers.csv");
 
 Review comment:
   Not sure this a good idea. First the source of file is unknown, secondly is there is not lib that provides this functionality, I am not sure we should provide such function in Drill.

----------------------------------------------------------------
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