{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/ambry/pulls/comments/190037352","pull_request_review_id":122319370,"id":190037352,"diff_hunk":"@@ -584,36 +628,22 @@ void writeIndexSegmentToFile(Offset safeEndPoint) throws IOException, StoreExcep\n           writer.writeShort(resetKey.getSecond().ordinal());\n         }\n \n-        // NOTE: In the event of a crash, it is possible that there is a part of the log that is not covered by the\n-        // index. This happens due to the fact that a DELETE that occurs in the same segment as a PUT overwrites the\n-        // PUT entry. Consider the following case:-\n-        // (entries are of the form ID:TYPE:START_OFFSET-END_OFFSET)\n-        // This is the order of operations\n-        // A:PUT:0-100\n-        // B:PUT:101-200\n-        // A:DELETE:201-250\n-        // These are the entries in the index segment\n-        // A:DELETE:201-250\n-        // B:PUT:101-200\n-        // If safeEndPoint < 250, then B:PUT:101-200 will be written but not A:DELETE:201-250. If the process were to\n-        // crash at this point, the index end offset would be 200 and the span 0-100 would not be represented in the\n-        // index.\n-        // write the entries\n         byte[] maxPaddingBytes = null;\n         if (getVersion() == PersistentIndex.VERSION_2) {\n           maxPaddingBytes = new byte[persistedEntrySize - valueSize];\n         }\n-        for (Map.Entry<StoreKey, IndexValue> entry : index.entrySet()) {\n-          if (entry.getValue().getOffset().getOffset() + entry.getValue().getSize() <= safeEndPoint.getOffset()) {\n-            writer.write(entry.getKey().toBytes());\n-            writer.write(entry.getValue().getBytes().array());\n-            if (getVersion() == PersistentIndex.VERSION_2) {\n-              // Add padding if necessary\n-              writer.write(maxPaddingBytes, 0, persistedEntrySize - (entry.getKey().sizeInBytes() + valueSize));\n+        for (Map.Entry<StoreKey, NavigableSet<IndexValue>> entry : index.entrySet()) {","path":"ambry-store/src/main/java/com.github.ambry.store/IndexSegment.java","position":179,"original_position":179,"commit_id":"8b9ef5b15903eafa11e62322995a671aa59a4636","original_commit_id":"8b9ef5b15903eafa11e62322995a671aa59a4636","user":{"login":"pnarayanan","id":1454915,"avatar_url":"https://avatars2.githubusercontent.com/u/1454915?v=4","gravatar_id":"","url":"https://api.github.com/users/pnarayanan","html_url":"https://github.com/pnarayanan","followers_url":"https://api.github.com/users/pnarayanan/followers","following_url":"https://api.github.com/users/pnarayanan/following{/other_user}","gists_url":"https://api.github.com/users/pnarayanan/gists{/gist_id}","starred_url":"https://api.github.com/users/pnarayanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnarayanan/subscriptions","organizations_url":"https://api.github.com/users/pnarayanan/orgs","repos_url":"https://api.github.com/users/pnarayanan/repos","events_url":"https://api.github.com/users/pnarayanan/events{/privacy}","received_events_url":"https://api.github.com/users/pnarayanan/received_events","type":"User","site_admin":false},"body":"there should be a clever way of using java 8 streams here to flatten the map, which can perhaps simplify this code. For example, `index.entrySet().stream().flatMap(e -> e.getValue().stream())` flattens and creates a stream of all individual entries. @cgtz any ideas?","created_at":"2018-05-22T20:13:06Z","updated_at":"2018-05-22T20:13:12Z","html_url":"https://github.com/linkedin/ambry/pull/920#discussion_r190037352","pull_request_url":"https://api.github.com/repos/linkedin/ambry/pulls/920","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/linkedin/ambry/pulls/comments/190037352"},"html":{"href":"https://github.com/linkedin/ambry/pull/920#discussion_r190037352"},"pull_request":{"href":"https://api.github.com/repos/linkedin/ambry/pulls/920"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/ambry/pulls/920","id":187317147,"html_url":"https://github.com/linkedin/ambry/pull/920","diff_url":"https://github.com/linkedin/ambry/pull/920.diff","patch_url":"https://github.com/linkedin/ambry/pull/920.patch","issue_url":"https://api.github.com/repos/linkedin/ambry/issues/920","number":920,"state":"open","locked":false,"title":"Allowing for multiple values for the same key in IndexSegment","user":{"login":"vgkholla","id":288834,"avatar_url":"https://avatars2.githubusercontent.com/u/288834?v=4","gravatar_id":"","url":"https://api.github.com/users/vgkholla","html_url":"https://github.com/vgkholla","followers_url":"https://api.github.com/users/vgkholla/followers","following_url":"https://api.github.com/users/vgkholla/following{/other_user}","gists_url":"https://api.github.com/users/vgkholla/gists{/gist_id}","starred_url":"https://api.github.com/users/vgkholla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vgkholla/subscriptions","organizations_url":"https://api.github.com/users/vgkholla/orgs","repos_url":"https://api.github.com/users/vgkholla/repos","events_url":"https://api.github.com/users/vgkholla/events{/privacy}","received_events_url":"https://api.github.com/users/vgkholla/received_events","type":"User","site_admin":false},"body":"Currently, an IndexSegment can have only value for a particular key which means that delete entries squash put entries if they occur in the same index segment. This commit changes this behavior to allow the IndexSegment to have more than one value for a key","created_at":"2018-05-10T21:50:50Z","updated_at":"2018-05-22T20:13:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4b170669accff69d736f7aca8ff34b7448655b47","assignee":{"login":"vgkholla","id":288834,"avatar_url":"https://avatars2.githubusercontent.com/u/288834?v=4","gravatar_id":"","url":"https://api.github.com/users/vgkholla","html_url":"https://github.com/vgkholla","followers_url":"https://api.github.com/users/vgkholla/followers","following_url":"https://api.github.com/users/vgkholla/following{/other_user}","gists_url":"https://api.github.com/users/vgkholla/gists{/gist_id}","starred_url":"https://api.github.com/users/vgkholla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vgkholla/subscriptions","organizations_url":"https://api.github.com/users/vgkholla/orgs","repos_url":"https://api.github.com/users/vgkholla/repos","events_url":"https://api.github.com/users/vgkholla/events{/privacy}","received_events_url":"https://api.github.com/users/vgkholla/received_events","type":"User","site_admin":false},"assignees":[{"login":"vgkholla","id":288834,"avatar_url":"https://avatars2.githubusercontent.com/u/288834?v=4","gravatar_id":"","url":"https://api.github.com/users/vgkholla","html_url":"https://github.com/vgkholla","followers_url":"https://api.github.com/users/vgkholla/followers","following_url":"https://api.github.com/users/vgkholla/following{/other_user}","gists_url":"https://api.github.com/users/vgkholla/gists{/gist_id}","starred_url":"https://api.github.com/users/vgkholla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vgkholla/subscriptions","organizations_url":"https://api.github.com/users/vgkholla/orgs","repos_url":"https://api.github.com/users/vgkholla/repos","events_url":"https://api.github.com/users/vgkholla/events{/privacy}","received_events_url":"https://api.github.com/users/vgkholla/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":62686637,"url":"https://api.github.com/repos/linkedin/ambry/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/ambry/pulls/920/commits","review_comments_url":"https://api.github.com/repos/linkedin/ambry/pulls/920/comments","review_comment_url":"https://api.github.com/repos/linkedin/ambry/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/ambry/issues/920/comments","statuses_url":"https://api.github.com/repos/linkedin/ambry/statuses/8b9ef5b15903eafa11e62322995a671aa59a4636","head":{"label":"vgkholla:MultiValueIndexSegment","ref":"MultiValueIndexSegment","sha":"8b9ef5b15903eafa11e62322995a671aa59a4636","user":{"login":"vgkholla","id":288834,"avatar_url":"https://avatars2.githubusercontent.com/u/288834?v=4","gravatar_id":"","url":"https://api.github.com/users/vgkholla","html_url":"https://github.com/vgkholla","followers_url":"https://api.github.com/users/vgkholla/followers","following_url":"https://api.github.com/users/vgkholla/following{/other_user}","gists_url":"https://api.github.com/users/vgkholla/gists{/gist_id}","starred_url":"https://api.github.com/users/vgkholla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vgkholla/subscriptions","organizations_url":"https://api.github.com/users/vgkholla/orgs","repos_url":"https://api.github.com/users/vgkholla/repos","events_url":"https://api.github.com/users/vgkholla/events{/privacy}","received_events_url":"https://api.github.com/users/vgkholla/received_events","type":"User","site_admin":false},"repo":{"id":33381520,"name":"ambry","full_name":"vgkholla/ambry","owner":{"login":"vgkholla","id":288834,"avatar_url":"https://avatars2.githubusercontent.com/u/288834?v=4","gravatar_id":"","url":"https://api.github.com/users/vgkholla","html_url":"https://github.com/vgkholla","followers_url":"https://api.github.com/users/vgkholla/followers","following_url":"https://api.github.com/users/vgkholla/following{/other_user}","gists_url":"https://api.github.com/users/vgkholla/gists{/gist_id}","starred_url":"https://api.github.com/users/vgkholla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vgkholla/subscriptions","organizations_url":"https://api.github.com/users/vgkholla/orgs","repos_url":"https://api.github.com/users/vgkholla/repos","events_url":"https://api.github.com/users/vgkholla/events{/privacy}","received_events_url":"https://api.github.com/users/vgkholla/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vgkholla/ambry","description":"Immutable blob store","fork":true,"url":"https://api.github.com/repos/vgkholla/ambry","forks_url":"https://api.github.com/repos/vgkholla/ambry/forks","keys_url":"https://api.github.com/repos/vgkholla/ambry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vgkholla/ambry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vgkholla/ambry/teams","hooks_url":"https://api.github.com/repos/vgkholla/ambry/hooks","issue_events_url":"https://api.github.com/repos/vgkholla/ambry/issues/events{/number}","events_url":"https://api.github.com/repos/vgkholla/ambry/events","assignees_url":"https://api.github.com/repos/vgkholla/ambry/assignees{/user}","branches_url":"https://api.github.com/repos/vgkholla/ambry/branches{/branch}","tags_url":"https://api.github.com/repos/vgkholla/ambry/tags","blobs_url":"https://api.github.com/repos/vgkholla/ambry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vgkholla/ambry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vgkholla/ambry/git/refs{/sha}","trees_url":"https://api.github.com/repos/vgkholla/ambry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vgkholla/ambry/statuses/{sha}","languages_url":"https://api.github.com/repos/vgkholla/ambry/languages","stargazers_url":"https://api.github.com/repos/vgkholla/ambry/stargazers","contributors_url":"https://api.github.com/repos/vgkholla/ambry/contributors","subscribers_url":"https://api.github.com/repos/vgkholla/ambry/subscribers","subscription_url":"https://api.github.com/repos/vgkholla/ambry/subscription","commits_url":"https://api.github.com/repos/vgkholla/ambry/commits{/sha}","git_commits_url":"https://api.github.com/repos/vgkholla/ambry/git/commits{/sha}","comments_url":"https://api.github.com/repos/vgkholla/ambry/comments{/number}","issue_comment_url":"https://api.github.com/repos/vgkholla/ambry/issues/comments{/number}","contents_url":"https://api.github.com/repos/vgkholla/ambry/contents/{+path}","compare_url":"https://api.github.com/repos/vgkholla/ambry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vgkholla/ambry/merges","archive_url":"https://api.github.com/repos/vgkholla/ambry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vgkholla/ambry/downloads","issues_url":"https://api.github.com/repos/vgkholla/ambry/issues{/number}","pulls_url":"https://api.github.com/repos/vgkholla/ambry/pulls{/number}","milestones_url":"https://api.github.com/repos/vgkholla/ambry/milestones{/number}","notifications_url":"https://api.github.com/repos/vgkholla/ambry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vgkholla/ambry/labels{/name}","releases_url":"https://api.github.com/repos/vgkholla/ambry/releases{/id}","deployments_url":"https://api.github.com/repos/vgkholla/ambry/deployments","created_at":"2015-04-03T20:29:52Z","updated_at":"2018-05-17T22:44:18Z","pushed_at":"2018-05-21T23:09:27Z","git_url":"git://github.com/vgkholla/ambry.git","ssh_url":"git@github.com:vgkholla/ambry.git","clone_url":"https://github.com/vgkholla/ambry.git","svn_url":"https://github.com/vgkholla/ambry","homepage":null,"size":13262,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"linkedin:master","ref":"master","sha":"fb0777e3c6f25a019f8303a98eb1dc6ce172aa24","user":{"login":"linkedin","id":357098,"avatar_url":"https://avatars3.githubusercontent.com/u/357098?v=4","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":13870893,"name":"ambry","full_name":"linkedin/ambry","owner":{"login":"linkedin","id":357098,"avatar_url":"https://avatars3.githubusercontent.com/u/357098?v=4","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linkedin/ambry","description":"Distributed object store","fork":false,"url":"https://api.github.com/repos/linkedin/ambry","forks_url":"https://api.github.com/repos/linkedin/ambry/forks","keys_url":"https://api.github.com/repos/linkedin/ambry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/ambry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/ambry/teams","hooks_url":"https://api.github.com/repos/linkedin/ambry/hooks","issue_events_url":"https://api.github.com/repos/linkedin/ambry/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/ambry/events","assignees_url":"https://api.github.com/repos/linkedin/ambry/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/ambry/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/ambry/tags","blobs_url":"https://api.github.com/repos/linkedin/ambry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/ambry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/ambry/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/ambry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/ambry/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/ambry/languages","stargazers_url":"https://api.github.com/repos/linkedin/ambry/stargazers","contributors_url":"https://api.github.com/repos/linkedin/ambry/contributors","subscribers_url":"https://api.github.com/repos/linkedin/ambry/subscribers","subscription_url":"https://api.github.com/repos/linkedin/ambry/subscription","commits_url":"https://api.github.com/repos/linkedin/ambry/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/ambry/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/ambry/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/ambry/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/ambry/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/ambry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/ambry/merges","archive_url":"https://api.github.com/repos/linkedin/ambry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/ambry/downloads","issues_url":"https://api.github.com/repos/linkedin/ambry/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/ambry/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/ambry/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/ambry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/ambry/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/ambry/releases{/id}","deployments_url":"https://api.github.com/repos/linkedin/ambry/deployments","created_at":"2013-10-25T20:04:54Z","updated_at":"2018-05-22T05:23:43Z","pushed_at":"2018-05-22T01:55:00Z","git_url":"git://github.com/linkedin/ambry.git","ssh_url":"git@github.com:linkedin/ambry.git","clone_url":"https://github.com/linkedin/ambry.git","svn_url":"https://github.com/linkedin/ambry","homepage":"https://github.com/linkedin/ambry/wiki","size":12461,"stargazers_count":1052,"watchers_count":1052,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":203,"mirror_url":null,"archived":false,"open_issues_count":96,"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":203,"open_issues":96,"watchers":1052,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/ambry/pulls/920"},"html":{"href":"https://github.com/linkedin/ambry/pull/920"},"issue":{"href":"https://api.github.com/repos/linkedin/ambry/issues/920"},"comments":{"href":"https://api.github.com/repos/linkedin/ambry/issues/920/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/ambry/pulls/920/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/ambry/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/ambry/pulls/920/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/ambry/statuses/8b9ef5b15903eafa11e62322995a671aa59a4636"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pnarayanan"}}