{"action":"created","comment":{"url":"https://api.github.com/repos/apache/beam/pulls/comments/210425410","pull_request_review_id":146639075,"id":210425410,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDQyNTQxMA==","diff_hunk":"@@ -0,0 +1,157 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF 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, 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+\n+package org.apache.beam.sdk.io.synthetic;\n+\n+import static org.hamcrest.Matchers.containsInAnyOrder;\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertFalse;\n+import static org.junit.Assert.assertThat;\n+\n+import com.fasterxml.jackson.core.JsonParseException;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import java.io.IOException;\n+import java.nio.ByteBuffer;\n+import java.util.ArrayList;\n+import java.util.List;\n+import org.apache.beam.sdk.transforms.DoFnTester;\n+import org.apache.beam.sdk.values.KV;\n+import org.apache.commons.math3.distribution.ConstantRealDistribution;\n+import org.junit.Rule;\n+import org.junit.Test;\n+import org.junit.rules.ExpectedException;\n+import org.junit.runner.RunWith;\n+import org.junit.runners.JUnit4;\n+\n+/** Unit tests for {@link SyntheticStep}. */\n+@RunWith(JUnit4.class)\n+public class SyntheticStepTest {\n+  @Rule public final ExpectedException thrown = ExpectedException.none();\n+\n+  private byte[] intToByteArray(int value) {\n+    return ByteBuffer.allocate(4).putInt(value).array();\n+  }\n+\n+  private SyntheticStep.Options fromString(String jsonString) throws IOException {\n+    ObjectMapper mapper = new ObjectMapper();\n+    SyntheticStep.Options result = mapper.readValue(jsonString, SyntheticStep.Options.class);\n+    result.validate();\n+    return result;\n+  }\n+\n+  private SyntheticStep.Options createStepOptions(\n+      double outputRecordsPerInputRecord,\n+      boolean preservesInputKeyDistribution,\n+      long keySizeBytes,\n+      long valueSizeBytes,\n+      long numHotKeys,\n+      double hotKeyFraction,\n+      int seed,\n+      SyntheticOptions.Sampler dist) {\n+    SyntheticStep.Options options = new SyntheticStep.Options();\n+    options.outputRecordsPerInputRecord = outputRecordsPerInputRecord;\n+    options.preservesInputKeyDistribution = preservesInputKeyDistribution;\n+    options.keySizeBytes = keySizeBytes;\n+    options.valueSizeBytes = valueSizeBytes;\n+    options.numHotKeys = numHotKeys;\n+    options.hotKeyFraction = hotKeyFraction;\n+    options.setSeed(seed);\n+    options.delayDistribution = dist;\n+    return options;\n+  }\n+\n+  @Test\n+  public void testInvalidSyntheticStepOptionsJsonFormat() throws Exception {\n+    thrown.expect(JsonParseException.class);\n+    String syntheticStepOptions = \"unknown json format\";\n+    fromString(syntheticStepOptions);\n+  }\n+\n+  @Test\n+  public void testFromString() throws Exception {\n+    String syntheticStepOptions =\n+        \"{\\\"outputRecordsPerInputRecord\\\":5.0,\\\"preservesInputKeyDistribution\\\":false,\"\n+            + \"\\\"keySizeBytes\\\":10,\\\"valueSizeBytes\\\":20,\\\"numHotKeys\\\":3,\\\"hotKeyFraction\\\":0.3,\"\n+            + \"\\\"seed\\\":123456,\\\"delayDistribution\\\":{\\\"type\\\":\\\"const\\\",\\\"const\\\":10}}\";\n+    SyntheticStep.Options stepOptions = fromString(syntheticStepOptions);\n+    assertEquals(5.0, stepOptions.outputRecordsPerInputRecord, 0);\n+    assertFalse(stepOptions.preservesInputKeyDistribution);\n+    assertEquals(10, stepOptions.keySizeBytes);\n+    assertEquals(20, stepOptions.valueSizeBytes);\n+    assertEquals(3, stepOptions.numHotKeys);\n+    assertEquals(0.3, stepOptions.hotKeyFraction, 0);\n+    assertEquals(10, stepOptions.nextDelay(stepOptions.seed));\n+    assertEquals(123456, stepOptions.seed);\n+  }\n+\n+  @Test\n+  public void testSyntheticStepWithPreservingInputKeyDistribution() throws Exception {\n+    DoFnTester<KV<byte[], byte[]>, KV<byte[], byte[]>> fnTester =","path":"sdks/java/io/synthetic/src/test/java/org/apache/beam/sdk/io/synthetic/SyntheticStepTest.java","position":104,"original_position":104,"commit_id":"ffe8c48acd68e856fa4056dac92b1da5acc688fa","original_commit_id":"ffe8c48acd68e856fa4056dac92b1da5acc688fa","user":{"login":"pabloem","id":1301740,"node_id":"MDQ6VXNlcjEzMDE3NDA=","avatar_url":"https://avatars2.githubusercontent.com/u/1301740?v=4","gravatar_id":"","url":"https://api.github.com/users/pabloem","html_url":"https://github.com/pabloem","followers_url":"https://api.github.com/users/pabloem/followers","following_url":"https://api.github.com/users/pabloem/following{/other_user}","gists_url":"https://api.github.com/users/pabloem/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloem/subscriptions","organizations_url":"https://api.github.com/users/pabloem/orgs","repos_url":"https://api.github.com/users/pabloem/repos","events_url":"https://api.github.com/users/pabloem/events{/privacy}","received_events_url":"https://api.github.com/users/pabloem/received_events","type":"User","site_admin":false},"body":"Done. Thanks for catching this : )","created_at":"2018-08-15T22:09:20Z","updated_at":"2018-08-15T22:09:20Z","html_url":"https://github.com/apache/beam/pull/6047#discussion_r210425410","pull_request_url":"https://api.github.com/repos/apache/beam/pulls/6047","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/comments/210425410"},"html":{"href":"https://github.com/apache/beam/pull/6047#discussion_r210425410"},"pull_request":{"href":"https://api.github.com/repos/apache/beam/pulls/6047"}},"in_reply_to_id":207836952},"pull_request":{"url":"https://api.github.com/repos/apache/beam/pulls/6047","id":203595643,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzNTk1NjQz","html_url":"https://github.com/apache/beam/pull/6047","diff_url":"https://github.com/apache/beam/pull/6047.diff","patch_url":"https://github.com/apache/beam/pull/6047.patch","issue_url":"https://api.github.com/repos/apache/beam/issues/6047","number":6047,"state":"open","locked":false,"title":"Adding Synthetic Step to Synthetic Package","user":{"login":"pabloem","id":1301740,"node_id":"MDQ6VXNlcjEzMDE3NDA=","avatar_url":"https://avatars2.githubusercontent.com/u/1301740?v=4","gravatar_id":"","url":"https://api.github.com/users/pabloem","html_url":"https://github.com/pabloem","followers_url":"https://api.github.com/users/pabloem/followers","following_url":"https://api.github.com/users/pabloem/following{/other_user}","gists_url":"https://api.github.com/users/pabloem/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloem/subscriptions","organizations_url":"https://api.github.com/users/pabloem/orgs","repos_url":"https://api.github.com/users/pabloem/repos","events_url":"https://api.github.com/users/pabloem/events{/privacy}","received_events_url":"https://api.github.com/users/pabloem/received_events","type":"User","site_admin":false},"body":"r: @lgajowy \r\nI am currently relying on the same workaround as you are for your PR. We need to figure out how `hashFunction` is meant to be used properly...","created_at":"2018-07-24T17:08:59Z","updated_at":"2018-08-15T22:09:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"acca7801bc162dec1bb600cb3636fda0f053a934","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/beam/pulls/6047/commits","review_comments_url":"https://api.github.com/repos/apache/beam/pulls/6047/comments","review_comment_url":"https://api.github.com/repos/apache/beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/beam/issues/6047/comments","statuses_url":"https://api.github.com/repos/apache/beam/statuses/ffe8c48acd68e856fa4056dac92b1da5acc688fa","head":{"label":"pabloem:synthetic-step","ref":"synthetic-step","sha":"ffe8c48acd68e856fa4056dac92b1da5acc688fa","user":{"login":"pabloem","id":1301740,"node_id":"MDQ6VXNlcjEzMDE3NDA=","avatar_url":"https://avatars2.githubusercontent.com/u/1301740?v=4","gravatar_id":"","url":"https://api.github.com/users/pabloem","html_url":"https://github.com/pabloem","followers_url":"https://api.github.com/users/pabloem/followers","following_url":"https://api.github.com/users/pabloem/following{/other_user}","gists_url":"https://api.github.com/users/pabloem/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloem/subscriptions","organizations_url":"https://api.github.com/users/pabloem/orgs","repos_url":"https://api.github.com/users/pabloem/repos","events_url":"https://api.github.com/users/pabloem/events{/privacy}","received_events_url":"https://api.github.com/users/pabloem/received_events","type":"User","site_admin":false},"repo":{"id":69611732,"node_id":"MDEwOlJlcG9zaXRvcnk2OTYxMTczMg==","name":"incubator-beam","full_name":"pabloem/incubator-beam","owner":{"login":"pabloem","id":1301740,"node_id":"MDQ6VXNlcjEzMDE3NDA=","avatar_url":"https://avatars2.githubusercontent.com/u/1301740?v=4","gravatar_id":"","url":"https://api.github.com/users/pabloem","html_url":"https://github.com/pabloem","followers_url":"https://api.github.com/users/pabloem/followers","following_url":"https://api.github.com/users/pabloem/following{/other_user}","gists_url":"https://api.github.com/users/pabloem/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloem/subscriptions","organizations_url":"https://api.github.com/users/pabloem/orgs","repos_url":"https://api.github.com/users/pabloem/repos","events_url":"https://api.github.com/users/pabloem/events{/privacy}","received_events_url":"https://api.github.com/users/pabloem/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pabloem/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/pabloem/incubator-beam","forks_url":"https://api.github.com/repos/pabloem/incubator-beam/forks","keys_url":"https://api.github.com/repos/pabloem/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pabloem/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pabloem/incubator-beam/teams","hooks_url":"https://api.github.com/repos/pabloem/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/pabloem/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/pabloem/incubator-beam/events","assignees_url":"https://api.github.com/repos/pabloem/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/pabloem/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/pabloem/incubator-beam/tags","blobs_url":"https://api.github.com/repos/pabloem/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pabloem/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pabloem/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/pabloem/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pabloem/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/pabloem/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/pabloem/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/pabloem/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/pabloem/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/pabloem/incubator-beam/subscription","commits_url":"https://api.github.com/repos/pabloem/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/pabloem/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/pabloem/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/pabloem/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/pabloem/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/pabloem/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pabloem/incubator-beam/merges","archive_url":"https://api.github.com/repos/pabloem/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pabloem/incubator-beam/downloads","issues_url":"https://api.github.com/repos/pabloem/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/pabloem/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/pabloem/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/pabloem/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pabloem/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/pabloem/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/pabloem/incubator-beam/deployments","created_at":"2016-09-29T22:05:49Z","updated_at":"2018-04-18T23:58:11Z","pushed_at":"2018-08-14T22:12:32Z","git_url":"git://github.com/pabloem/incubator-beam.git","ssh_url":"git@github.com:pabloem/incubator-beam.git","clone_url":"https://github.com/pabloem/incubator-beam.git","svn_url":"https://github.com/pabloem/incubator-beam","homepage":null,"size":94614,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"7ea9c82457c96835215bf799836738e256bac1da","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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":50904245,"node_id":"MDEwOlJlcG9zaXRvcnk1MDkwNDI0NQ==","name":"beam","full_name":"apache/beam","owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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/beam","description":"Apache Beam","fork":false,"url":"https://api.github.com/repos/apache/beam","forks_url":"https://api.github.com/repos/apache/beam/forks","keys_url":"https://api.github.com/repos/apache/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/beam/teams","hooks_url":"https://api.github.com/repos/apache/beam/hooks","issue_events_url":"https://api.github.com/repos/apache/beam/issues/events{/number}","events_url":"https://api.github.com/repos/apache/beam/events","assignees_url":"https://api.github.com/repos/apache/beam/assignees{/user}","branches_url":"https://api.github.com/repos/apache/beam/branches{/branch}","tags_url":"https://api.github.com/repos/apache/beam/tags","blobs_url":"https://api.github.com/repos/apache/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/beam/languages","stargazers_url":"https://api.github.com/repos/apache/beam/stargazers","contributors_url":"https://api.github.com/repos/apache/beam/contributors","subscribers_url":"https://api.github.com/repos/apache/beam/subscribers","subscription_url":"https://api.github.com/repos/apache/beam/subscription","commits_url":"https://api.github.com/repos/apache/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/beam/contents/{+path}","compare_url":"https://api.github.com/repos/apache/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/beam/merges","archive_url":"https://api.github.com/repos/apache/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/beam/downloads","issues_url":"https://api.github.com/repos/apache/beam/issues{/number}","pulls_url":"https://api.github.com/repos/apache/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/beam/labels{/name}","releases_url":"https://api.github.com/repos/apache/beam/releases{/id}","deployments_url":"https://api.github.com/repos/apache/beam/deployments","created_at":"2016-02-02T08:00:06Z","updated_at":"2018-08-15T22:04:53Z","pushed_at":"2018-08-15T22:08:43Z","git_url":"git://github.com/apache/beam.git","ssh_url":"git@github.com:apache/beam.git","clone_url":"https://github.com/apache/beam.git","svn_url":"https://github.com/apache/beam","homepage":"https://beam.apache.org","size":100288,"stargazers_count":2055,"watchers_count":2055,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1287,"mirror_url":null,"archived":false,"open_issues_count":89,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1287,"open_issues":89,"watchers":2055,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/6047"},"html":{"href":"https://github.com/apache/beam/pull/6047"},"issue":{"href":"https://api.github.com/repos/apache/beam/issues/6047"},"comments":{"href":"https://api.github.com/repos/apache/beam/issues/6047/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/beam/pulls/6047/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/beam/pulls/6047/commits"},"statuses":{"href":"https://api.github.com/repos/apache/beam/statuses/ffe8c48acd68e856fa4056dac92b1da5acc688fa"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"pabloem"}}