{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/comments/40382865","id":40382865,"diff_hunk":"@@ -0,0 +1,192 @@\n+/*\n+ * Copyright (c) 2015 DataTorrent\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.datatorrent.lib.appdata.schemas;\n+\n+import java.io.Serializable;\n+\n+import java.util.Objects;\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+\n+import com.google.common.base.Preconditions;\n+\n+/**\n+ * This represents a {@link TimeBucket} which can be a multiple of a time unit.\n+ */\n+public class CustomTimeBucket implements Serializable\n+{\n+  private static final long serialVersionUID = 201509221545L;\n+\n+  public static final String TIME_BUCKET_NAME_REGEX = \"(\\\\d+)([a-zA-Z]+)\";\n+  public static final Pattern TIME_BUCKET_NAME_PATTERN = Pattern.compile(TIME_BUCKET_NAME_REGEX);\n+\n+  private TimeBucket timeBucket;\n+  private long count;\n+  private String text;\n+  private long numMillis;\n+\n+  private CustomTimeBucket()\n+  {\n+    //For kryo\n+  }\n+\n+  public CustomTimeBucket(String timeBucketText)\n+  {\n+    if (timeBucketText.equals(TimeBucket.ALL.getText())) {\n+      initialize(TimeBucket.ALL, 0L);\n+    } else {\n+      Matcher matcher = TIME_BUCKET_NAME_PATTERN.matcher(timeBucketText);\n+\n+      if (!matcher.matches()) {\n+        throw new IllegalArgumentException(\"The given text for the variable time bucket \" + timeBucketText\n+                                           + \" does not match the regex for a variable time bucket \" + TIME_BUCKET_NAME_REGEX);\n+      }\n+\n+      String amountString = matcher.group(1);\n+      long amount = Long.parseLong(amountString);\n+\n+      String suffix = matcher.group(2);\n+      @SuppressWarnings(\"LocalVariableHidesMemberVariable\")\n+      TimeBucket timeBucket = TimeBucket.getTimeBucketForSuffixEx(suffix);\n+\n+      initialize(timeBucket,\n+                 amount);\n+    }\n+  }\n+\n+  public CustomTimeBucket(TimeBucket timeBucket,\n+                          long count)\n+  {\n+    initialize(timeBucket,\n+               count);\n+  }\n+\n+  public CustomTimeBucket(TimeBucket timeBucket)\n+  {\n+    if (timeBucket == TimeBucket.ALL) {\n+      initialize(timeBucket,\n+                 0L);","path":"library/src/main/java/com/datatorrent/lib/appdata/schemas/CustomTimeBucket.java","position":81,"original_position":81,"commit_id":"b3b7c5b1dac79c0130a700ec7e0e91de554b06b4","original_commit_id":"b3b7c5b1dac79c0130a700ec7e0e91de554b06b4","user":{"login":"chandnisingh","id":4690923,"avatar_url":"https://avatars.githubusercontent.com/u/4690923?v=3","gravatar_id":"","url":"https://api.github.com/users/chandnisingh","html_url":"https://github.com/chandnisingh","followers_url":"https://api.github.com/users/chandnisingh/followers","following_url":"https://api.github.com/users/chandnisingh/following{/other_user}","gists_url":"https://api.github.com/users/chandnisingh/gists{/gist_id}","starred_url":"https://api.github.com/users/chandnisingh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chandnisingh/subscriptions","organizations_url":"https://api.github.com/users/chandnisingh/orgs","repos_url":"https://api.github.com/users/chandnisingh/repos","events_url":"https://api.github.com/users/chandnisingh/events{/privacy}","received_events_url":"https://api.github.com/users/chandnisingh/received_events","type":"User","site_admin":false},"body":"Why multiple lines?","created_at":"2015-09-24T22:47:52Z","updated_at":"2015-09-24T22:47:52Z","html_url":"https://github.com/apache/incubator-apex-malhar/pull/33#discussion_r40382865","pull_request_url":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/comments/40382865"},"html":{"href":"https://github.com/apache/incubator-apex-malhar/pull/33#discussion_r40382865"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33","id":45871874,"html_url":"https://github.com/apache/incubator-apex-malhar/pull/33","diff_url":"https://github.com/apache/incubator-apex-malhar/pull/33.diff","patch_url":"https://github.com/apache/incubator-apex-malhar/pull/33.patch","issue_url":"https://api.github.com/repos/apache/incubator-apex-malhar/issues/33","number":33,"state":"closed","locked":false,"title":" - MLHR-1832 Added Custom TimeBuckets","user":{"login":"ilooner","id":8020165,"avatar_url":"https://avatars.githubusercontent.com/u/8020165?v=3","gravatar_id":"","url":"https://api.github.com/users/ilooner","html_url":"https://github.com/ilooner","followers_url":"https://api.github.com/users/ilooner/followers","following_url":"https://api.github.com/users/ilooner/following{/other_user}","gists_url":"https://api.github.com/users/ilooner/gists{/gist_id}","starred_url":"https://api.github.com/users/ilooner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilooner/subscriptions","organizations_url":"https://api.github.com/users/ilooner/orgs","repos_url":"https://api.github.com/users/ilooner/repos","events_url":"https://api.github.com/users/ilooner/events{/privacy}","received_events_url":"https://api.github.com/users/ilooner/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-24T08:40:55Z","updated_at":"2015-09-24T22:47:52Z","closed_at":"2015-09-24T22:46:31Z","merged_at":"2015-09-24T22:46:31Z","merge_commit_sha":"9f68462b3368753bf3ebad1c58b1db0fc4b24f17","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-apex-malhar/issues/33/comments","statuses_url":"https://api.github.com/repos/apache/incubator-apex-malhar/statuses/b3b7c5b1dac79c0130a700ec7e0e91de554b06b4","head":{"label":"ilooner:MLHR-1832_pull","ref":"MLHR-1832_pull","sha":"b3b7c5b1dac79c0130a700ec7e0e91de554b06b4","user":{"login":"ilooner","id":8020165,"avatar_url":"https://avatars.githubusercontent.com/u/8020165?v=3","gravatar_id":"","url":"https://api.github.com/users/ilooner","html_url":"https://github.com/ilooner","followers_url":"https://api.github.com/users/ilooner/followers","following_url":"https://api.github.com/users/ilooner/following{/other_user}","gists_url":"https://api.github.com/users/ilooner/gists{/gist_id}","starred_url":"https://api.github.com/users/ilooner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilooner/subscriptions","organizations_url":"https://api.github.com/users/ilooner/orgs","repos_url":"https://api.github.com/users/ilooner/repos","events_url":"https://api.github.com/users/ilooner/events{/privacy}","received_events_url":"https://api.github.com/users/ilooner/received_events","type":"User","site_admin":false},"repo":{"id":41442065,"name":"incubator-apex-malhar","full_name":"ilooner/incubator-apex-malhar","owner":{"login":"ilooner","id":8020165,"avatar_url":"https://avatars.githubusercontent.com/u/8020165?v=3","gravatar_id":"","url":"https://api.github.com/users/ilooner","html_url":"https://github.com/ilooner","followers_url":"https://api.github.com/users/ilooner/followers","following_url":"https://api.github.com/users/ilooner/following{/other_user}","gists_url":"https://api.github.com/users/ilooner/gists{/gist_id}","starred_url":"https://api.github.com/users/ilooner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilooner/subscriptions","organizations_url":"https://api.github.com/users/ilooner/orgs","repos_url":"https://api.github.com/users/ilooner/repos","events_url":"https://api.github.com/users/ilooner/events{/privacy}","received_events_url":"https://api.github.com/users/ilooner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ilooner/incubator-apex-malhar","description":"Mirror of Apache Apex malhar (Incubating)","fork":true,"url":"https://api.github.com/repos/ilooner/incubator-apex-malhar","forks_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/forks","keys_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/teams","hooks_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/events","assignees_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/tags","blobs_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/languages","stargazers_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/subscription","commits_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/merges","archive_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/downloads","issues_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/ilooner/incubator-apex-malhar/releases{/id}","created_at":"2015-08-26T18:14:45Z","updated_at":"2015-08-26T18:14:49Z","pushed_at":"2015-09-24T08:04:05Z","git_url":"git://github.com/ilooner/incubator-apex-malhar.git","ssh_url":"git@github.com:ilooner/incubator-apex-malhar.git","clone_url":"https://github.com/ilooner/incubator-apex-malhar.git","svn_url":"https://github.com/ilooner/incubator-apex-malhar","homepage":null,"size":82803,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:devel-3","ref":"devel-3","sha":"d710af9b1a5a84de8e179c783bb96c5405af95de","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":41348334,"name":"incubator-apex-malhar","full_name":"apache/incubator-apex-malhar","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-apex-malhar","description":"Mirror of Apache Apex malhar (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-apex-malhar","forks_url":"https://api.github.com/repos/apache/incubator-apex-malhar/forks","keys_url":"https://api.github.com/repos/apache/incubator-apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-apex-malhar/teams","hooks_url":"https://api.github.com/repos/apache/incubator-apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-apex-malhar/events","assignees_url":"https://api.github.com/repos/apache/incubator-apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-apex-malhar/tags","blobs_url":"https://api.github.com/repos/apache/incubator-apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-apex-malhar/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-apex-malhar/subscription","commits_url":"https://api.github.com/repos/apache/incubator-apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-apex-malhar/merges","archive_url":"https://api.github.com/repos/apache/incubator-apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-apex-malhar/downloads","issues_url":"https://api.github.com/repos/apache/incubator-apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-apex-malhar/releases{/id}","created_at":"2015-08-25T07:00:05Z","updated_at":"2015-09-21T07:12:32Z","pushed_at":"2015-09-24T22:46:31Z","git_url":"git://github.com/apache/incubator-apex-malhar.git","ssh_url":"git@github.com:apache/incubator-apex-malhar.git","clone_url":"https://github.com/apache/incubator-apex-malhar.git","svn_url":"https://github.com/apache/incubator-apex-malhar","homepage":null,"size":94365,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":22,"mirror_url":"git://git.apache.org/incubator-apex-malhar.git","open_issues_count":5,"forks":22,"open_issues":5,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33"},"html":{"href":"https://github.com/apache/incubator-apex-malhar/pull/33"},"issue":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/issues/33"},"comments":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-apex-malhar/statuses/b3b7c5b1dac79c0130a700ec7e0e91de554b06b4"}}}}