Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5302F200B9B for ; Wed, 7 Sep 2016 01:27:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 51B2B160AA9; Tue, 6 Sep 2016 23:27:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A0C96160ACE for ; Wed, 7 Sep 2016 01:27:21 +0200 (CEST) Received: (qmail 80271 invoked by uid 500); 6 Sep 2016 23:27:20 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 80066 invoked by uid 99); 6 Sep 2016 23:27:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 23:27:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 8C7032C1B80 for ; Tue, 6 Sep 2016 23:27:20 +0000 (UTC) Date: Tue, 6 Sep 2016 23:27:20 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-4726) Dynamic UDFs support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 06 Sep 2016 23:27:22 -0000 [ https://issues.apache.org/jira/browse/DRILL-4726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15468941#comment-15468941 ] ASF GitHub Bot commented on DRILL-4726: --------------------------------------- Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/574#discussion_r77737152 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionRegistry.java --- @@ -64,62 +76,134 @@ .put("CONVERT_FROM", Pair.of(2, 2)) .put("FLATTEN", Pair.of(1, 1)).build(); + /** Registers all functions present in Drill classpath on start-up. All functions will be marked as built-in.*/ public DrillFunctionRegistry(ScanResult classpathScan) { + validate(BUILT_IN, classpathScan); + register(BUILT_IN, classpathScan, this.getClass().getClassLoader()); + if (logger.isTraceEnabled()) { + StringBuilder allFunctions = new StringBuilder(); + for (DrillFuncHolder method: registryHolder.getAllFunctionsWithHolders().values()) { + allFunctions.append(method.toString()).append("\n"); + } + logger.trace("Registered functions: [\n{}]", allFunctions); + } + } + + /** + * Validates all functions, present in jars. + * Will throw {@link FunctionValidationException} if: + * 1. Jar with the same name has been already registered. + * 2. Conflicting function with the similar signature is found. + * 3. Aggregating function is not deterministic. + * + * @return list of validated functions + */ + public List validate(String jarName, ScanResult classpathScan) { + List functions = Lists.newArrayList(); FunctionConverter converter = new FunctionConverter(); List providerClasses = classpathScan.getAnnotatedClasses(); - // Hash map to prevent registering functions with exactly matching signatures - // key: Function Name + Input's Major Type - // value: Class name where function is implemented - // - final Map functionSignatureMap = new HashMap<>(); + if (registryHolder.containsJar(jarName)) { + throw new FunctionValidationException(String.format("Jar %s is already registered", jarName)); + } --- End diff -- Race condition. The check holds, then releases a lock. We proceed assuming the function is unique. But, another thread could be executing exactly in parallel, has also determined that the (same) function does not exist, and the two threads will now do the registration in parallel. Should this method be synchronized? > Dynamic UDFs support > -------------------- > > Key: DRILL-4726 > URL: https://issues.apache.org/jira/browse/DRILL-4726 > Project: Apache Drill > Issue Type: New Feature > Affects Versions: 1.6.0 > Reporter: Arina Ielchiieva > Assignee: Arina Ielchiieva > Fix For: Future > > > Allow register UDFs without restart of Drillbits. > Design is described in document below: > https://docs.google.com/document/d/1FfyJtWae5TLuyheHCfldYUpCdeIezR2RlNsrOTYyAB4/edit?usp=sharing -- This message was sent by Atlassian JIRA (v6.3.4#6332)