{"action":"created","comment":{"url":"https://api.github.com/repos/slamdata/slamengine/pulls/comments/26914579","id":26914579,"diff_hunk":"@@ -1138,18 +1138,20 @@ class WorkflowSpec extends Specification with TreeMatchers {\n                     Js.Call(\n                       Js.AnonFunDecl(List(\"key\", \"value\"), List(\n                         Js.VarDef(List(\"rez\" -> Js.AnonElem(Nil))),\n-                        Js.ForIn(Js.Ident(\"elem1\"), JsCore.Select(Ident(\"value\").fix, \"baz\").fix.toJs,\n-                          Js.ForIn(Js.Ident(\"elem0\"), JsCore.Select(Ident(\"value\").fix, \"bar\").fix.toJs,\n-                            Js.Block(List(\n-                              Js.VarDef(List(\"each\" -> Js.Call(Js.Ident(\"clone\"), List(Js.Ident(\"value\"))))),\n-                              JsCore.safeAssign(Select(Ident(\"each\").fix, \"bar\").fix, Access(Select(Ident(\"value\").fix, \"bar\").fix, Ident(\"elem0\").fix).fix),\n-                              JsCore.safeAssign(Select(Ident(\"each\").fix, \"baz\").fix, Access(Select(Ident(\"value\").fix, \"baz\").fix, Ident(\"elem1\").fix).fix),\n-                              JsCore.Call(JsCore.Select(Ident(\"rez\").fix, \"push\").fix, List(\n-                                Arr(List(\n-                                  Call(Ident(\"ObjectId\").fix, List[Term[JsCore]]()).fix,\n-                                  Obj(ListMap(\n-                                    \"0\" -> Select(Ident(\"each\").fix, \"bar\").fix,\n-                                    \"1\" -> Select(Ident(\"each\").fix, \"baz\").fix)).fix)).fix)).fix.toJs)))),\n+                        Js.ForIn(Js.Ident(\"elem\"), JsCore.Select(Ident(\"value\").fix, \"bar\").fix.toJs,\n+                          Js.Block(List(\n+                            Js.VarDef(List(\"each0\" -> Js.Call(Js.Ident(\"clone\"), List(Js.Ident(\"value\"))))),\n+                            JsCore.safeAssign(Select(Ident(\"each0\").fix, \"bar\").fix, Access(Select(Ident(\"value\").fix, \"bar\").fix, Ident(\"elem\").fix).fix),\n+                            Js.ForIn(Js.Ident(\"elem\"), JsCore.Select(Ident(\"each0\").fix, \"baz\").fix.toJs,","path":"core/src/test/scala/slamdata/engine/physical/mongodb/workflowop.scala","position":87,"original_position":87,"commit_id":"4530fc8084b5d59a2ef664a3f29b2411706d1f05","original_commit_id":"4530fc8084b5d59a2ef664a3f29b2411706d1f05","user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"body":"I like the way you had written it, and I was thinking that it would be good to get that back in the future as a performance optimization when possible, but the important difference is how we handle stacked flattens (`parents[*]{*}`). which end up in the `$SimpleMap` `flatten` field as `[_.parents, _.parents]`.\r\n\r\nThe previous way walked over each expr in `flatten` and copied it from `value` to `each`, so in the `[*]{*}` case, it copied the entire parents object at each index twice, rather than the first flatten copying the object and the second copying a field from that object. In the `[*]{*}` case, the outer clone isn’t unnecessary – we need to hold the object that we later pull the fields from.\r\n\r\nIt would be nice to check the flattens, see which (if any) exprs overlap, and minimize the clones, pushing most of the flattens to the innermost loop (or pushing everything into the inner loop, but rewriting stacked expressions as necessary). But … these are arbitrary `JsMacro`s, so it’s not something I was about to dive into until we determine that flattening is a real problem for us.\r\n\r\nI had actually not shadowed elem initially, but the scala code looked slightly nicer when I did – I’m happy to go back and change that, though.","created_at":"2015-03-23T05:11:03Z","updated_at":"2015-03-23T05:11:03Z","html_url":"https://github.com/slamdata/slamengine/pull/666#discussion_r26914579","pull_request_url":"https://api.github.com/repos/slamdata/slamengine/pulls/666","_links":{"self":{"href":"https://api.github.com/repos/slamdata/slamengine/pulls/comments/26914579"},"html":{"href":"https://github.com/slamdata/slamengine/pull/666#discussion_r26914579"},"pull_request":{"href":"https://api.github.com/repos/slamdata/slamengine/pulls/666"}}},"pull_request":{"url":"https://api.github.com/repos/slamdata/slamengine/pulls/666","id":31677676,"html_url":"https://github.com/slamdata/slamengine/pull/666","diff_url":"https://github.com/slamdata/slamengine/pull/666.diff","patch_url":"https://github.com/slamdata/slamengine/pull/666.patch","issue_url":"https://api.github.com/repos/slamdata/slamengine/issues/666","number":666,"state":"open","locked":false,"title":"Convert SimpleMap flattens in a way that allows for stacked flattening.","user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"body":"Fixes #635.","created_at":"2015-03-21T20:33:18Z","updated_at":"2015-03-23T05:11:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4527f81a80814d36b31c10a813e1d172ca4fc9f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/slamdata/slamengine/pulls/666/commits","review_comments_url":"https://api.github.com/repos/slamdata/slamengine/pulls/666/comments","review_comment_url":"https://api.github.com/repos/slamdata/slamengine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/slamdata/slamengine/issues/666/comments","statuses_url":"https://api.github.com/repos/slamdata/slamengine/statuses/4530fc8084b5d59a2ef664a3f29b2411706d1f05","head":{"label":"sellout:ready/635-flatten-flatten","ref":"ready/635-flatten-flatten","sha":"4530fc8084b5d59a2ef664a3f29b2411706d1f05","user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"repo":{"id":21178230,"name":"slamengine","full_name":"sellout/slamengine","owner":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sellout/slamengine","description":"The engine for SlamData","fork":true,"url":"https://api.github.com/repos/sellout/slamengine","forks_url":"https://api.github.com/repos/sellout/slamengine/forks","keys_url":"https://api.github.com/repos/sellout/slamengine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sellout/slamengine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sellout/slamengine/teams","hooks_url":"https://api.github.com/repos/sellout/slamengine/hooks","issue_events_url":"https://api.github.com/repos/sellout/slamengine/issues/events{/number}","events_url":"https://api.github.com/repos/sellout/slamengine/events","assignees_url":"https://api.github.com/repos/sellout/slamengine/assignees{/user}","branches_url":"https://api.github.com/repos/sellout/slamengine/branches{/branch}","tags_url":"https://api.github.com/repos/sellout/slamengine/tags","blobs_url":"https://api.github.com/repos/sellout/slamengine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sellout/slamengine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sellout/slamengine/git/refs{/sha}","trees_url":"https://api.github.com/repos/sellout/slamengine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sellout/slamengine/statuses/{sha}","languages_url":"https://api.github.com/repos/sellout/slamengine/languages","stargazers_url":"https://api.github.com/repos/sellout/slamengine/stargazers","contributors_url":"https://api.github.com/repos/sellout/slamengine/contributors","subscribers_url":"https://api.github.com/repos/sellout/slamengine/subscribers","subscription_url":"https://api.github.com/repos/sellout/slamengine/subscription","commits_url":"https://api.github.com/repos/sellout/slamengine/commits{/sha}","git_commits_url":"https://api.github.com/repos/sellout/slamengine/git/commits{/sha}","comments_url":"https://api.github.com/repos/sellout/slamengine/comments{/number}","issue_comment_url":"https://api.github.com/repos/sellout/slamengine/issues/comments{/number}","contents_url":"https://api.github.com/repos/sellout/slamengine/contents/{+path}","compare_url":"https://api.github.com/repos/sellout/slamengine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sellout/slamengine/merges","archive_url":"https://api.github.com/repos/sellout/slamengine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sellout/slamengine/downloads","issues_url":"https://api.github.com/repos/sellout/slamengine/issues{/number}","pulls_url":"https://api.github.com/repos/sellout/slamengine/pulls{/number}","milestones_url":"https://api.github.com/repos/sellout/slamengine/milestones{/number}","notifications_url":"https://api.github.com/repos/sellout/slamengine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sellout/slamengine/labels{/name}","releases_url":"https://api.github.com/repos/sellout/slamengine/releases{/id}","created_at":"2014-06-24T19:38:07Z","updated_at":"2014-09-08T15:39:05Z","pushed_at":"2015-03-21T20:32:58Z","git_url":"git://github.com/sellout/slamengine.git","ssh_url":"git@github.com:sellout/slamengine.git","clone_url":"https://github.com/sellout/slamengine.git","svn_url":"https://github.com/sellout/slamengine","homepage":null,"size":5663,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"CHECK-UPSTREAM-REPO"}},"base":{"label":"slamdata:master","ref":"master","sha":"b6be469b391ccba6b542b70edcc5b36aec4af684","user":{"login":"slamdata","id":5385602,"avatar_url":"https://avatars.githubusercontent.com/u/5385602?v=3","gravatar_id":"","url":"https://api.github.com/users/slamdata","html_url":"https://github.com/slamdata","followers_url":"https://api.github.com/users/slamdata/followers","following_url":"https://api.github.com/users/slamdata/following{/other_user}","gists_url":"https://api.github.com/users/slamdata/gists{/gist_id}","starred_url":"https://api.github.com/users/slamdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slamdata/subscriptions","organizations_url":"https://api.github.com/users/slamdata/orgs","repos_url":"https://api.github.com/users/slamdata/repos","events_url":"https://api.github.com/users/slamdata/events{/privacy}","received_events_url":"https://api.github.com/users/slamdata/received_events","type":"Organization","site_admin":false},"repo":{"id":16515058,"name":"slamengine","full_name":"slamdata/slamengine","owner":{"login":"slamdata","id":5385602,"avatar_url":"https://avatars.githubusercontent.com/u/5385602?v=3","gravatar_id":"","url":"https://api.github.com/users/slamdata","html_url":"https://github.com/slamdata","followers_url":"https://api.github.com/users/slamdata/followers","following_url":"https://api.github.com/users/slamdata/following{/other_user}","gists_url":"https://api.github.com/users/slamdata/gists{/gist_id}","starred_url":"https://api.github.com/users/slamdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slamdata/subscriptions","organizations_url":"https://api.github.com/users/slamdata/orgs","repos_url":"https://api.github.com/users/slamdata/repos","events_url":"https://api.github.com/users/slamdata/events{/privacy}","received_events_url":"https://api.github.com/users/slamdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/slamdata/slamengine","description":"The engine for SlamData","fork":false,"url":"https://api.github.com/repos/slamdata/slamengine","forks_url":"https://api.github.com/repos/slamdata/slamengine/forks","keys_url":"https://api.github.com/repos/slamdata/slamengine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slamdata/slamengine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slamdata/slamengine/teams","hooks_url":"https://api.github.com/repos/slamdata/slamengine/hooks","issue_events_url":"https://api.github.com/repos/slamdata/slamengine/issues/events{/number}","events_url":"https://api.github.com/repos/slamdata/slamengine/events","assignees_url":"https://api.github.com/repos/slamdata/slamengine/assignees{/user}","branches_url":"https://api.github.com/repos/slamdata/slamengine/branches{/branch}","tags_url":"https://api.github.com/repos/slamdata/slamengine/tags","blobs_url":"https://api.github.com/repos/slamdata/slamengine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slamdata/slamengine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slamdata/slamengine/git/refs{/sha}","trees_url":"https://api.github.com/repos/slamdata/slamengine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slamdata/slamengine/statuses/{sha}","languages_url":"https://api.github.com/repos/slamdata/slamengine/languages","stargazers_url":"https://api.github.com/repos/slamdata/slamengine/stargazers","contributors_url":"https://api.github.com/repos/slamdata/slamengine/contributors","subscribers_url":"https://api.github.com/repos/slamdata/slamengine/subscribers","subscription_url":"https://api.github.com/repos/slamdata/slamengine/subscription","commits_url":"https://api.github.com/repos/slamdata/slamengine/commits{/sha}","git_commits_url":"https://api.github.com/repos/slamdata/slamengine/git/commits{/sha}","comments_url":"https://api.github.com/repos/slamdata/slamengine/comments{/number}","issue_comment_url":"https://api.github.com/repos/slamdata/slamengine/issues/comments{/number}","contents_url":"https://api.github.com/repos/slamdata/slamengine/contents/{+path}","compare_url":"https://api.github.com/repos/slamdata/slamengine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slamdata/slamengine/merges","archive_url":"https://api.github.com/repos/slamdata/slamengine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slamdata/slamengine/downloads","issues_url":"https://api.github.com/repos/slamdata/slamengine/issues{/number}","pulls_url":"https://api.github.com/repos/slamdata/slamengine/pulls{/number}","milestones_url":"https://api.github.com/repos/slamdata/slamengine/milestones{/number}","notifications_url":"https://api.github.com/repos/slamdata/slamengine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slamdata/slamengine/labels{/name}","releases_url":"https://api.github.com/repos/slamdata/slamengine/releases{/id}","created_at":"2014-02-04T15:01:27Z","updated_at":"2015-03-21T19:34:10Z","pushed_at":"2015-03-21T20:33:19Z","git_url":"git://github.com/slamdata/slamengine.git","ssh_url":"git@github.com:slamdata/slamengine.git","clone_url":"https://github.com/slamdata/slamengine.git","svn_url":"https://github.com/slamdata/slamengine","homepage":null,"size":8313,"stargazers_count":100,"watchers_count":100,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":128,"forks":23,"open_issues":128,"watchers":100,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/slamdata/slamengine/pulls/666"},"html":{"href":"https://github.com/slamdata/slamengine/pull/666"},"issue":{"href":"https://api.github.com/repos/slamdata/slamengine/issues/666"},"comments":{"href":"https://api.github.com/repos/slamdata/slamengine/issues/666/comments"},"review_comments":{"href":"https://api.github.com/repos/slamdata/slamengine/pulls/666/comments"},"review_comment":{"href":"https://api.github.com/repos/slamdata/slamengine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/slamdata/slamengine/pulls/666/commits"},"statuses":{"href":"https://api.github.com/repos/slamdata/slamengine/statuses/4530fc8084b5d59a2ef664a3f29b2411706d1f05"}}}}