{"action":"created","comment":{"url":"https://api.github.com/repos/apache/beam/pulls/comments/175165866","pull_request_review_id":104658367,"id":175165866,"diff_hunk":"@@ -0,0 +1,195 @@\n+package datastoreio\n+\n+import (\n+\t\"reflect\"\n+\t\"github.com/apache/beam/sdks/go/pkg/beam\"\n+\t\"sort\"\n+\t\"google.golang.org/api/iterator\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"cloud.google.com/go/datastore\"\n+\t\"context\"\n+\t\"math\"\n+\t\"github.com/apache/beam/sdks/go/pkg/beam/core/runtime\"\n+\t\"strconv\"\n+)\n+\n+const (\n+\tscatterPropertyName = \"__scatter__\"\n+)\n+\n+// Read reads all rows from the given kind. The kind must have a schema  compatible with the given type, t, and Read\n+// returns a PCollection<t>. You must also register your type with runtime.RegisterType which allows you to implement\n+// datastore.PropertyLoadSaver\n+//\n+//\n+// Example:\n+// type Item struct {}\n+// itemKey = runtime.RegisterType(reflect.TypeOf((*Item)(nil)).Elem())\n+//\n+// datastoreio.Read(s, \"project\", \"Item\", 256, reflect.TypeOf(Item{}), itemKey)\n+func Read(s beam.Scope, project, kind string, shards int, t reflect.Type, typeKey string) beam.PCollection {\n+\ts = s.Scope(\"datastore.Read\")\n+\treturn query(s, project, kind, shards, t, typeKey)\n+}\n+\n+func query(s beam.Scope, project, kind string, shards int, t reflect.Type, typeKey string) beam.PCollection {\n+\timp := beam.Impulse(s)\n+\tex := beam.ParDo(s, &splitQueryFn{Project: project, Kind: kind, Shards: shards}, imp)\n+\tg := beam.GroupByKey(s, ex)\n+\treturn beam.ParDo(s, &queryFn{Project: project, Kind: kind, Type: typeKey}, g, beam.TypeDefinition{Var: beam.XType, T: t})\n+}\n+\n+type splitQueryFn struct {","path":"sdks/go/pkg/beam/io/datastoreio/datastore.go","position":43,"original_position":43,"commit_id":"af52d227bded9cea202dea9f55c25ee977e9535b","original_commit_id":"af52d227bded9cea202dea9f55c25ee977e9535b","user":{"login":"bbassingthwaite-va","id":1919080,"avatar_url":"https://avatars0.githubusercontent.com/u/1919080?v=4","gravatar_id":"","url":"https://api.github.com/users/bbassingthwaite-va","html_url":"https://github.com/bbassingthwaite-va","followers_url":"https://api.github.com/users/bbassingthwaite-va/followers","following_url":"https://api.github.com/users/bbassingthwaite-va/following{/other_user}","gists_url":"https://api.github.com/users/bbassingthwaite-va/gists{/gist_id}","starred_url":"https://api.github.com/users/bbassingthwaite-va/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbassingthwaite-va/subscriptions","organizations_url":"https://api.github.com/users/bbassingthwaite-va/orgs","repos_url":"https://api.github.com/users/bbassingthwaite-va/repos","events_url":"https://api.github.com/users/bbassingthwaite-va/events{/privacy}","received_events_url":"https://api.github.com/users/bbassingthwaite-va/received_events","type":"User","site_admin":false},"body":"Right, I missed this when porting it from our code.","created_at":"2018-03-16T17:41:17Z","updated_at":"2018-03-16T17:41:17Z","html_url":"https://github.com/apache/beam/pull/4850#discussion_r175165866","pull_request_url":"https://api.github.com/repos/apache/beam/pulls/4850","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/comments/175165866"},"html":{"href":"https://github.com/apache/beam/pull/4850#discussion_r175165866"},"pull_request":{"href":"https://api.github.com/repos/apache/beam/pulls/4850"}},"in_reply_to_id":175145574},"pull_request":{"url":"https://api.github.com/repos/apache/beam/pulls/4850","id":174393349,"html_url":"https://github.com/apache/beam/pull/4850","diff_url":"https://github.com/apache/beam/pull/4850.diff","patch_url":"https://github.com/apache/beam/pull/4850.patch","issue_url":"https://api.github.com/repos/apache/beam/issues/4850","number":4850,"state":"open","locked":false,"title":"- Go SDK Datastore IO reader","user":{"login":"bbassingthwaite-va","id":1919080,"avatar_url":"https://avatars0.githubusercontent.com/u/1919080?v=4","gravatar_id":"","url":"https://api.github.com/users/bbassingthwaite-va","html_url":"https://github.com/bbassingthwaite-va","followers_url":"https://api.github.com/users/bbassingthwaite-va/followers","following_url":"https://api.github.com/users/bbassingthwaite-va/following{/other_user}","gists_url":"https://api.github.com/users/bbassingthwaite-va/gists{/gist_id}","starred_url":"https://api.github.com/users/bbassingthwaite-va/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbassingthwaite-va/subscriptions","organizations_url":"https://api.github.com/users/bbassingthwaite-va/orgs","repos_url":"https://api.github.com/users/bbassingthwaite-va/repos","events_url":"https://api.github.com/users/bbassingthwaite-va/events{/privacy}","received_events_url":"https://api.github.com/users/bbassingthwaite-va/received_events","type":"User","site_admin":false},"body":"@herohde \r\n\r\nThis is based on the python input reader but is not feature complete and needs more work. I am mostly opening this if anyone else would find it useful but also to provide feedback on the go sdk.\r\n\r\n1) Parallelism looks to be missing? Running this on Dataflow on an entity with 90 million items takes a long time (12+ hours). I've tried with 256, 512, and 1024 shards and the dataflow typically always runs with 4 workers no matter the shard size, I would have expected it to fan out and process at a much faster rate. Is this because of the compat runtime? Am I doing something wrong with my pipeline? Any insight would be great. I want to start using this for much larger size datasets, but the throughput isn't at a level that I could start using it.\r\n\r\n2) `beam.EncodeType` should not serialize the type and reconstruct on the other end. I can't think of a time that i would ever use this, losing the methods is a deal breaker, as well as not being able to handle complex structures. For example the `datastore.Key` has a recursive definition, and can't be put into this format. I might be missing something on this one but I am working on very little documentation(which is fine for now). The other example is that my struct implements `datastore.PropertyLoadSaver` which is lost when using `beam.EncodeType`. There doesn't seem to be an API to take advantage of `runtime.RegisterType` when using generics.\r\n\r\n\r\nThanks!\r\n\r\n\r\n","created_at":"2018-03-12T14:55:40Z","updated_at":"2018-03-16T17:41:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e680d1a929cd9aa3a2e625ac5ad733de423521f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/beam/pulls/4850/commits","review_comments_url":"https://api.github.com/repos/apache/beam/pulls/4850/comments","review_comment_url":"https://api.github.com/repos/apache/beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/beam/issues/4850/comments","statuses_url":"https://api.github.com/repos/apache/beam/statuses/af52d227bded9cea202dea9f55c25ee977e9535b","head":{"label":"bbassingthwaite-va:master","ref":"master","sha":"af52d227bded9cea202dea9f55c25ee977e9535b","user":{"login":"bbassingthwaite-va","id":1919080,"avatar_url":"https://avatars0.githubusercontent.com/u/1919080?v=4","gravatar_id":"","url":"https://api.github.com/users/bbassingthwaite-va","html_url":"https://github.com/bbassingthwaite-va","followers_url":"https://api.github.com/users/bbassingthwaite-va/followers","following_url":"https://api.github.com/users/bbassingthwaite-va/following{/other_user}","gists_url":"https://api.github.com/users/bbassingthwaite-va/gists{/gist_id}","starred_url":"https://api.github.com/users/bbassingthwaite-va/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbassingthwaite-va/subscriptions","organizations_url":"https://api.github.com/users/bbassingthwaite-va/orgs","repos_url":"https://api.github.com/users/bbassingthwaite-va/repos","events_url":"https://api.github.com/users/bbassingthwaite-va/events{/privacy}","received_events_url":"https://api.github.com/users/bbassingthwaite-va/received_events","type":"User","site_admin":false},"repo":{"id":124810048,"name":"beam","full_name":"bbassingthwaite-va/beam","owner":{"login":"bbassingthwaite-va","id":1919080,"avatar_url":"https://avatars0.githubusercontent.com/u/1919080?v=4","gravatar_id":"","url":"https://api.github.com/users/bbassingthwaite-va","html_url":"https://github.com/bbassingthwaite-va","followers_url":"https://api.github.com/users/bbassingthwaite-va/followers","following_url":"https://api.github.com/users/bbassingthwaite-va/following{/other_user}","gists_url":"https://api.github.com/users/bbassingthwaite-va/gists{/gist_id}","starred_url":"https://api.github.com/users/bbassingthwaite-va/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbassingthwaite-va/subscriptions","organizations_url":"https://api.github.com/users/bbassingthwaite-va/orgs","repos_url":"https://api.github.com/users/bbassingthwaite-va/repos","events_url":"https://api.github.com/users/bbassingthwaite-va/events{/privacy}","received_events_url":"https://api.github.com/users/bbassingthwaite-va/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bbassingthwaite-va/beam","description":"Apache Beam","fork":true,"url":"https://api.github.com/repos/bbassingthwaite-va/beam","forks_url":"https://api.github.com/repos/bbassingthwaite-va/beam/forks","keys_url":"https://api.github.com/repos/bbassingthwaite-va/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bbassingthwaite-va/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bbassingthwaite-va/beam/teams","hooks_url":"https://api.github.com/repos/bbassingthwaite-va/beam/hooks","issue_events_url":"https://api.github.com/repos/bbassingthwaite-va/beam/issues/events{/number}","events_url":"https://api.github.com/repos/bbassingthwaite-va/beam/events","assignees_url":"https://api.github.com/repos/bbassingthwaite-va/beam/assignees{/user}","branches_url":"https://api.github.com/repos/bbassingthwaite-va/beam/branches{/branch}","tags_url":"https://api.github.com/repos/bbassingthwaite-va/beam/tags","blobs_url":"https://api.github.com/repos/bbassingthwaite-va/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bbassingthwaite-va/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bbassingthwaite-va/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/bbassingthwaite-va/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bbassingthwaite-va/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/bbassingthwaite-va/beam/languages","stargazers_url":"https://api.github.com/repos/bbassingthwaite-va/beam/stargazers","contributors_url":"https://api.github.com/repos/bbassingthwaite-va/beam/contributors","subscribers_url":"https://api.github.com/repos/bbassingthwaite-va/beam/subscribers","subscription_url":"https://api.github.com/repos/bbassingthwaite-va/beam/subscription","commits_url":"https://api.github.com/repos/bbassingthwaite-va/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/bbassingthwaite-va/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/bbassingthwaite-va/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/bbassingthwaite-va/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/bbassingthwaite-va/beam/contents/{+path}","compare_url":"https://api.github.com/repos/bbassingthwaite-va/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bbassingthwaite-va/beam/merges","archive_url":"https://api.github.com/repos/bbassingthwaite-va/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bbassingthwaite-va/beam/downloads","issues_url":"https://api.github.com/repos/bbassingthwaite-va/beam/issues{/number}","pulls_url":"https://api.github.com/repos/bbassingthwaite-va/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/bbassingthwaite-va/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/bbassingthwaite-va/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bbassingthwaite-va/beam/labels{/name}","releases_url":"https://api.github.com/repos/bbassingthwaite-va/beam/releases{/id}","deployments_url":"https://api.github.com/repos/bbassingthwaite-va/beam/deployments","created_at":"2018-03-11T23:41:13Z","updated_at":"2018-03-11T23:41:26Z","pushed_at":"2018-03-12T14:31:38Z","git_url":"git://github.com/bbassingthwaite-va/beam.git","ssh_url":"git@github.com:bbassingthwaite-va/beam.git","clone_url":"https://github.com/bbassingthwaite-va/beam.git","svn_url":"https://github.com/bbassingthwaite-va/beam","homepage":"","size":54936,"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":0,"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"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"793bfac7516c2532ad4c979da220f2a9801e1b19","user":{"login":"apache","id":47359,"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,"name":"beam","full_name":"apache/beam","owner":{"login":"apache","id":47359,"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-03-16T16:53:30Z","pushed_at":"2018-03-16T17:33:16Z","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":"","size":55175,"stargazers_count":1750,"watchers_count":1750,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1057,"mirror_url":null,"archived":false,"open_issues_count":104,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1057,"open_issues":104,"watchers":1750,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/4850"},"html":{"href":"https://github.com/apache/beam/pull/4850"},"issue":{"href":"https://api.github.com/repos/apache/beam/issues/4850"},"comments":{"href":"https://api.github.com/repos/apache/beam/issues/4850/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/beam/pulls/4850/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/beam/pulls/4850/commits"},"statuses":{"href":"https://api.github.com/repos/apache/beam/statuses/af52d227bded9cea202dea9f55c25ee977e9535b"}},"author_association":"NONE"}}
{"actor":{"display_login":"bbassingthwaite-va"}}