{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/scalding/pulls/comments/32585939","id":32585939,"diff_hunk":"@@ -0,0 +1,323 @@\n+/*\n+ Copyright 2014 Twitter, Inc.\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+package com.twitter.scalding.serialization.macros.impl.ordered_serialization\n+\n+import scala.language.experimental.macros\n+import scala.reflect.macros.Context\n+\n+import com.twitter.scalding._\n+import com.twitter.scalding.serialization.OrderedSerialization\n+\n+object SealedTraitLike {\n+\n+  def compareBinary(c: Context)(inputStreamA: c.TermName, inputStreamB: c.TermName)(subData: List[(Int, c.Type, Option[TreeOrderedBuf[c.type]])]): c.Tree = {\n+    import c.universe._\n+    def freshT(id: String) = newTermName(c.fresh(id))\n+    val valueA = freshT(\"valueA\")\n+    val valueB = freshT(\"valueB\")\n+    val idxCmp = freshT(\"idxCmp\")\n+\n+    val compareSameTypes: Tree = subData.foldLeft(Option.empty[Tree]) {\n+      case (existing, (idx, tpe, optiTBuf)) =>\n+\n+        val commonCmp: Tree = optiTBuf.map{ tBuf =>\n+          tBuf.compareBinary(inputStreamA, inputStreamB)\n+        }.getOrElse[Tree](q\"0\")\n+\n+        existing match {\n+          case Some(t) =>\n+            Some(q\"\"\"\n+              if($valueA == $idx) {\n+                $commonCmp\n+              } else {\n+                $t\n+              }\n+            \"\"\")\n+          case None =>\n+            Some(q\"\"\"\n+                if($valueA == $idx) {\n+                  $commonCmp\n+                } else {\n+                  sys.error(\"Unable to compare unknown type\")","path":"scalding-serialization-macros/src/main/scala/com/twitter/scalding/serialization/macros/impl/ordered_serialization/SealedTraitLike.scala","position":54,"original_position":54,"commit_id":"14af24de4cf6c523e89b1326628d1f540b1a3246","original_commit_id":"14af24de4cf6c523e89b1326628d1f540b1a3246","user":{"login":"johnynek","id":67958,"avatar_url":"https://avatars.githubusercontent.com/u/67958?v=3","gravatar_id":"","url":"https://api.github.com/users/johnynek","html_url":"https://github.com/johnynek","followers_url":"https://api.github.com/users/johnynek/followers","following_url":"https://api.github.com/users/johnynek/following{/other_user}","gists_url":"https://api.github.com/users/johnynek/gists{/gist_id}","starred_url":"https://api.github.com/users/johnynek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnynek/subscriptions","organizations_url":"https://api.github.com/users/johnynek/orgs","repos_url":"https://api.github.com/users/johnynek/repos","events_url":"https://api.github.com/users/johnynek/events{/privacy}","received_events_url":"https://api.github.com/users/johnynek/received_events","type":"User","site_admin":false},"body":"how could this happen? Can you add a comment?","created_at":"2015-06-17T00:19:48Z","updated_at":"2015-06-17T00:19:48Z","html_url":"https://github.com/twitter/scalding/pull/1320#discussion_r32585939","pull_request_url":"https://api.github.com/repos/twitter/scalding/pulls/1320","_links":{"self":{"href":"https://api.github.com/repos/twitter/scalding/pulls/comments/32585939"},"html":{"href":"https://github.com/twitter/scalding/pull/1320#discussion_r32585939"},"pull_request":{"href":"https://api.github.com/repos/twitter/scalding/pulls/1320"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/scalding/pulls/1320","id":37649255,"html_url":"https://github.com/twitter/scalding/pull/1320","diff_url":"https://github.com/twitter/scalding/pull/1320.diff","patch_url":"https://github.com/twitter/scalding/pull/1320.patch","issue_url":"https://api.github.com/repos/twitter/scalding/issues/1320","number":1320,"state":"open","locked":false,"title":"Added a sealed trait ordered serializer. When it works its great. Not…","user":{"login":"ianoc","id":446652,"avatar_url":"https://avatars.githubusercontent.com/u/446652?v=3","gravatar_id":"","url":"https://api.github.com/users/ianoc","html_url":"https://github.com/ianoc","followers_url":"https://api.github.com/users/ianoc/followers","following_url":"https://api.github.com/users/ianoc/following{/other_user}","gists_url":"https://api.github.com/users/ianoc/gists{/gist_id}","starred_url":"https://api.github.com/users/ianoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianoc/subscriptions","organizations_url":"https://api.github.com/users/ianoc/orgs","repos_url":"https://api.github.com/users/ianoc/repos","events_url":"https://api.github.com/users/ianoc/events{/privacy}","received_events_url":"https://api.github.com/users/ianoc/received_events","type":"User","site_admin":false},"body":"… as reliable as we'd like. But hopefully restrictions on it will do the job","created_at":"2015-06-14T21:57:51Z","updated_at":"2015-06-17T00:19:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a7f593d6cb6c8b43d6f663416846cb50bee4e802","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/twitter/scalding/pulls/1320/commits","review_comments_url":"https://api.github.com/repos/twitter/scalding/pulls/1320/comments","review_comment_url":"https://api.github.com/repos/twitter/scalding/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/scalding/issues/1320/comments","statuses_url":"https://api.github.com/repos/twitter/scalding/statuses/14af24de4cf6c523e89b1326628d1f540b1a3246","head":{"label":"twitter:ioconnell/addSealedTraitSerializationMacro","ref":"ioconnell/addSealedTraitSerializationMacro","sha":"14af24de4cf6c523e89b1326628d1f540b1a3246","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":3146558,"name":"scalding","full_name":"twitter/scalding","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/scalding","description":"A Scala API for Cascading","fork":false,"url":"https://api.github.com/repos/twitter/scalding","forks_url":"https://api.github.com/repos/twitter/scalding/forks","keys_url":"https://api.github.com/repos/twitter/scalding/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/scalding/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/scalding/teams","hooks_url":"https://api.github.com/repos/twitter/scalding/hooks","issue_events_url":"https://api.github.com/repos/twitter/scalding/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/scalding/events","assignees_url":"https://api.github.com/repos/twitter/scalding/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/scalding/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/scalding/tags","blobs_url":"https://api.github.com/repos/twitter/scalding/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/scalding/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/scalding/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/scalding/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/scalding/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/scalding/languages","stargazers_url":"https://api.github.com/repos/twitter/scalding/stargazers","contributors_url":"https://api.github.com/repos/twitter/scalding/contributors","subscribers_url":"https://api.github.com/repos/twitter/scalding/subscribers","subscription_url":"https://api.github.com/repos/twitter/scalding/subscription","commits_url":"https://api.github.com/repos/twitter/scalding/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/scalding/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/scalding/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/scalding/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/scalding/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/scalding/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/scalding/merges","archive_url":"https://api.github.com/repos/twitter/scalding/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/scalding/downloads","issues_url":"https://api.github.com/repos/twitter/scalding/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/scalding/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/scalding/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/scalding/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/scalding/labels{/name}","releases_url":"https://api.github.com/repos/twitter/scalding/releases{/id}","created_at":"2012-01-10T16:22:08Z","updated_at":"2015-06-16T06:04:21Z","pushed_at":"2015-06-16T20:21:29Z","git_url":"git://github.com/twitter/scalding.git","ssh_url":"git@github.com:twitter/scalding.git","clone_url":"https://github.com/twitter/scalding.git","svn_url":"https://github.com/twitter/scalding","homepage":"http://twitter.com/scalding","size":21492,"stargazers_count":2135,"watchers_count":2135,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":476,"mirror_url":null,"open_issues_count":230,"forks":476,"open_issues":230,"watchers":2135,"default_branch":"develop"}},"base":{"label":"twitter:develop","ref":"develop","sha":"ae999e43d36bb875c4da259df46a7e8d4847b8a4","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":3146558,"name":"scalding","full_name":"twitter/scalding","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/scalding","description":"A Scala API for Cascading","fork":false,"url":"https://api.github.com/repos/twitter/scalding","forks_url":"https://api.github.com/repos/twitter/scalding/forks","keys_url":"https://api.github.com/repos/twitter/scalding/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/scalding/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/scalding/teams","hooks_url":"https://api.github.com/repos/twitter/scalding/hooks","issue_events_url":"https://api.github.com/repos/twitter/scalding/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/scalding/events","assignees_url":"https://api.github.com/repos/twitter/scalding/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/scalding/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/scalding/tags","blobs_url":"https://api.github.com/repos/twitter/scalding/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/scalding/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/scalding/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/scalding/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/scalding/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/scalding/languages","stargazers_url":"https://api.github.com/repos/twitter/scalding/stargazers","contributors_url":"https://api.github.com/repos/twitter/scalding/contributors","subscribers_url":"https://api.github.com/repos/twitter/scalding/subscribers","subscription_url":"https://api.github.com/repos/twitter/scalding/subscription","commits_url":"https://api.github.com/repos/twitter/scalding/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/scalding/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/scalding/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/scalding/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/scalding/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/scalding/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/scalding/merges","archive_url":"https://api.github.com/repos/twitter/scalding/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/scalding/downloads","issues_url":"https://api.github.com/repos/twitter/scalding/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/scalding/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/scalding/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/scalding/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/scalding/labels{/name}","releases_url":"https://api.github.com/repos/twitter/scalding/releases{/id}","created_at":"2012-01-10T16:22:08Z","updated_at":"2015-06-16T06:04:21Z","pushed_at":"2015-06-16T20:21:29Z","git_url":"git://github.com/twitter/scalding.git","ssh_url":"git@github.com:twitter/scalding.git","clone_url":"https://github.com/twitter/scalding.git","svn_url":"https://github.com/twitter/scalding","homepage":"http://twitter.com/scalding","size":21492,"stargazers_count":2135,"watchers_count":2135,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":476,"mirror_url":null,"open_issues_count":230,"forks":476,"open_issues":230,"watchers":2135,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/scalding/pulls/1320"},"html":{"href":"https://github.com/twitter/scalding/pull/1320"},"issue":{"href":"https://api.github.com/repos/twitter/scalding/issues/1320"},"comments":{"href":"https://api.github.com/repos/twitter/scalding/issues/1320/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/scalding/pulls/1320/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/scalding/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/scalding/pulls/1320/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/scalding/statuses/14af24de4cf6c523e89b1326628d1f540b1a3246"}}}}