{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/druid/pulls/comments/30443624","id":30443624,"diff_hunk":"@@ -0,0 +1,344 @@\n+/*\n+ * Licensed to Metamarkets Group Inc. (Metamarkets) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  Metamarkets licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package io.druid.indexer;\n+\n+import com.fasterxml.jackson.databind.InjectableValues;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import com.fasterxml.jackson.databind.jsontype.NamedType;\n+import com.google.common.collect.ImmutableList;\n+import com.google.common.collect.ImmutableMap;\n+import com.google.common.collect.Lists;\n+import com.google.common.collect.Maps;\n+import com.google.common.io.Files;\n+import com.metamx.common.Granularity;\n+import io.druid.data.input.impl.CSVParseSpec;\n+import io.druid.data.input.impl.DimensionsSpec;\n+import io.druid.data.input.impl.StringInputRowParser;\n+import io.druid.data.input.impl.TimestampSpec;\n+import io.druid.granularity.QueryGranularity;\n+import io.druid.jackson.DefaultObjectMapper;\n+import io.druid.query.aggregation.AggregatorFactory;\n+import io.druid.query.aggregation.LongSumAggregatorFactory;\n+import io.druid.segment.indexing.DataSchema;\n+import io.druid.segment.indexing.granularity.UniformGranularitySpec;\n+import io.druid.timeline.DataSegment;\n+import io.druid.timeline.partition.HashBasedNumberedShardSpec;\n+import io.druid.timeline.partition.ShardSpec;\n+import io.druid.timeline.partition.SingleDimensionShardSpec;\n+import org.apache.commons.io.FileUtils;\n+import org.joda.time.DateTime;\n+import org.joda.time.DateTimeComparator;\n+import org.joda.time.Interval;\n+import org.junit.After;\n+import org.junit.Assert;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.junit.runners.Parameterized;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.util.Arrays;\n+import java.util.Collection;\n+import java.util.List;\n+import java.util.Map;\n+\n+@RunWith(Parameterized.class)\n+public class IndexGeneratorJobTest\n+{\n+\n+  @Parameterized.Parameters(name = \"partitionType={0}, interval={1}, shardInfoForEachSegment={2}, data={3}\")\n+  public static Collection<Object[]> constructFeed()\n+  {\n+    return Arrays.asList(\n+        new Object[][]{\n+            {\n+                \"single\",\n+                \"2014-10-22T00:00:00Z/P2D\",\n+                new String[][][]{\n+                    {\n+                        { null, \"c.example.com\" },\n+                        { \"c.example.com\", \"e.example.com\" },\n+                        { \"e.example.com\", \"g.example.com\" },\n+                        { \"g.example.com\", \"i.example.com\" },\n+                        { \"i.example.com\", null }\n+                    },\n+                    {\n+                        { null, \"c.example.com\" },\n+                        { \"c.example.com\", \"e.example.com\" },\n+                        { \"e.example.com\", \"g.example.com\" },\n+                        { \"g.example.com\", \"i.example.com\" },\n+                        { \"i.example.com\", null }\n+                    }\n+                },\n+                ImmutableList.of(\n+                    \"2014102200,a.example.com,100\",\n+                    \"2014102200,b.exmaple.com,50\",\n+                    \"2014102200,c.example.com,200\",\n+                    \"2014102200,d.example.com,250\",\n+                    \"2014102200,e.example.com,123\",\n+                    \"2014102200,f.example.com,567\",\n+                    \"2014102200,g.example.com,11\",\n+                    \"2014102200,h.example.com,251\",\n+                    \"2014102200,i.example.com,963\",\n+                    \"2014102200,j.example.com,333\",\n+                    \"2014102300,a.example.com,100\",\n+                    \"2014102300,b.exmaple.com,50\",\n+                    \"2014102300,c.example.com,200\",\n+                    \"2014102300,d.example.com,250\",\n+                    \"2014102300,e.example.com,123\",\n+                    \"2014102300,f.example.com,567\",\n+                    \"2014102300,g.example.com,11\",\n+                    \"2014102300,h.example.com,251\",\n+                    \"2014102300,i.example.com,963\",\n+                    \"2014102300,j.example.com,333\"\n+                )\n+            },\n+            {\n+                \"hashed\",\n+                \"2014-10-22T00:00:00Z/P1D\",\n+                new Integer[][][]{\n+                    {\n+                        { 0, 4 },\n+                        { 1, 4 },\n+                        { 2, 4 },\n+                        { 3, 4 }\n+                    }\n+                },\n+                ImmutableList.of(\n+                    \"2014102200,a.example.com,100\",\n+                    \"2014102201,b.exmaple.com,50\",\n+                    \"2014102202,c.example.com,200\",\n+                    \"2014102203,d.example.com,250\",\n+                    \"2014102204,e.example.com,123\",\n+                    \"2014102205,f.example.com,567\",\n+                    \"2014102206,g.example.com,11\",\n+                    \"2014102207,h.example.com,251\",\n+                    \"2014102208,i.example.com,963\",\n+                    \"2014102209,j.example.com,333\",\n+                    \"2014102210,k.example.com,253\",\n+                    \"2014102211,l.example.com,321\",\n+                    \"2014102212,m.example.com,3125\",\n+                    \"2014102213,n.example.com,234\",\n+                    \"2014102214,o.example.com,325\",\n+                    \"2014102215,p.example.com,3533\",\n+                    \"2014102216,q.example.com,587\"\n+                )\n+            }\n+        }\n+    );\n+  }\n+\n+  private ObjectMapper mapper;\n+  private HadoopDruidIndexerConfig config;\n+  private File dataFile;\n+  private File tmpDir;\n+  private Interval interval;\n+  private String partitionType;\n+  private Object[][][] shardInfoForEachSegment;\n+\n+  public IndexGeneratorJobTest(\n+      String partitionType,\n+      String interval,\n+      Object[][][] shardInfoForEachSegment,\n+      List<String> data\n+  ) throws IOException\n+  {\n+    this.partitionType = partitionType;\n+    this.shardInfoForEachSegment = shardInfoForEachSegment;\n+    this.interval = new Interval(interval);\n+    mapper = new DefaultObjectMapper();\n+    mapper.registerSubtypes(new NamedType(HashBasedNumberedShardSpec.class, \"hashed\"));\n+    mapper.registerSubtypes(new NamedType(SingleDimensionShardSpec.class, \"single\"));\n+    InjectableValues inject = new InjectableValues.Std().addValue(ObjectMapper.class, mapper);\n+    mapper.setInjectableValues(inject);\n+\n+    dataFile = File.createTempFile(\"test_website_data\", \"tmp\");","path":"indexing-hadoop/src/test/java/io/druid/indexer/IndexGeneratorJobTest.java","position":172,"original_position":172,"commit_id":"d5ee1a5a4202f297a8e6090fc0c78daefbc45579","original_commit_id":"d5ee1a5a4202f297a8e6090fc0c78daefbc45579","user":{"login":"guobingkun","id":11789051,"avatar_url":"https://avatars.githubusercontent.com/u/11789051?v=3","gravatar_id":"","url":"https://api.github.com/users/guobingkun","html_url":"https://github.com/guobingkun","followers_url":"https://api.github.com/users/guobingkun/followers","following_url":"https://api.github.com/users/guobingkun/following{/other_user}","gists_url":"https://api.github.com/users/guobingkun/gists{/gist_id}","starred_url":"https://api.github.com/users/guobingkun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guobingkun/subscriptions","organizations_url":"https://api.github.com/users/guobingkun/orgs","repos_url":"https://api.github.com/users/guobingkun/repos","events_url":"https://api.github.com/users/guobingkun/events{/privacy}","received_events_url":"https://api.github.com/users/guobingkun/received_events","type":"User","site_admin":false},"body":"Yeah, I tried that. But doing ```temporaryFolder.newFile()``` in the constructor gave me an exception saying ```java.lang.IllegalStateException: the temporary folder has not yet been created``` ","created_at":"2015-05-15T20:33:34Z","updated_at":"2015-05-15T20:33:34Z","html_url":"https://github.com/druid-io/druid/pull/1371#discussion_r30443624","pull_request_url":"https://api.github.com/repos/druid-io/druid/pulls/1371","_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments/30443624"},"html":{"href":"https://github.com/druid-io/druid/pull/1371#discussion_r30443624"},"pull_request":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1371"}}},"pull_request":{"url":"https://api.github.com/repos/druid-io/druid/pulls/1371","id":35544461,"html_url":"https://github.com/druid-io/druid/pull/1371","diff_url":"https://github.com/druid-io/druid/pull/1371.diff","patch_url":"https://github.com/druid-io/druid/pull/1371.patch","issue_url":"https://api.github.com/repos/druid-io/druid/issues/1371","number":1371,"state":"open","locked":false,"title":"Unit test for IndexGeneratorJob","user":{"login":"guobingkun","id":11789051,"avatar_url":"https://avatars.githubusercontent.com/u/11789051?v=3","gravatar_id":"","url":"https://api.github.com/users/guobingkun","html_url":"https://github.com/guobingkun","followers_url":"https://api.github.com/users/guobingkun/followers","following_url":"https://api.github.com/users/guobingkun/following{/other_user}","gists_url":"https://api.github.com/users/guobingkun/gists{/gist_id}","starred_url":"https://api.github.com/users/guobingkun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guobingkun/subscriptions","organizations_url":"https://api.github.com/users/guobingkun/orgs","repos_url":"https://api.github.com/users/guobingkun/repos","events_url":"https://api.github.com/users/guobingkun/events{/privacy}","received_events_url":"https://api.github.com/users/guobingkun/received_events","type":"User","site_admin":false},"body":"Unit test for IndexGeneratorJob","created_at":"2015-05-15T19:43:44Z","updated_at":"2015-05-15T20:33:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5a97b5ccda35774c1e0d762e9f0639e16c2afcd3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/druid-io/druid/pulls/1371/commits","review_comments_url":"https://api.github.com/repos/druid-io/druid/pulls/1371/comments","review_comment_url":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/druid-io/druid/issues/1371/comments","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/d5ee1a5a4202f297a8e6090fc0c78daefbc45579","head":{"label":"guobingkun:unit_test","ref":"unit_test","sha":"d5ee1a5a4202f297a8e6090fc0c78daefbc45579","user":{"login":"guobingkun","id":11789051,"avatar_url":"https://avatars.githubusercontent.com/u/11789051?v=3","gravatar_id":"","url":"https://api.github.com/users/guobingkun","html_url":"https://github.com/guobingkun","followers_url":"https://api.github.com/users/guobingkun/followers","following_url":"https://api.github.com/users/guobingkun/following{/other_user}","gists_url":"https://api.github.com/users/guobingkun/gists{/gist_id}","starred_url":"https://api.github.com/users/guobingkun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guobingkun/subscriptions","organizations_url":"https://api.github.com/users/guobingkun/orgs","repos_url":"https://api.github.com/users/guobingkun/repos","events_url":"https://api.github.com/users/guobingkun/events{/privacy}","received_events_url":"https://api.github.com/users/guobingkun/received_events","type":"User","site_admin":false},"repo":{"id":33376574,"name":"druid","full_name":"guobingkun/druid","owner":{"login":"guobingkun","id":11789051,"avatar_url":"https://avatars.githubusercontent.com/u/11789051?v=3","gravatar_id":"","url":"https://api.github.com/users/guobingkun","html_url":"https://github.com/guobingkun","followers_url":"https://api.github.com/users/guobingkun/followers","following_url":"https://api.github.com/users/guobingkun/following{/other_user}","gists_url":"https://api.github.com/users/guobingkun/gists{/gist_id}","starred_url":"https://api.github.com/users/guobingkun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guobingkun/subscriptions","organizations_url":"https://api.github.com/users/guobingkun/orgs","repos_url":"https://api.github.com/users/guobingkun/repos","events_url":"https://api.github.com/users/guobingkun/events{/privacy}","received_events_url":"https://api.github.com/users/guobingkun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/guobingkun/druid","description":"Real²time Exploratory Analytics on Large Datasets","fork":true,"url":"https://api.github.com/repos/guobingkun/druid","forks_url":"https://api.github.com/repos/guobingkun/druid/forks","keys_url":"https://api.github.com/repos/guobingkun/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guobingkun/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guobingkun/druid/teams","hooks_url":"https://api.github.com/repos/guobingkun/druid/hooks","issue_events_url":"https://api.github.com/repos/guobingkun/druid/issues/events{/number}","events_url":"https://api.github.com/repos/guobingkun/druid/events","assignees_url":"https://api.github.com/repos/guobingkun/druid/assignees{/user}","branches_url":"https://api.github.com/repos/guobingkun/druid/branches{/branch}","tags_url":"https://api.github.com/repos/guobingkun/druid/tags","blobs_url":"https://api.github.com/repos/guobingkun/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guobingkun/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guobingkun/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/guobingkun/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guobingkun/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/guobingkun/druid/languages","stargazers_url":"https://api.github.com/repos/guobingkun/druid/stargazers","contributors_url":"https://api.github.com/repos/guobingkun/druid/contributors","subscribers_url":"https://api.github.com/repos/guobingkun/druid/subscribers","subscription_url":"https://api.github.com/repos/guobingkun/druid/subscription","commits_url":"https://api.github.com/repos/guobingkun/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/guobingkun/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/guobingkun/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/guobingkun/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/guobingkun/druid/contents/{+path}","compare_url":"https://api.github.com/repos/guobingkun/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guobingkun/druid/merges","archive_url":"https://api.github.com/repos/guobingkun/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guobingkun/druid/downloads","issues_url":"https://api.github.com/repos/guobingkun/druid/issues{/number}","pulls_url":"https://api.github.com/repos/guobingkun/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/guobingkun/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/guobingkun/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guobingkun/druid/labels{/name}","releases_url":"https://api.github.com/repos/guobingkun/druid/releases{/id}","created_at":"2015-04-03T18:24:06Z","updated_at":"2015-05-07T19:33:13Z","pushed_at":"2015-05-15T19:40:48Z","git_url":"git://github.com/guobingkun/druid.git","ssh_url":"git@github.com:guobingkun/druid.git","clone_url":"https://github.com/guobingkun/druid.git","svn_url":"https://github.com/guobingkun/druid","homepage":"http://druid.io","size":92978,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"87924c7c661da1468d1ada8d86838736f9978158","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"name":"druid","full_name":"druid-io/druid","owner":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/druid-io/druid","description":"Real²time Exploratory Analytics on Large Datasets","fork":false,"url":"https://api.github.com/repos/druid-io/druid","forks_url":"https://api.github.com/repos/druid-io/druid/forks","keys_url":"https://api.github.com/repos/druid-io/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/druid-io/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/druid-io/druid/teams","hooks_url":"https://api.github.com/repos/druid-io/druid/hooks","issue_events_url":"https://api.github.com/repos/druid-io/druid/issues/events{/number}","events_url":"https://api.github.com/repos/druid-io/druid/events","assignees_url":"https://api.github.com/repos/druid-io/druid/assignees{/user}","branches_url":"https://api.github.com/repos/druid-io/druid/branches{/branch}","tags_url":"https://api.github.com/repos/druid-io/druid/tags","blobs_url":"https://api.github.com/repos/druid-io/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/druid-io/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/druid-io/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/druid-io/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/druid-io/druid/languages","stargazers_url":"https://api.github.com/repos/druid-io/druid/stargazers","contributors_url":"https://api.github.com/repos/druid-io/druid/contributors","subscribers_url":"https://api.github.com/repos/druid-io/druid/subscribers","subscription_url":"https://api.github.com/repos/druid-io/druid/subscription","commits_url":"https://api.github.com/repos/druid-io/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/druid-io/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/druid-io/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/druid-io/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/druid-io/druid/contents/{+path}","compare_url":"https://api.github.com/repos/druid-io/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/druid-io/druid/merges","archive_url":"https://api.github.com/repos/druid-io/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/druid-io/druid/downloads","issues_url":"https://api.github.com/repos/druid-io/druid/issues{/number}","pulls_url":"https://api.github.com/repos/druid-io/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/druid-io/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/druid-io/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/druid-io/druid/labels{/name}","releases_url":"https://api.github.com/repos/druid-io/druid/releases{/id}","created_at":"2012-10-23T19:08:07Z","updated_at":"2015-05-15T14:34:06Z","pushed_at":"2015-05-15T19:43:44Z","git_url":"git://github.com/druid-io/druid.git","ssh_url":"git@github.com:druid-io/druid.git","clone_url":"https://github.com/druid-io/druid.git","svn_url":"https://github.com/druid-io/druid","homepage":"http://druid.io","size":173622,"stargazers_count":1728,"watchers_count":1728,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":374,"mirror_url":null,"open_issues_count":149,"forks":374,"open_issues":149,"watchers":1728,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1371"},"html":{"href":"https://github.com/druid-io/druid/pull/1371"},"issue":{"href":"https://api.github.com/repos/druid-io/druid/issues/1371"},"comments":{"href":"https://api.github.com/repos/druid-io/druid/issues/1371/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1371/comments"},"review_comment":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1371/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/druid/statuses/d5ee1a5a4202f297a8e6090fc0c78daefbc45579"}}}}