{"action":"created","comment":{"url":"https://api.github.com/repos/prestodb/presto/pulls/comments/61160231","id":61160231,"diff_hunk":"@@ -0,0 +1,77 @@\n+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.facebook.presto.execution.resourceGroups;\n+\n+import com.facebook.presto.SessionRepresentation;\n+import com.fasterxml.jackson.annotation.JsonCreator;\n+\n+import java.util.Objects;\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+\n+import static com.google.common.base.Preconditions.checkArgument;\n+import static java.util.Objects.requireNonNull;\n+\n+public class ResourceGroupNameTemplate\n+{\n+    private static final Pattern USER_PATTERN = Pattern.compile(Pattern.quote(\"${USER}\"));\n+    private static final Pattern SOURCE_PATTERN = Pattern.compile(Pattern.quote(\"${SOURCE}\"));\n+    private static final Pattern PARAMETER_PATTERN = Pattern.compile(\"\\\\$\\\\{(.*?)\\\\}\");\n+\n+    private final String name;\n+\n+    @JsonCreator\n+    public ResourceGroupNameTemplate(String name)\n+    {\n+        this.name = requireNonNull(name, \"name is null\");\n+        checkArgument(!name.isEmpty(), \"Resource group name is empty\");\n+        checkArgument(ResourceGroupId.REGEXP.matcher(name).matches(), \"Invalid resource group name. '%s' contains a '.'\", name);\n+        Matcher matcher = PARAMETER_PATTERN.matcher(name);\n+        while (matcher.find()) {\n+            String group = matcher.group(1);\n+            checkArgument(group.equals(\"USER\") || group.equals(\"SOURCE\"), \"Unsupported template parameter: ${%s}\", group);\n+        }\n+    }\n+\n+    public String expandTemplate(SessionRepresentation session)\n+    {\n+        String expanded = USER_PATTERN.matcher(name).replaceAll(session.getUser());\n+        return SOURCE_PATTERN.matcher(expanded).replaceAll(session.getSource().orElse(\"\"));","path":"presto-main/src/main/java/com/facebook/presto/execution/resourceGroups/ResourceGroupNameTemplate.java","position":50,"original_position":50,"commit_id":"e052d38e876ebb0c45f5d87c9466e2ed490d5a5c","original_commit_id":"05fc108762bd15eceb54a65e974fa85c64caab9b","user":{"login":"dain","id":58298,"avatar_url":"https://avatars.githubusercontent.com/u/58298?v=3","gravatar_id":"","url":"https://api.github.com/users/dain","html_url":"https://github.com/dain","followers_url":"https://api.github.com/users/dain/followers","following_url":"https://api.github.com/users/dain/following{/other_user}","gists_url":"https://api.github.com/users/dain/gists{/gist_id}","starred_url":"https://api.github.com/users/dain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dain/subscriptions","organizations_url":"https://api.github.com/users/dain/orgs","repos_url":"https://api.github.com/users/dain/repos","events_url":"https://api.github.com/users/dain/events{/privacy}","received_events_url":"https://api.github.com/users/dain/received_events","type":"User","site_admin":false},"body":"If you remember if the name contains either of these it would be faster... I don't think it really matters","created_at":"2016-04-26T20:41:05Z","updated_at":"2016-04-26T20:41:05Z","html_url":"https://github.com/prestodb/presto/pull/5120#discussion_r61160231","pull_request_url":"https://api.github.com/repos/prestodb/presto/pulls/5120","_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments/61160231"},"html":{"href":"https://github.com/prestodb/presto/pull/5120#discussion_r61160231"},"pull_request":{"href":"https://api.github.com/repos/prestodb/presto/pulls/5120"}}},"pull_request":{"url":"https://api.github.com/repos/prestodb/presto/pulls/5120","id":67918450,"html_url":"https://github.com/prestodb/presto/pull/5120","diff_url":"https://github.com/prestodb/presto/pull/5120.diff","patch_url":"https://github.com/prestodb/presto/pull/5120.patch","issue_url":"https://api.github.com/repos/prestodb/presto/issues/5120","number":5120,"state":"open","locked":false,"title":"Add new config file format for resource groups","user":{"login":"cberner","id":842688,"avatar_url":"https://avatars.githubusercontent.com/u/842688?v=3","gravatar_id":"","url":"https://api.github.com/users/cberner","html_url":"https://github.com/cberner","followers_url":"https://api.github.com/users/cberner/followers","following_url":"https://api.github.com/users/cberner/following{/other_user}","gists_url":"https://api.github.com/users/cberner/gists{/gist_id}","starred_url":"https://api.github.com/users/cberner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cberner/subscriptions","organizations_url":"https://api.github.com/users/cberner/orgs","repos_url":"https://api.github.com/users/cberner/repos","events_url":"https://api.github.com/users/cberner/events{/privacy}","received_events_url":"https://api.github.com/users/cberner/received_events","type":"User","site_admin":false},"body":"The first 3 commits have already been reviewed","created_at":"2016-04-26T16:38:32Z","updated_at":"2016-04-26T20:41:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abdab72418a771128e31da8541e9d0a578f33bfc","assignee":{"login":"dain","id":58298,"avatar_url":"https://avatars.githubusercontent.com/u/58298?v=3","gravatar_id":"","url":"https://api.github.com/users/dain","html_url":"https://github.com/dain","followers_url":"https://api.github.com/users/dain/followers","following_url":"https://api.github.com/users/dain/following{/other_user}","gists_url":"https://api.github.com/users/dain/gists{/gist_id}","starred_url":"https://api.github.com/users/dain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dain/subscriptions","organizations_url":"https://api.github.com/users/dain/orgs","repos_url":"https://api.github.com/users/dain/repos","events_url":"https://api.github.com/users/dain/events{/privacy}","received_events_url":"https://api.github.com/users/dain/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/prestodb/presto/pulls/5120/commits","review_comments_url":"https://api.github.com/repos/prestodb/presto/pulls/5120/comments","review_comment_url":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prestodb/presto/issues/5120/comments","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/e052d38e876ebb0c45f5d87c9466e2ed490d5a5c","head":{"label":"cberner:configurable","ref":"configurable","sha":"e052d38e876ebb0c45f5d87c9466e2ed490d5a5c","user":{"login":"cberner","id":842688,"avatar_url":"https://avatars.githubusercontent.com/u/842688?v=3","gravatar_id":"","url":"https://api.github.com/users/cberner","html_url":"https://github.com/cberner","followers_url":"https://api.github.com/users/cberner/followers","following_url":"https://api.github.com/users/cberner/following{/other_user}","gists_url":"https://api.github.com/users/cberner/gists{/gist_id}","starred_url":"https://api.github.com/users/cberner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cberner/subscriptions","organizations_url":"https://api.github.com/users/cberner/orgs","repos_url":"https://api.github.com/users/cberner/repos","events_url":"https://api.github.com/users/cberner/events{/privacy}","received_events_url":"https://api.github.com/users/cberner/received_events","type":"User","site_admin":false},"repo":{"id":10272630,"name":"presto","full_name":"cberner/presto","owner":{"login":"cberner","id":842688,"avatar_url":"https://avatars.githubusercontent.com/u/842688?v=3","gravatar_id":"","url":"https://api.github.com/users/cberner","html_url":"https://github.com/cberner","followers_url":"https://api.github.com/users/cberner/followers","following_url":"https://api.github.com/users/cberner/following{/other_user}","gists_url":"https://api.github.com/users/cberner/gists{/gist_id}","starred_url":"https://api.github.com/users/cberner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cberner/subscriptions","organizations_url":"https://api.github.com/users/cberner/orgs","repos_url":"https://api.github.com/users/cberner/repos","events_url":"https://api.github.com/users/cberner/events{/privacy}","received_events_url":"https://api.github.com/users/cberner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cberner/presto","description":"","fork":true,"url":"https://api.github.com/repos/cberner/presto","forks_url":"https://api.github.com/repos/cberner/presto/forks","keys_url":"https://api.github.com/repos/cberner/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cberner/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cberner/presto/teams","hooks_url":"https://api.github.com/repos/cberner/presto/hooks","issue_events_url":"https://api.github.com/repos/cberner/presto/issues/events{/number}","events_url":"https://api.github.com/repos/cberner/presto/events","assignees_url":"https://api.github.com/repos/cberner/presto/assignees{/user}","branches_url":"https://api.github.com/repos/cberner/presto/branches{/branch}","tags_url":"https://api.github.com/repos/cberner/presto/tags","blobs_url":"https://api.github.com/repos/cberner/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cberner/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cberner/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/cberner/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cberner/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/cberner/presto/languages","stargazers_url":"https://api.github.com/repos/cberner/presto/stargazers","contributors_url":"https://api.github.com/repos/cberner/presto/contributors","subscribers_url":"https://api.github.com/repos/cberner/presto/subscribers","subscription_url":"https://api.github.com/repos/cberner/presto/subscription","commits_url":"https://api.github.com/repos/cberner/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/cberner/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/cberner/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/cberner/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/cberner/presto/contents/{+path}","compare_url":"https://api.github.com/repos/cberner/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cberner/presto/merges","archive_url":"https://api.github.com/repos/cberner/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cberner/presto/downloads","issues_url":"https://api.github.com/repos/cberner/presto/issues{/number}","pulls_url":"https://api.github.com/repos/cberner/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/cberner/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/cberner/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cberner/presto/labels{/name}","releases_url":"https://api.github.com/repos/cberner/presto/releases{/id}","deployments_url":"https://api.github.com/repos/cberner/presto/deployments","created_at":"2013-05-24T18:37:52Z","updated_at":"2016-03-18T20:43:12Z","pushed_at":"2016-04-26T16:37:48Z","git_url":"git://github.com/cberner/presto.git","ssh_url":"git@github.com:cberner/presto.git","clone_url":"https://github.com/cberner/presto.git","svn_url":"https://github.com/cberner/presto","homepage":null,"size":50521,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"prestodb:master","ref":"master","sha":"e638e060f920d2c5cc06e77c237fe1db1edfcc42","user":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars.githubusercontent.com/u/6882181?v=3","gravatar_id":"","url":"https://api.github.com/users/prestodb","html_url":"https://github.com/prestodb","followers_url":"https://api.github.com/users/prestodb/followers","following_url":"https://api.github.com/users/prestodb/following{/other_user}","gists_url":"https://api.github.com/users/prestodb/gists{/gist_id}","starred_url":"https://api.github.com/users/prestodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestodb/subscriptions","organizations_url":"https://api.github.com/users/prestodb/orgs","repos_url":"https://api.github.com/users/prestodb/repos","events_url":"https://api.github.com/users/prestodb/events{/privacy}","received_events_url":"https://api.github.com/users/prestodb/received_events","type":"Organization","site_admin":false},"repo":{"id":5349565,"name":"presto","full_name":"prestodb/presto","owner":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars.githubusercontent.com/u/6882181?v=3","gravatar_id":"","url":"https://api.github.com/users/prestodb","html_url":"https://github.com/prestodb","followers_url":"https://api.github.com/users/prestodb/followers","following_url":"https://api.github.com/users/prestodb/following{/other_user}","gists_url":"https://api.github.com/users/prestodb/gists{/gist_id}","starred_url":"https://api.github.com/users/prestodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestodb/subscriptions","organizations_url":"https://api.github.com/users/prestodb/orgs","repos_url":"https://api.github.com/users/prestodb/repos","events_url":"https://api.github.com/users/prestodb/events{/privacy}","received_events_url":"https://api.github.com/users/prestodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prestodb/presto","description":"Distributed SQL query engine for big data","fork":false,"url":"https://api.github.com/repos/prestodb/presto","forks_url":"https://api.github.com/repos/prestodb/presto/forks","keys_url":"https://api.github.com/repos/prestodb/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prestodb/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prestodb/presto/teams","hooks_url":"https://api.github.com/repos/prestodb/presto/hooks","issue_events_url":"https://api.github.com/repos/prestodb/presto/issues/events{/number}","events_url":"https://api.github.com/repos/prestodb/presto/events","assignees_url":"https://api.github.com/repos/prestodb/presto/assignees{/user}","branches_url":"https://api.github.com/repos/prestodb/presto/branches{/branch}","tags_url":"https://api.github.com/repos/prestodb/presto/tags","blobs_url":"https://api.github.com/repos/prestodb/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prestodb/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prestodb/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/prestodb/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/prestodb/presto/languages","stargazers_url":"https://api.github.com/repos/prestodb/presto/stargazers","contributors_url":"https://api.github.com/repos/prestodb/presto/contributors","subscribers_url":"https://api.github.com/repos/prestodb/presto/subscribers","subscription_url":"https://api.github.com/repos/prestodb/presto/subscription","commits_url":"https://api.github.com/repos/prestodb/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/prestodb/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/prestodb/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/prestodb/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/prestodb/presto/contents/{+path}","compare_url":"https://api.github.com/repos/prestodb/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prestodb/presto/merges","archive_url":"https://api.github.com/repos/prestodb/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prestodb/presto/downloads","issues_url":"https://api.github.com/repos/prestodb/presto/issues{/number}","pulls_url":"https://api.github.com/repos/prestodb/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/prestodb/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/prestodb/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prestodb/presto/labels{/name}","releases_url":"https://api.github.com/repos/prestodb/presto/releases{/id}","deployments_url":"https://api.github.com/repos/prestodb/presto/deployments","created_at":"2012-08-09T01:03:37Z","updated_at":"2016-04-26T19:07:59Z","pushed_at":"2016-04-26T20:21:06Z","git_url":"git://github.com/prestodb/presto.git","ssh_url":"git@github.com:prestodb/presto.git","clone_url":"https://github.com/prestodb/presto.git","svn_url":"https://github.com/prestodb/presto","homepage":"https://prestodb.io","size":149218,"stargazers_count":4694,"watchers_count":4694,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1363,"mirror_url":null,"open_issues_count":573,"forks":1363,"open_issues":573,"watchers":4694,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/5120"},"html":{"href":"https://github.com/prestodb/presto/pull/5120"},"issue":{"href":"https://api.github.com/repos/prestodb/presto/issues/5120"},"comments":{"href":"https://api.github.com/repos/prestodb/presto/issues/5120/comments"},"review_comments":{"href":"https://api.github.com/repos/prestodb/presto/pulls/5120/comments"},"review_comment":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prestodb/presto/pulls/5120/commits"},"statuses":{"href":"https://api.github.com/repos/prestodb/presto/statuses/e052d38e876ebb0c45f5d87c9466e2ed490d5a5c"}}}}