{"action":"created","comment":{"url":"https://api.github.com/repos/google/kythe/pulls/comments/191013249","pull_request_review_id":123507817,"id":191013249,"diff_hunk":"@@ -0,0 +1,193 @@\n+/*\n+ * Copyright 2018 Google Inc. All rights reserved.\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+\n+// Package nodes provides Beam transformations over *ppb.Nodes.\n+package nodes\n+\n+import (\n+\t\"fmt\"\n+\t\"reflect\"\n+\t\"sort\"\n+\n+\t\"kythe.io/kythe/go/services/graphstore/compare\"\n+\t\"kythe.io/kythe/go/util/schema\"\n+\t\"kythe.io/kythe/go/util/schema/edges\"\n+\t\"kythe.io/kythe/go/util/schema/facts\"\n+\n+\t\"github.com/apache/beam/sdks/go/pkg/beam\"\n+\n+\tppb \"kythe.io/kythe/proto/pipeline_go_proto\"\n+\tscpb \"kythe.io/kythe/proto/schema_go_proto\"\n+\tspb \"kythe.io/kythe/proto/storage_go_proto\"\n+)\n+\n+func init() {\n+\tbeam.RegisterFunction(embedSourceKey)\n+\tbeam.RegisterFunction(entryToNode)\n+\n+\tbeam.RegisterType(reflect.TypeOf((*combineNodes)(nil)).Elem())\n+}\n+\n+// FromEntries transforms a PCollection of *ppb.Entry protos into *ppb.Nodes.\n+func FromEntries(s beam.Scope, entries beam.PCollection) beam.PCollection {\n+\treturn beam.ParDo(s, embedSourceKey,\n+\t\tbeam.CombinePerKey(s, &combineNodes{},\n+\t\t\tbeam.ParDo(s, entryToNode, entries)))\n+}\n+\n+func entryToNode(e *spb.Entry, emit func(*spb.VName, *ppb.Node)) error {\n+\tif e.Source == nil {\n+\t\treturn fmt.Errorf(\"invalid Entry: source is missing: %+v\", e)\n+\t}\n+\n+\tn := &ppb.Node{}\n+\tif e.EdgeKind == \"\" {\n+\t\tif e.FactName == \"\" || e.Target != nil {\n+\t\t\treturn fmt.Errorf(\"invalid fact Entry: {%v}\", e)\n+\t\t}\n+\n+\t\tswitch e.FactName {\n+\t\tcase facts.NodeKind:\n+\t\t\tkind := string(e.FactValue)\n+\t\t\tif k := schema.NodeKind(kind); k != scpb.NodeKind_UNKNOWN_NODE_KIND {\n+\t\t\t\tn.Kind = &ppb.Node_KytheKind{k}\n+\t\t\t} else {\n+\t\t\t\tn.Kind = &ppb.Node_GenericKind{kind}\n+\t\t\t}\n+\t\tcase facts.Subkind:\n+\t\t\tsubkind := string(e.FactValue)\n+\t\t\tif k := schema.Subkind(subkind); k != scpb.Subkind_UNKNOWN_SUBKIND {\n+\t\t\t\tn.Subkind = &ppb.Node_KytheSubkind{k}\n+\t\t\t} else {\n+\t\t\t\tn.Subkind = &ppb.Node_GenericSubkind{subkind}\n+\t\t\t}\n+\t\tdefault:\n+\t\t\tn.Fact = append(n.Fact, entryToFact(e))\n+\t\t}\n+\t} else {\n+\t\tif (e.FactName != \"/\" && e.FactName != \"\") || len(e.FactValue) != 0 || e.Target == nil {\n+\t\t\treturn fmt.Errorf(\"invalid edge Entry: {%v}\", e)\n+\t\t}\n+\n+\t\tn.Edge = append(n.Edge, entryToEdge(e))\n+\t}\n+\n+\temit(e.Source, n)\n+\treturn nil\n+}\n+\n+func entryToEdge(e *spb.Entry) *ppb.Edge {\n+\tkind, ord, _ := edges.ParseOrdinal(e.EdgeKind)\n+\tg := &ppb.Edge{Target: e.Target, Ordinal: int32(ord)}\n+\tedgeKind := schema.EdgeKind(kind)\n+\tif edgeKind == scpb.EdgeKind_UNKNOWN_EDGE_KIND {\n+\t\tg.Kind = &ppb.Edge_GenericKind{kind}\n+\t} else {\n+\t\tg.Kind = &ppb.Edge_KytheKind{edgeKind}\n+\t}\n+\treturn g\n+}\n+\n+func entryToFact(e *spb.Entry) *ppb.Fact {\n+\tf := &ppb.Fact{Value: e.FactValue}\n+\tname := schema.FactName(e.FactName)\n+\tif name == scpb.FactName_UNKNOWN_FACT_NAME {\n+\t\tf.Name = &ppb.Fact_GenericName{e.FactName}\n+\t} else {\n+\t\tf.Name = &ppb.Fact_KytheName{name}\n+\t}\n+\treturn f\n+}\n+\n+type combineNodes struct{}","path":"kythe/go/serving/pipeline/nodes/nodes.go","position":115,"original_position":115,"commit_id":"81368d85fa4dc45a7e7a020c6c75f7f0cf117f9f","original_commit_id":"81368d85fa4dc45a7e7a020c6c75f7f0cf117f9f","user":{"login":"jrtom","id":11969894,"avatar_url":"https://avatars3.githubusercontent.com/u/11969894?v=4","gravatar_id":"","url":"https://api.github.com/users/jrtom","html_url":"https://github.com/jrtom","followers_url":"https://api.github.com/users/jrtom/followers","following_url":"https://api.github.com/users/jrtom/following{/other_user}","gists_url":"https://api.github.com/users/jrtom/gists{/gist_id}","starred_url":"https://api.github.com/users/jrtom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrtom/subscriptions","organizations_url":"https://api.github.com/users/jrtom/orgs","repos_url":"https://api.github.com/users/jrtom/repos","events_url":"https://api.github.com/users/jrtom/events{/privacy}","received_events_url":"https://api.github.com/users/jrtom/received_events","type":"User","site_admin":false},"body":"Please add documentation for this type and for its public methods below.","created_at":"2018-05-25T21:27:55Z","updated_at":"2018-05-25T21:44:55Z","html_url":"https://github.com/google/kythe/pull/50#discussion_r191013249","pull_request_url":"https://api.github.com/repos/google/kythe/pulls/50","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/google/kythe/pulls/comments/191013249"},"html":{"href":"https://github.com/google/kythe/pull/50#discussion_r191013249"},"pull_request":{"href":"https://api.github.com/repos/google/kythe/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/google/kythe/pulls/50","id":190391834,"html_url":"https://github.com/google/kythe/pull/50","diff_url":"https://github.com/google/kythe/pull/50.diff","patch_url":"https://github.com/google/kythe/pull/50.patch","issue_url":"https://api.github.com/repos/google/kythe/issues/50","number":50,"state":"open","locked":false,"title":"Combine *spb.Entry protos into *ppb.Nodes","user":{"login":"schroederc","id":8930878,"avatar_url":"https://avatars3.githubusercontent.com/u/8930878?v=4","gravatar_id":"","url":"https://api.github.com/users/schroederc","html_url":"https://github.com/schroederc","followers_url":"https://api.github.com/users/schroederc/followers","following_url":"https://api.github.com/users/schroederc/following{/other_user}","gists_url":"https://api.github.com/users/schroederc/gists{/gist_id}","starred_url":"https://api.github.com/users/schroederc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schroederc/subscriptions","organizations_url":"https://api.github.com/users/schroederc/orgs","repos_url":"https://api.github.com/users/schroederc/repos","events_url":"https://api.github.com/users/schroederc/events{/privacy}","received_events_url":"https://api.github.com/users/schroederc/received_events","type":"User","site_admin":false},"body":"Nodes will be the basic input for the rest of the Kythe pipeline.  While\r\ncombining entries, duplicate edges/fact_values are discarded and known\r\nschema strings are stored as enums.","created_at":"2018-05-24T19:13:46Z","updated_at":"2018-05-25T21:44:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e60c4791a4aee481fe5d1b130b2a0f321703573","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/kythe/pulls/50/commits","review_comments_url":"https://api.github.com/repos/google/kythe/pulls/50/comments","review_comment_url":"https://api.github.com/repos/google/kythe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/kythe/issues/50/comments","statuses_url":"https://api.github.com/repos/google/kythe/statuses/81368d85fa4dc45a7e7a020c6c75f7f0cf117f9f","head":{"label":"schroederc:beam-nodes","ref":"beam-nodes","sha":"81368d85fa4dc45a7e7a020c6c75f7f0cf117f9f","user":{"login":"schroederc","id":8930878,"avatar_url":"https://avatars3.githubusercontent.com/u/8930878?v=4","gravatar_id":"","url":"https://api.github.com/users/schroederc","html_url":"https://github.com/schroederc","followers_url":"https://api.github.com/users/schroederc/followers","following_url":"https://api.github.com/users/schroederc/following{/other_user}","gists_url":"https://api.github.com/users/schroederc/gists{/gist_id}","starred_url":"https://api.github.com/users/schroederc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schroederc/subscriptions","organizations_url":"https://api.github.com/users/schroederc/orgs","repos_url":"https://api.github.com/users/schroederc/repos","events_url":"https://api.github.com/users/schroederc/events{/privacy}","received_events_url":"https://api.github.com/users/schroederc/received_events","type":"User","site_admin":false},"repo":{"id":109754450,"name":"kythe","full_name":"schroederc/kythe","owner":{"login":"schroederc","id":8930878,"avatar_url":"https://avatars3.githubusercontent.com/u/8930878?v=4","gravatar_id":"","url":"https://api.github.com/users/schroederc","html_url":"https://github.com/schroederc","followers_url":"https://api.github.com/users/schroederc/followers","following_url":"https://api.github.com/users/schroederc/following{/other_user}","gists_url":"https://api.github.com/users/schroederc/gists{/gist_id}","starred_url":"https://api.github.com/users/schroederc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schroederc/subscriptions","organizations_url":"https://api.github.com/users/schroederc/orgs","repos_url":"https://api.github.com/users/schroederc/repos","events_url":"https://api.github.com/users/schroederc/events{/privacy}","received_events_url":"https://api.github.com/users/schroederc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/schroederc/kythe","description":"Kythe is a pluggable, (mostly) language-agnostic ecosystem for building tools that work with code.","fork":true,"url":"https://api.github.com/repos/schroederc/kythe","forks_url":"https://api.github.com/repos/schroederc/kythe/forks","keys_url":"https://api.github.com/repos/schroederc/kythe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/schroederc/kythe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/schroederc/kythe/teams","hooks_url":"https://api.github.com/repos/schroederc/kythe/hooks","issue_events_url":"https://api.github.com/repos/schroederc/kythe/issues/events{/number}","events_url":"https://api.github.com/repos/schroederc/kythe/events","assignees_url":"https://api.github.com/repos/schroederc/kythe/assignees{/user}","branches_url":"https://api.github.com/repos/schroederc/kythe/branches{/branch}","tags_url":"https://api.github.com/repos/schroederc/kythe/tags","blobs_url":"https://api.github.com/repos/schroederc/kythe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/schroederc/kythe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/schroederc/kythe/git/refs{/sha}","trees_url":"https://api.github.com/repos/schroederc/kythe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/schroederc/kythe/statuses/{sha}","languages_url":"https://api.github.com/repos/schroederc/kythe/languages","stargazers_url":"https://api.github.com/repos/schroederc/kythe/stargazers","contributors_url":"https://api.github.com/repos/schroederc/kythe/contributors","subscribers_url":"https://api.github.com/repos/schroederc/kythe/subscribers","subscription_url":"https://api.github.com/repos/schroederc/kythe/subscription","commits_url":"https://api.github.com/repos/schroederc/kythe/commits{/sha}","git_commits_url":"https://api.github.com/repos/schroederc/kythe/git/commits{/sha}","comments_url":"https://api.github.com/repos/schroederc/kythe/comments{/number}","issue_comment_url":"https://api.github.com/repos/schroederc/kythe/issues/comments{/number}","contents_url":"https://api.github.com/repos/schroederc/kythe/contents/{+path}","compare_url":"https://api.github.com/repos/schroederc/kythe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/schroederc/kythe/merges","archive_url":"https://api.github.com/repos/schroederc/kythe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/schroederc/kythe/downloads","issues_url":"https://api.github.com/repos/schroederc/kythe/issues{/number}","pulls_url":"https://api.github.com/repos/schroederc/kythe/pulls{/number}","milestones_url":"https://api.github.com/repos/schroederc/kythe/milestones{/number}","notifications_url":"https://api.github.com/repos/schroederc/kythe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/schroederc/kythe/labels{/name}","releases_url":"https://api.github.com/repos/schroederc/kythe/releases{/id}","deployments_url":"https://api.github.com/repos/schroederc/kythe/deployments","created_at":"2017-11-06T21:55:11Z","updated_at":"2018-05-25T17:53:34Z","pushed_at":"2018-05-25T18:52:36Z","git_url":"git://github.com/schroederc/kythe.git","ssh_url":"git@github.com:schroederc/kythe.git","clone_url":"https://github.com/schroederc/kythe.git","svn_url":"https://github.com/schroederc/kythe","homepage":"https://kythe.io","size":156283,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":false,"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":"google:master","ref":"master","sha":"6c5b311367a51a34911f56a8c458c9e7fc26d7a1","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":29174627,"name":"kythe","full_name":"google/kythe","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/kythe","description":"Kythe is a pluggable, (mostly) language-agnostic ecosystem for building tools that work with code.","fork":false,"url":"https://api.github.com/repos/google/kythe","forks_url":"https://api.github.com/repos/google/kythe/forks","keys_url":"https://api.github.com/repos/google/kythe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/kythe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/kythe/teams","hooks_url":"https://api.github.com/repos/google/kythe/hooks","issue_events_url":"https://api.github.com/repos/google/kythe/issues/events{/number}","events_url":"https://api.github.com/repos/google/kythe/events","assignees_url":"https://api.github.com/repos/google/kythe/assignees{/user}","branches_url":"https://api.github.com/repos/google/kythe/branches{/branch}","tags_url":"https://api.github.com/repos/google/kythe/tags","blobs_url":"https://api.github.com/repos/google/kythe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/kythe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/kythe/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/kythe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/kythe/statuses/{sha}","languages_url":"https://api.github.com/repos/google/kythe/languages","stargazers_url":"https://api.github.com/repos/google/kythe/stargazers","contributors_url":"https://api.github.com/repos/google/kythe/contributors","subscribers_url":"https://api.github.com/repos/google/kythe/subscribers","subscription_url":"https://api.github.com/repos/google/kythe/subscription","commits_url":"https://api.github.com/repos/google/kythe/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/kythe/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/kythe/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/kythe/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/kythe/contents/{+path}","compare_url":"https://api.github.com/repos/google/kythe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/kythe/merges","archive_url":"https://api.github.com/repos/google/kythe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/kythe/downloads","issues_url":"https://api.github.com/repos/google/kythe/issues{/number}","pulls_url":"https://api.github.com/repos/google/kythe/pulls{/number}","milestones_url":"https://api.github.com/repos/google/kythe/milestones{/number}","notifications_url":"https://api.github.com/repos/google/kythe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/kythe/labels{/name}","releases_url":"https://api.github.com/repos/google/kythe/releases{/id}","deployments_url":"https://api.github.com/repos/google/kythe/deployments","created_at":"2015-01-13T05:39:06Z","updated_at":"2018-05-25T21:38:20Z","pushed_at":"2018-05-25T21:38:18Z","git_url":"git://github.com/google/kythe.git","ssh_url":"git@github.com:google/kythe.git","clone_url":"https://github.com/google/kythe.git","svn_url":"https://github.com/google/kythe","homepage":"https://kythe.io","size":156267,"stargazers_count":983,"watchers_count":983,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":119,"mirror_url":null,"archived":false,"open_issues_count":5,"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":119,"open_issues":5,"watchers":983,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/kythe/pulls/50"},"html":{"href":"https://github.com/google/kythe/pull/50"},"issue":{"href":"https://api.github.com/repos/google/kythe/issues/50"},"comments":{"href":"https://api.github.com/repos/google/kythe/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/google/kythe/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/google/kythe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/kythe/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/google/kythe/statuses/81368d85fa4dc45a7e7a020c6c75f7f0cf117f9f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jrtom"}}