{"action":"created","comment":{"url":"https://api.github.com/repos/snowplow/snowplow/pulls/comments/113622087","pull_request_review_id":35024983,"id":113622087,"diff_hunk":"@@ -0,0 +1,216 @@\n+/*\n+ * Copyright (c) 2017 Snowplow Analytics Ltd. All rights reserved.\n+ *\n+ * This program is licensed to you under the Apache License Version 2.0,\n+ * and you may not use this file except in compliance with the Apache License Version 2.0.\n+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the Apache License Version 2.0 is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.\n+ */\n+package com.snowplowanalytics.snowplow.eventpopulator\n+\n+// scalaz\n+import scalaz.{Ordering => _, _}\n+import Scalaz._\n+\n+// Scala\n+import scala.util.control.NonFatal\n+import scala.collection.convert.decorateAsScala._\n+\n+// AWS SDK\n+import com.amazonaws.auth.DefaultAWSCredentialsProviderChain\n+import com.amazonaws.services.s3.AmazonS3ClientBuilder\n+import com.amazonaws.services.s3.model.ListObjectsRequest\n+\n+// Java\n+import java.nio.charset.StandardCharsets.UTF_8\n+\n+// Jackson\n+import com.fasterxml.jackson.databind.{ ObjectMapper, JsonNode }\n+\n+// Iglu client\n+import com.snowplowanalytics.iglu.client.Validated\n+import com.snowplowanalytics.iglu.client.validation.ProcessingMessageMethods._\n+\n+// Apache Commons Codec\n+import org.apache.commons.codec.binary.Base64\n+\n+// Joda time\n+import org.joda.time.DateTime\n+import org.joda.time.format.DateTimeFormat\n+import org.joda.time.format.DateTimeFormatterBuilder\n+\n+// This project\n+import Main.JobConf\n+\n+/**\n+  * Util functions and constant that not directly related to spark job\n+  */\n+object Utils {\n+\n+  // Column indexes in TSV\n+  val EtlTimestampIndex = 2\n+  val EventIdIndex = 6\n+  val FingerprintIndex = 129\n+\n+  /**\n+    * Date format in archive buckets: run=YYYY-MM-dd-HH-mm-ss\n+    * In EmrEtlRunner: \"%Y-%m-%d-%H-%M-%S\"\n+    */\n+  val runIdFormat = DateTimeFormat.forPattern(\"YYYY-MM-dd-HH-mm-ss\")\n+\n+  /**\n+    * Shortened `runIdFormat` that can be used for manual input\n+    */\n+  val dayFormat = DateTimeFormat.forPattern(\"YYYY-MM-dd\")\n+\n+  /**\n+    * Combined `dayFormat` and `runIdFormat` that can be used\n+    * both for precise and shorten manual input\n+    */\n+  val inputFormatter = new DateTimeFormatterBuilder()\n+    .append(null, List(runIdFormat.getParser, dayFormat.getParser).toArray)\n+    .toFormatter\n+\n+  implicit def dateTimeOrdering: Ordering[DateTime] =\n+    Ordering.fromLessThan(_ isBefore _)\n+\n+  private val UrlSafeBase64 = new Base64(true) // true means \"url safe\"\n+\n+  private lazy val Mapper = new ObjectMapper\n+\n+  /**\n+    * Data extracted from EnrichedEvent and storing in DynamoDB\n+    */\n+  case class DeduplicationTriple(eventId: String, fingerprint: String, etlTstamp: String)\n+\n+  /**\n+    * Error happening when TSV doesn't match expected number of lines\n+    *\n+    * @param columns encountered number of columns\n+    * @param line original event TSV line\n+    */\n+  case class ParsingError(columns: Int, line: String) extends RuntimeException {\n+    def message: String = s\"Wrong EnrichedEvent TSV columns number. Expected 130, got [$columns]. Line: [$line]\"\n+  }\n+\n+  /**\n+    * Get run ids from `jobConf.enrichedInBucket` happened since `jobConf.since`\n+    *\n+    * @param jobConf input configuration\n+    * @return list of timestamps (run ids)\n+    */\n+  def getRuns(jobConf: JobConf): List[String] = {\n+    val runIds = ls3s(jobConf)\n+    val filtered = jobConf.since match {\n+      case Some(start) => filterSince(runIds, start)\n+      case None => runIds\n+    }\n+    filtered.map(runId => runIdFormat.print(runId))\n+  }\n+\n+  /**\n+    * Get list of all folders inside S3 bucket with enriched archive\n+    *\n+    * @param jobConf parameters parsed from command line\n+    * @return list of **dates** (without \"run\") of for arhives\n+    */\n+  private def ls3s(jobConf: JobConf): List[DateTime] = {","path":"5-data-modeling/event-manifest-populator/src/main/scala/com/snowplowanalytics/snowplow/eventpopulator/Utils.scala","position":121,"original_position":121,"commit_id":"5faaab09f75f26b035eaf6ae66f4954d7455d886","original_commit_id":"5faaab09f75f26b035eaf6ae66f4954d7455d886","user":{"login":"chuwy","id":681171,"avatar_url":"https://avatars1.githubusercontent.com/u/681171?v=3","gravatar_id":"","url":"https://api.github.com/users/chuwy","html_url":"https://github.com/chuwy","followers_url":"https://api.github.com/users/chuwy/followers","following_url":"https://api.github.com/users/chuwy/following{/other_user}","gists_url":"https://api.github.com/users/chuwy/gists{/gist_id}","starred_url":"https://api.github.com/users/chuwy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuwy/subscriptions","organizations_url":"https://api.github.com/users/chuwy/orgs","repos_url":"https://api.github.com/users/chuwy/repos","events_url":"https://api.github.com/users/chuwy/events{/privacy}","received_events_url":"https://api.github.com/users/chuwy/received_events","type":"User","site_admin":false},"body":"`ls` stands for unix `ls` command.","created_at":"2017-04-27T06:17:31Z","updated_at":"2017-04-27T06:17:31Z","html_url":"https://github.com/snowplow/snowplow/pull/3133#discussion_r113622087","pull_request_url":"https://api.github.com/repos/snowplow/snowplow/pulls/3133","_links":{"self":{"href":"https://api.github.com/repos/snowplow/snowplow/pulls/comments/113622087"},"html":{"href":"https://github.com/snowplow/snowplow/pull/3133#discussion_r113622087"},"pull_request":{"href":"https://api.github.com/repos/snowplow/snowplow/pulls/3133"}}},"pull_request":{"url":"https://api.github.com/repos/snowplow/snowplow/pulls/3133","id":108079887,"html_url":"https://github.com/snowplow/snowplow/pull/3133","diff_url":"https://github.com/snowplow/snowplow/pull/3133.diff","patch_url":"https://github.com/snowplow/snowplow/pull/3133.patch","issue_url":"https://api.github.com/repos/snowplow/snowplow/issues/3133","number":3133,"state":"open","locked":false,"title":"R88 Angkor Wat","user":{"login":"chuwy","id":681171,"avatar_url":"https://avatars1.githubusercontent.com/u/681171?v=3","gravatar_id":"","url":"https://api.github.com/users/chuwy","html_url":"https://github.com/chuwy","followers_url":"https://api.github.com/users/chuwy/followers","following_url":"https://api.github.com/users/chuwy/following{/other_user}","gists_url":"https://api.github.com/users/chuwy/gists{/gist_id}","starred_url":"https://api.github.com/users/chuwy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuwy/subscriptions","organizations_url":"https://api.github.com/users/chuwy/orgs","repos_url":"https://api.github.com/users/chuwy/repos","events_url":"https://api.github.com/users/chuwy/events{/privacy}","received_events_url":"https://api.github.com/users/chuwy/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-02-27T09:55:20Z","updated_at":"2017-04-27T06:17:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"492361e1696886e758531d4f3565d97386bf7c4f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/snowplow/snowplow/pulls/3133/commits","review_comments_url":"https://api.github.com/repos/snowplow/snowplow/pulls/3133/comments","review_comment_url":"https://api.github.com/repos/snowplow/snowplow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snowplow/snowplow/issues/3133/comments","statuses_url":"https://api.github.com/repos/snowplow/snowplow/statuses/5faaab09f75f26b035eaf6ae66f4954d7455d886","head":{"label":"snowplow:release/r88-angkor-wat","ref":"release/r88-angkor-wat","sha":"5faaab09f75f26b035eaf6ae66f4954d7455d886","user":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars0.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"repo":{"id":3591964,"name":"snowplow","full_name":"snowplow/snowplow","owner":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars0.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snowplow/snowplow","description":"Enterprise-strength web, mobile and event analytics, powered by Hadoop, Kafka, Kinesis, Redshift and Elasticsearch","fork":false,"url":"https://api.github.com/repos/snowplow/snowplow","forks_url":"https://api.github.com/repos/snowplow/snowplow/forks","keys_url":"https://api.github.com/repos/snowplow/snowplow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snowplow/snowplow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snowplow/snowplow/teams","hooks_url":"https://api.github.com/repos/snowplow/snowplow/hooks","issue_events_url":"https://api.github.com/repos/snowplow/snowplow/issues/events{/number}","events_url":"https://api.github.com/repos/snowplow/snowplow/events","assignees_url":"https://api.github.com/repos/snowplow/snowplow/assignees{/user}","branches_url":"https://api.github.com/repos/snowplow/snowplow/branches{/branch}","tags_url":"https://api.github.com/repos/snowplow/snowplow/tags","blobs_url":"https://api.github.com/repos/snowplow/snowplow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snowplow/snowplow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snowplow/snowplow/git/refs{/sha}","trees_url":"https://api.github.com/repos/snowplow/snowplow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snowplow/snowplow/statuses/{sha}","languages_url":"https://api.github.com/repos/snowplow/snowplow/languages","stargazers_url":"https://api.github.com/repos/snowplow/snowplow/stargazers","contributors_url":"https://api.github.com/repos/snowplow/snowplow/contributors","subscribers_url":"https://api.github.com/repos/snowplow/snowplow/subscribers","subscription_url":"https://api.github.com/repos/snowplow/snowplow/subscription","commits_url":"https://api.github.com/repos/snowplow/snowplow/commits{/sha}","git_commits_url":"https://api.github.com/repos/snowplow/snowplow/git/commits{/sha}","comments_url":"https://api.github.com/repos/snowplow/snowplow/comments{/number}","issue_comment_url":"https://api.github.com/repos/snowplow/snowplow/issues/comments{/number}","contents_url":"https://api.github.com/repos/snowplow/snowplow/contents/{+path}","compare_url":"https://api.github.com/repos/snowplow/snowplow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snowplow/snowplow/merges","archive_url":"https://api.github.com/repos/snowplow/snowplow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snowplow/snowplow/downloads","issues_url":"https://api.github.com/repos/snowplow/snowplow/issues{/number}","pulls_url":"https://api.github.com/repos/snowplow/snowplow/pulls{/number}","milestones_url":"https://api.github.com/repos/snowplow/snowplow/milestones{/number}","notifications_url":"https://api.github.com/repos/snowplow/snowplow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snowplow/snowplow/labels{/name}","releases_url":"https://api.github.com/repos/snowplow/snowplow/releases{/id}","deployments_url":"https://api.github.com/repos/snowplow/snowplow/deployments","created_at":"2012-03-01T13:02:21Z","updated_at":"2017-04-27T03:56:57Z","pushed_at":"2017-04-26T13:53:34Z","git_url":"git://github.com/snowplow/snowplow.git","ssh_url":"git@github.com:snowplow/snowplow.git","clone_url":"https://github.com/snowplow/snowplow.git","svn_url":"https://github.com/snowplow/snowplow","homepage":"http://snowplowanalytics.com","size":20019,"stargazers_count":3284,"watchers_count":3284,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":758,"mirror_url":null,"open_issues_count":824,"forks":758,"open_issues":824,"watchers":3284,"default_branch":"master"}},"base":{"label":"snowplow:master","ref":"master","sha":"d261fcd7fae6f5b1a932c8b99b37159a22391c3a","user":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars0.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"repo":{"id":3591964,"name":"snowplow","full_name":"snowplow/snowplow","owner":{"login":"snowplow","id":1476001,"avatar_url":"https://avatars0.githubusercontent.com/u/1476001?v=3","gravatar_id":"","url":"https://api.github.com/users/snowplow","html_url":"https://github.com/snowplow","followers_url":"https://api.github.com/users/snowplow/followers","following_url":"https://api.github.com/users/snowplow/following{/other_user}","gists_url":"https://api.github.com/users/snowplow/gists{/gist_id}","starred_url":"https://api.github.com/users/snowplow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowplow/subscriptions","organizations_url":"https://api.github.com/users/snowplow/orgs","repos_url":"https://api.github.com/users/snowplow/repos","events_url":"https://api.github.com/users/snowplow/events{/privacy}","received_events_url":"https://api.github.com/users/snowplow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snowplow/snowplow","description":"Enterprise-strength web, mobile and event analytics, powered by Hadoop, Kafka, Kinesis, Redshift and Elasticsearch","fork":false,"url":"https://api.github.com/repos/snowplow/snowplow","forks_url":"https://api.github.com/repos/snowplow/snowplow/forks","keys_url":"https://api.github.com/repos/snowplow/snowplow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snowplow/snowplow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snowplow/snowplow/teams","hooks_url":"https://api.github.com/repos/snowplow/snowplow/hooks","issue_events_url":"https://api.github.com/repos/snowplow/snowplow/issues/events{/number}","events_url":"https://api.github.com/repos/snowplow/snowplow/events","assignees_url":"https://api.github.com/repos/snowplow/snowplow/assignees{/user}","branches_url":"https://api.github.com/repos/snowplow/snowplow/branches{/branch}","tags_url":"https://api.github.com/repos/snowplow/snowplow/tags","blobs_url":"https://api.github.com/repos/snowplow/snowplow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snowplow/snowplow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snowplow/snowplow/git/refs{/sha}","trees_url":"https://api.github.com/repos/snowplow/snowplow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snowplow/snowplow/statuses/{sha}","languages_url":"https://api.github.com/repos/snowplow/snowplow/languages","stargazers_url":"https://api.github.com/repos/snowplow/snowplow/stargazers","contributors_url":"https://api.github.com/repos/snowplow/snowplow/contributors","subscribers_url":"https://api.github.com/repos/snowplow/snowplow/subscribers","subscription_url":"https://api.github.com/repos/snowplow/snowplow/subscription","commits_url":"https://api.github.com/repos/snowplow/snowplow/commits{/sha}","git_commits_url":"https://api.github.com/repos/snowplow/snowplow/git/commits{/sha}","comments_url":"https://api.github.com/repos/snowplow/snowplow/comments{/number}","issue_comment_url":"https://api.github.com/repos/snowplow/snowplow/issues/comments{/number}","contents_url":"https://api.github.com/repos/snowplow/snowplow/contents/{+path}","compare_url":"https://api.github.com/repos/snowplow/snowplow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snowplow/snowplow/merges","archive_url":"https://api.github.com/repos/snowplow/snowplow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snowplow/snowplow/downloads","issues_url":"https://api.github.com/repos/snowplow/snowplow/issues{/number}","pulls_url":"https://api.github.com/repos/snowplow/snowplow/pulls{/number}","milestones_url":"https://api.github.com/repos/snowplow/snowplow/milestones{/number}","notifications_url":"https://api.github.com/repos/snowplow/snowplow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snowplow/snowplow/labels{/name}","releases_url":"https://api.github.com/repos/snowplow/snowplow/releases{/id}","deployments_url":"https://api.github.com/repos/snowplow/snowplow/deployments","created_at":"2012-03-01T13:02:21Z","updated_at":"2017-04-27T03:56:57Z","pushed_at":"2017-04-26T13:53:34Z","git_url":"git://github.com/snowplow/snowplow.git","ssh_url":"git@github.com:snowplow/snowplow.git","clone_url":"https://github.com/snowplow/snowplow.git","svn_url":"https://github.com/snowplow/snowplow","homepage":"http://snowplowanalytics.com","size":20019,"stargazers_count":3284,"watchers_count":3284,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":758,"mirror_url":null,"open_issues_count":824,"forks":758,"open_issues":824,"watchers":3284,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snowplow/snowplow/pulls/3133"},"html":{"href":"https://github.com/snowplow/snowplow/pull/3133"},"issue":{"href":"https://api.github.com/repos/snowplow/snowplow/issues/3133"},"comments":{"href":"https://api.github.com/repos/snowplow/snowplow/issues/3133/comments"},"review_comments":{"href":"https://api.github.com/repos/snowplow/snowplow/pulls/3133/comments"},"review_comment":{"href":"https://api.github.com/repos/snowplow/snowplow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snowplow/snowplow/pulls/3133/commits"},"statuses":{"href":"https://api.github.com/repos/snowplow/snowplow/statuses/5faaab09f75f26b035eaf6ae66f4954d7455d886"}}}}
{"actor":{"display_login":"chuwy"}}