{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/presto/pulls/comments/64132375","id":64132375,"diff_hunk":"@@ -48,98 +57,69 @@\n \n public class AggregationCompiler\n {\n-    private final TypeManager typeManager;\n-\n-    public AggregationCompiler()\n+    private AggregationCompiler()\n     {\n-        this(new TypeRegistry());\n     }\n \n-    public AggregationCompiler(TypeManager typeManager)\n+    // This function should only be used for function matching for testing purposes.\n+    // General purpose function matching is done through FunctionRegistry.\n+    public static BindableAggregationFunction generateAggregationBindableFunction(Class<?> clazz)\n     {\n-        this.typeManager = requireNonNull(typeManager, \"typeManager is null\");\n-    }\n-\n-    private static List<Method> findPublicStaticMethodsWithAnnotation(Class<?> clazz, Class<?> annotationClass)\n-    {\n-        ImmutableList.Builder<Method> methods = ImmutableList.builder();\n-        for (Method method : clazz.getMethods()) {\n-            for (Annotation annotation : method.getAnnotations()) {\n-                if (annotationClass.isInstance(annotation)) {\n-                    checkArgument(Modifier.isStatic(method.getModifiers()) && Modifier.isPublic(method.getModifiers()), \"%s annotated with %s must be static and public\", method.getName(), annotationClass.getSimpleName());\n-                    methods.add(method);\n-                }\n-            }\n-        }\n-        return methods.build();\n-    }\n-\n-    public InternalAggregationFunction generateAggregationFunction(Class<?> clazz)\n-    {\n-        List<InternalAggregationFunction> aggregations = generateAggregationFunctions(clazz);\n+        List<BindableAggregationFunction> aggregations = generateBindableAggregationFunctions(clazz);\n         checkArgument(aggregations.size() == 1, \"More than one aggregation function found\");\n         return aggregations.get(0);\n     }\n \n-    public InternalAggregationFunction generateAggregationFunction(Class<?> clazz, Type returnType, List<Type> argumentTypes)\n+    // This function should only be used for function matching for testing purposes.\n+    // General purpose function matching is done through FunctionRegistry.\n+    public static BindableAggregationFunction generateAggregationBindableFunction(Class<?> clazz, TypeSignature returnType, List<TypeSignature> argumentTypes)\n     {\n         requireNonNull(returnType, \"returnType is null\");\n         requireNonNull(argumentTypes, \"argumentTypes is null\");\n-        for (InternalAggregationFunction aggregation : generateAggregationFunctions(clazz)) {\n-            if (aggregation.getFinalType().equals(returnType) && aggregation.getParameterTypes().equals(argumentTypes)) {\n+        for (BindableAggregationFunction aggregation : generateBindableAggregationFunctions(clazz)) {\n+            if (aggregation.getSignature().getReturnType().equals(returnType) &&\n+                    aggregation.getSignature().getArgumentTypes().equals(argumentTypes)) {\n                 return aggregation;\n             }\n         }\n         throw new IllegalArgumentException(String.format(\"No method with return type %s and arguments %s\", returnType, argumentTypes));\n     }\n \n-    public List<InternalAggregationFunction> generateAggregationFunctions(Class<?> clazz)\n+    public static List<BindableAggregationFunction> generateBindableAggregationFunctions(Class<?> aggregationDefinition)\n     {\n-        AggregationFunction aggregationAnnotation = clazz.getAnnotation(AggregationFunction.class);\n+        AggregationFunction aggregationAnnotation = aggregationDefinition.getAnnotation(AggregationFunction.class);\n         requireNonNull(aggregationAnnotation, \"aggregationAnnotation is null\");\n \n-        DynamicClassLoader classLoader = new DynamicClassLoader(clazz.getClassLoader());\n+        DynamicClassLoader classLoader = new DynamicClassLoader(aggregationDefinition.getClassLoader());\n+\n+        ImmutableList.Builder<BindableAggregationFunction> builder = ImmutableList.builder();\n \n-        ImmutableList.Builder<InternalAggregationFunction> builder = ImmutableList.builder();\n-        for (Class<?> stateClass : getStateClasses(clazz)) {\n+        for (Class<?> stateClass : getStateClasses(aggregationDefinition)) {\n             AccumulatorStateSerializer<?> stateSerializer = new StateCompiler().generateStateSerializer(stateClass, classLoader);\n-            Type intermediateType = stateSerializer.getSerializedType();\n-            Method intermediateInputFunction = getIntermediateInputFunction(clazz, stateClass);\n-            Method combineFunction = getCombineFunction(clazz, stateClass);\n-            AccumulatorStateFactory<?> stateFactory = new StateCompiler().generateStateFactory(stateClass, classLoader);\n \n-            for (Method outputFunction : getOutputFunctions(clazz, stateClass)) {\n-                for (Method inputFunction : getInputFunctions(clazz, stateClass)) {\n+            for (Method outputFunction : getOutputFunctions(aggregationDefinition, stateClass)) {\n+                for (Method inputFunction : getInputFunctions(aggregationDefinition, stateClass)) {\n                     for (String name : getNames(outputFunction, aggregationAnnotation)) {","path":"presto-main/src/main/java/com/facebook/presto/operator/aggregation/AggregationCompiler.java","position":124,"original_position":124,"commit_id":"a190d973630fe7afae761ddf7f813915e090b20d","original_commit_id":"2483483777cc527c80692a609805aaf0a0ed6f2a","user":{"login":"fiedukow","id":297223,"avatar_url":"https://avatars.githubusercontent.com/u/297223?v=3","gravatar_id":"","url":"https://api.github.com/users/fiedukow","html_url":"https://github.com/fiedukow","followers_url":"https://api.github.com/users/fiedukow/followers","following_url":"https://api.github.com/users/fiedukow/following{/other_user}","gists_url":"https://api.github.com/users/fiedukow/gists{/gist_id}","starred_url":"https://api.github.com/users/fiedukow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiedukow/subscriptions","organizations_url":"https://api.github.com/users/fiedukow/orgs","repos_url":"https://api.github.com/users/fiedukow/repos","events_url":"https://api.github.com/users/fiedukow/events{/privacy}","received_events_url":"https://api.github.com/users/fiedukow/received_events","type":"User","site_admin":false},"body":"Not that I introduced any new ;-)\r\nbtw. I think they are not avoidable as we really need to generate aggregations for:\r\n - each class\r\n - each output function\r\n - each input function\r\n - each alias","created_at":"2016-05-21T10:15:09Z","updated_at":"2016-05-21T10:15:09Z","html_url":"https://github.com/Teradata/presto/pull/207#discussion_r64132375","pull_request_url":"https://api.github.com/repos/Teradata/presto/pulls/207","_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments/64132375"},"html":{"href":"https://github.com/Teradata/presto/pull/207#discussion_r64132375"},"pull_request":{"href":"https://api.github.com/repos/Teradata/presto/pulls/207"}}},"pull_request":{"url":"https://api.github.com/repos/Teradata/presto/pulls/207","id":70711016,"html_url":"https://github.com/Teradata/presto/pull/207","diff_url":"https://github.com/Teradata/presto/pull/207.diff","patch_url":"https://github.com/Teradata/presto/pull/207.patch","issue_url":"https://api.github.com/repos/Teradata/presto/issues/207","number":207,"state":"open","locked":false,"title":"Make FunctionRegisty to use bindable aggregate functions.","user":{"login":"fiedukow","id":297223,"avatar_url":"https://avatars.githubusercontent.com/u/297223?v=3","gravatar_id":"","url":"https://api.github.com/users/fiedukow","html_url":"https://github.com/fiedukow","followers_url":"https://api.github.com/users/fiedukow/followers","following_url":"https://api.github.com/users/fiedukow/following{/other_user}","gists_url":"https://api.github.com/users/fiedukow/gists{/gist_id}","starred_url":"https://api.github.com/users/fiedukow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiedukow/subscriptions","organizations_url":"https://api.github.com/users/fiedukow/orgs","repos_url":"https://api.github.com/users/fiedukow/repos","events_url":"https://api.github.com/users/fiedukow/events{/privacy}","received_events_url":"https://api.github.com/users/fiedukow/received_events","type":"User","site_admin":false},"body":"This is continuation of https://github.com/Teradata/presto/pull/202\r\n@arhimondr ","created_at":"2016-05-19T15:06:24Z","updated_at":"2016-05-21T10:15:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1312820c4537e50e11659ad06bb072605360542","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/presto/pulls/207/commits","review_comments_url":"https://api.github.com/repos/Teradata/presto/pulls/207/comments","review_comment_url":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/presto/issues/207/comments","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/a190d973630fe7afae761ddf7f813915e090b20d","head":{"label":"Teradata:af/SWARM-2701/1","ref":"af/SWARM-2701/1","sha":"a190d973630fe7afae761ddf7f813915e090b20d","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata's Certified Version of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-05-12T22:16:53Z","pushed_at":"2016-05-21T09:02:07Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":140114,"stargazers_count":48,"watchers_count":48,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":6,"forks":8,"open_issues":6,"watchers":48,"default_branch":"master"}},"base":{"label":"Teradata:decimal_coercions_part_2","ref":"decimal_coercions_part_2","sha":"c4d269d11435e0015a3dbb8e474a20003af4a925","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata's Certified Version of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-05-12T22:16:53Z","pushed_at":"2016-05-21T09:02:07Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":140114,"stargazers_count":48,"watchers_count":48,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":6,"forks":8,"open_issues":6,"watchers":48,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/207"},"html":{"href":"https://github.com/Teradata/presto/pull/207"},"issue":{"href":"https://api.github.com/repos/Teradata/presto/issues/207"},"comments":{"href":"https://api.github.com/repos/Teradata/presto/issues/207/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/presto/pulls/207/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/presto/pulls/207/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/presto/statuses/a190d973630fe7afae761ddf7f813915e090b20d"}}}}
{"actor":{"display_login":"fiedukow"}}