{"action":"created","comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/27494957","id":27494957,"diff_hunk":"@@ -353,20 +365,51 @@ func TestGoMerge(t *testing.T) {\n \t}\n \n \tfor i, c := range testCasesTimeSeries {\n+\t\texpectedTS := unmarshalTimeSeries(t, c.expected)\n+\t\texistingTS := unmarshalTimeSeries(t, c.existing)\n+\t\tupdateTS := unmarshalTimeSeries(t, c.update)\n+\n+\t\t// Test the C++ implementation of merging first using goMerge.  goMerge\n+\t\t// operates directly only marshalled bytes.\n \t\tresult, err := goMerge(c.existing, c.update)\n \t\tif err != nil {\n-\t\t\tt.Errorf(\"goMerge error: %d: %v\", i, err)\n+\t\t\tt.Errorf(\"goMerge error on case %d: %s\", i, err.Error())\n \t\t\tcontinue\n \t\t}\n+\t\tresultTS := unmarshalTimeSeries(t, result)\n+\t\tif a, e := resultTS, expectedTS; !reflect.DeepEqual(a, e) {\n+\t\t\tt.Errorf(\"goMerge returned wrong result on case %d: expected %v, returned %v\", i, e, a)\n+\t\t}\n \n-\t\t// Extract the time series and compare.\n-\t\tvar resultV, expectedV proto.MVCCMetadata\n-\t\tgogoproto.Unmarshal(result, &resultV)\n-\t\tgogoproto.Unmarshal(c.expected, &expectedV)\n-\t\tresultTS, _ := proto.InternalTimeSeriesDataFromValue(resultV.Value)\n-\t\texpectedTS, _ := proto.InternalTimeSeriesDataFromValue(expectedV.Value)\n-\t\tif !reflect.DeepEqual(resultTS, expectedTS) {\n-\t\t\tt.Errorf(\"goMerge error: %d: want %v, got %v\", i, expectedTS, resultTS)\n+\t\t// Test the Go implementation of merging.\n+\t\tif existingTS == nil {\n+\t\t\tresultTS, err = proto.MergeInternalTimeSeriesData(updateTS)\n+\t\t} else {\n+\t\t\tresultTS, err = proto.MergeInternalTimeSeriesData(existingTS, updateTS)\n+\t\t}\n+\t\tif err != nil {\n+\t\t\tt.Errorf(\"MergeInternalTimeSeriesData error on case %d: %s\", i, err.Error())\n+\t\t\tcontinue\n \t\t}\n+\t\tif a, e := resultTS, expectedTS; !reflect.DeepEqual(a, e) {\n+\t\t\tt.Errorf(\"MergeInternalTimeSeriesData returned wrong result on case %d: expected %v, returned %v\",\n+\t\t\t\ti, e, a)\n+\t\t}\n+\t}\n+}\n+\n+// unmarshalTimeSeries unmarshals the time series value stored in the given byte\n+// array. It is assumed that the time series value was originally marshalled as\n+// a proto.MVCCMetadata with an inline value.\n+func unmarshalTimeSeries(t testing.TB, b []byte) *proto.InternalTimeSeriesData {\n+\tif b == nil {\n+\t\treturn nil\n+\t}\n+\tvar mvccValue proto.MVCCMetadata\n+\tgogoproto.Unmarshal(b, &mvccValue)","path":"storage/engine/merge_test.go","position":73,"original_position":73,"commit_id":"14c42b1d72515f7d8df565abec75426a0219de95","original_commit_id":"14c42b1d72515f7d8df565abec75426a0219de95","user":{"login":"mrtracy","id":6969858,"avatar_url":"https://avatars.githubusercontent.com/u/6969858?v=3","gravatar_id":"","url":"https://api.github.com/users/mrtracy","html_url":"https://github.com/mrtracy","followers_url":"https://api.github.com/users/mrtracy/followers","following_url":"https://api.github.com/users/mrtracy/following{/other_user}","gists_url":"https://api.github.com/users/mrtracy/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtracy/subscriptions","organizations_url":"https://api.github.com/users/mrtracy/orgs","repos_url":"https://api.github.com/users/mrtracy/repos","events_url":"https://api.github.com/users/mrtracy/events{/privacy}","received_events_url":"https://api.github.com/users/mrtracy/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2015-03-31T16:16:54Z","updated_at":"2015-03-31T16:16:54Z","html_url":"https://github.com/cockroachdb/cockroach/pull/518#discussion_r27494957","pull_request_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518","_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/27494957"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/518#discussion_r27494957"},"pull_request":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518"}}},"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518","id":32272766,"html_url":"https://github.com/cockroachdb/cockroach/pull/518","diff_url":"https://github.com/cockroachdb/cockroach/pull/518.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/518.patch","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/518","number":518,"state":"open","locked":false,"title":"Golang implementation of Time Series Merge","user":{"login":"mrtracy","id":6969858,"avatar_url":"https://avatars.githubusercontent.com/u/6969858?v=3","gravatar_id":"","url":"https://api.github.com/users/mrtracy","html_url":"https://github.com/mrtracy","followers_url":"https://api.github.com/users/mrtracy/followers","following_url":"https://api.github.com/users/mrtracy/following{/other_user}","gists_url":"https://api.github.com/users/mrtracy/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtracy/subscriptions","organizations_url":"https://api.github.com/users/mrtracy/orgs","repos_url":"https://api.github.com/users/mrtracy/repos","events_url":"https://api.github.com/users/mrtracy/events{/privacy}","received_events_url":"https://api.github.com/users/mrtracy/received_events","type":"User","site_admin":false},"body":"This commit creates a Golang implementation of the logic to merge\r\nInternalTimeSeriesData messages together; this has also been implemented in C++\r\nas part of our RocksDB custom merge operator.\r\n\r\nThe Go implementation is primarily intended for testing purposes - it provides\r\nthe ability to double-check the logic present in the C++ engine as part of high\r\nlevel, model based testing which is currently in development. The Golang\r\nimplementation is run through the exact same merge tests as the engine\r\nimplementation.\r\n\r\nAs part of this commit, I have also repaired a bug in the C++ engine merge logic\r\n; previously, it was not properly sorting and accumulating the samples from the\r\nfirst merge operation on a given key, instead just accepting the collection\r\nexactly as it was provided.","created_at":"2015-03-30T22:09:38Z","updated_at":"2015-03-31T16:16:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"07cf369f503ed89e8de813755d41935f42633f3d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/518/comments","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/14c42b1d72515f7d8df565abec75426a0219de95","head":{"label":"cockroachdb:mtracy/ts_go_side_merge","ref":"mtracy/ts_go_side_merge","sha":"14c42b1d72515f7d8df565abec75426a0219de95","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"name":"cockroach","full_name":"cockroachdb/cockroach","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","created_at":"2014-02-06T00:18:47Z","updated_at":"2015-03-31T16:02:39Z","pushed_at":"2015-03-31T16:15:55Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":null,"size":18446,"stargazers_count":3229,"watchers_count":3229,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":236,"mirror_url":null,"open_issues_count":40,"forks":236,"open_issues":40,"watchers":3229,"default_branch":"master"}},"base":{"label":"cockroachdb:master","ref":"master","sha":"c052f446a7e3024d6b3c2b488f6cf8adbf8cf52b","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"name":"cockroach","full_name":"cockroachdb/cockroach","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","created_at":"2014-02-06T00:18:47Z","updated_at":"2015-03-31T16:02:39Z","pushed_at":"2015-03-31T16:15:55Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":null,"size":18446,"stargazers_count":3229,"watchers_count":3229,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":236,"mirror_url":null,"open_issues_count":40,"forks":236,"open_issues":40,"watchers":3229,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/518"},"issue":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/518"},"comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/518/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/518/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/cockroach/statuses/14c42b1d72515f7d8df565abec75426a0219de95"}}}}