{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/rocksdb/pulls/comments/202127225","pull_request_review_id":136758347,"id":202127225,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjEyNzIyNQ==","diff_hunk":"@@ -463,12 +487,77 @@ BlockIter* Block::NewIterator(const Comparator* cmp, const Comparator* ucmp,\n     ret_iter->Invalidate(Status::OK());\n     return ret_iter;\n   } else {\n+    const bool kKeyIncludesSeq = true;\n+    ret_iter->InitializeBase(cmp, ucmp, data_, restart_offset_, num_restarts_,\n+                             global_seqno_, kKeyIncludesSeq, cachable());\n+  }\n+\n+  return ret_iter;\n+}\n+\n+BlockIter* Block::NewIndexOrDataIterator(\n+    const bool is_index, const Comparator* cmp, const Comparator* ucmp,\n+    BlockIter* iter, Statistics* stats, bool total_order_seek,\n+    bool key_includes_seq, BlockPrefixIndex* prefix_index) {\n+  BlockIter* ret_iter;\n+  if (iter != nullptr) {\n+    ret_iter = iter;\n+  } else {\n+    if (is_index) {\n+      ret_iter = new IndexBlockIter;\n+    } else {\n+      ret_iter = new DataBlockIter;\n+    }\n+  }\n+  if (size_ < 2 * sizeof(uint32_t)) {\n+    ret_iter->Invalidate(Status::Corruption(\"bad block contents\"));\n+    return ret_iter;\n+  }\n+  if (num_restarts_ == 0) {\n+    // Empty block.\n+    ret_iter->Invalidate(Status::OK());\n+    return ret_iter;\n+  } else if (is_index) {\n     BlockPrefixIndex* prefix_index_ptr =\n-        total_order_seek ? nullptr : prefix_index_.get();\n-    ret_iter->Initialize(cmp, ucmp, data_, restart_offset_, num_restarts_,\n-                         prefix_index_ptr, global_seqno_,\n-                         read_amp_bitmap_.get(), key_includes_seq, cachable());\n+        total_order_seek ? nullptr : prefix_index;\n+    reinterpret_cast<IndexBlockIter*>(ret_iter)->Initialize(\n+        cmp, ucmp, data_, restart_offset_, num_restarts_, prefix_index_ptr,\n+        key_includes_seq, cachable());","path":"table/block.cc","position":116,"original_position":116,"commit_id":"9c4b31543c035a27a257c5f8ba658c58436605c6","original_commit_id":"9c4b31543c035a27a257c5f8ba658c58436605c6","user":{"login":"siying","id":5334567,"node_id":"MDQ6VXNlcjUzMzQ1Njc=","avatar_url":"https://avatars3.githubusercontent.com/u/5334567?v=4","gravatar_id":"","url":"https://api.github.com/users/siying","html_url":"https://github.com/siying","followers_url":"https://api.github.com/users/siying/followers","following_url":"https://api.github.com/users/siying/following{/other_user}","gists_url":"https://api.github.com/users/siying/gists{/gist_id}","starred_url":"https://api.github.com/users/siying/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siying/subscriptions","organizations_url":"https://api.github.com/users/siying/orgs","repos_url":"https://api.github.com/users/siying/repos","events_url":"https://api.github.com/users/siying/events{/privacy}","received_events_url":"https://api.github.com/users/siying/received_events","type":"User","site_admin":false},"body":"These casting is not ideal. I want to understand more about why we need them at all. Can we divide to two separate Block::NewIndexIterator() and Block::NewDataIterator()?","created_at":"2018-07-12T18:02:24Z","updated_at":"2018-07-12T18:02:31Z","html_url":"https://github.com/facebook/rocksdb/pull/4121#discussion_r202127225","pull_request_url":"https://api.github.com/repos/facebook/rocksdb/pulls/4121","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/comments/202127225"},"html":{"href":"https://github.com/facebook/rocksdb/pull/4121#discussion_r202127225"},"pull_request":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4121"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/rocksdb/pulls/4121","id":200872220,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwODcyMjIw","html_url":"https://github.com/facebook/rocksdb/pull/4121","diff_url":"https://github.com/facebook/rocksdb/pull/4121.diff","patch_url":"https://github.com/facebook/rocksdb/pull/4121.patch","issue_url":"https://api.github.com/repos/facebook/rocksdb/issues/4121","number":4121,"state":"open","locked":false,"title":"Refactor BlockIter","user":{"login":"maysamyabandeh","id":1167741,"node_id":"MDQ6VXNlcjExNjc3NDE=","avatar_url":"https://avatars2.githubusercontent.com/u/1167741?v=4","gravatar_id":"","url":"https://api.github.com/users/maysamyabandeh","html_url":"https://github.com/maysamyabandeh","followers_url":"https://api.github.com/users/maysamyabandeh/followers","following_url":"https://api.github.com/users/maysamyabandeh/following{/other_user}","gists_url":"https://api.github.com/users/maysamyabandeh/gists{/gist_id}","starred_url":"https://api.github.com/users/maysamyabandeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maysamyabandeh/subscriptions","organizations_url":"https://api.github.com/users/maysamyabandeh/orgs","repos_url":"https://api.github.com/users/maysamyabandeh/repos","events_url":"https://api.github.com/users/maysamyabandeh/events{/privacy}","received_events_url":"https://api.github.com/users/maysamyabandeh/received_events","type":"User","site_admin":false},"body":"BlockIter is getting crowded including details that specific only to either index or data blocks. The patch moves down such details to DataBlockIter and IndexBlockIter, both inheriting from BlockIter.","created_at":"2018-07-12T02:25:04Z","updated_at":"2018-07-12T18:02:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fbd55971a2db29a4b9074b27df08ae67ca2a5ca7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":196859108,"node_id":"MDU6TGFiZWwxOTY4NTkxMDg=","url":"https://api.github.com/repos/facebook/rocksdb/labels/CLA%20Signed","name":"CLA Signed","color":"009900","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/rocksdb/pulls/4121/commits","review_comments_url":"https://api.github.com/repos/facebook/rocksdb/pulls/4121/comments","review_comment_url":"https://api.github.com/repos/facebook/rocksdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/rocksdb/issues/4121/comments","statuses_url":"https://api.github.com/repos/facebook/rocksdb/statuses/9c4b31543c035a27a257c5f8ba658c58436605c6","head":{"label":"maysamyabandeh:refactorblockiter","ref":"refactorblockiter","sha":"9c4b31543c035a27a257c5f8ba658c58436605c6","user":{"login":"maysamyabandeh","id":1167741,"node_id":"MDQ6VXNlcjExNjc3NDE=","avatar_url":"https://avatars2.githubusercontent.com/u/1167741?v=4","gravatar_id":"","url":"https://api.github.com/users/maysamyabandeh","html_url":"https://github.com/maysamyabandeh","followers_url":"https://api.github.com/users/maysamyabandeh/followers","following_url":"https://api.github.com/users/maysamyabandeh/following{/other_user}","gists_url":"https://api.github.com/users/maysamyabandeh/gists{/gist_id}","starred_url":"https://api.github.com/users/maysamyabandeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maysamyabandeh/subscriptions","organizations_url":"https://api.github.com/users/maysamyabandeh/orgs","repos_url":"https://api.github.com/users/maysamyabandeh/repos","events_url":"https://api.github.com/users/maysamyabandeh/events{/privacy}","received_events_url":"https://api.github.com/users/maysamyabandeh/received_events","type":"User","site_admin":false},"repo":{"id":73221890,"node_id":"MDEwOlJlcG9zaXRvcnk3MzIyMTg5MA==","name":"rocksdb","full_name":"maysamyabandeh/rocksdb","owner":{"login":"maysamyabandeh","id":1167741,"node_id":"MDQ6VXNlcjExNjc3NDE=","avatar_url":"https://avatars2.githubusercontent.com/u/1167741?v=4","gravatar_id":"","url":"https://api.github.com/users/maysamyabandeh","html_url":"https://github.com/maysamyabandeh","followers_url":"https://api.github.com/users/maysamyabandeh/followers","following_url":"https://api.github.com/users/maysamyabandeh/following{/other_user}","gists_url":"https://api.github.com/users/maysamyabandeh/gists{/gist_id}","starred_url":"https://api.github.com/users/maysamyabandeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maysamyabandeh/subscriptions","organizations_url":"https://api.github.com/users/maysamyabandeh/orgs","repos_url":"https://api.github.com/users/maysamyabandeh/repos","events_url":"https://api.github.com/users/maysamyabandeh/events{/privacy}","received_events_url":"https://api.github.com/users/maysamyabandeh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maysamyabandeh/rocksdb","description":"A library that provides an embeddable, persistent key-value store for fast storage.","fork":true,"url":"https://api.github.com/repos/maysamyabandeh/rocksdb","forks_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/forks","keys_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/teams","hooks_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/hooks","issue_events_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/issues/events{/number}","events_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/events","assignees_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/assignees{/user}","branches_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/branches{/branch}","tags_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/tags","blobs_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/statuses/{sha}","languages_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/languages","stargazers_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/stargazers","contributors_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/contributors","subscribers_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/subscribers","subscription_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/subscription","commits_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/contents/{+path}","compare_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/merges","archive_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/downloads","issues_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/issues{/number}","pulls_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/pulls{/number}","milestones_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/milestones{/number}","notifications_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/labels{/name}","releases_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/releases{/id}","deployments_url":"https://api.github.com/repos/maysamyabandeh/rocksdb/deployments","created_at":"2016-11-08T19:56:13Z","updated_at":"2016-11-08T19:56:19Z","pushed_at":"2018-07-12T16:10:50Z","git_url":"git://github.com/maysamyabandeh/rocksdb.git","ssh_url":"git@github.com:maysamyabandeh/rocksdb.git","clone_url":"https://github.com/maysamyabandeh/rocksdb.git","svn_url":"https://github.com/maysamyabandeh/rocksdb","homepage":"http://rocksdb.org","size":114324,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"35b38a232c1d357a7a885b9b4b8442e24a8433d7","user":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":6934395,"node_id":"MDEwOlJlcG9zaXRvcnk2OTM0Mzk1","name":"rocksdb","full_name":"facebook/rocksdb","owner":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/rocksdb","description":"A library that provides an embeddable, persistent key-value store for fast storage.","fork":false,"url":"https://api.github.com/repos/facebook/rocksdb","forks_url":"https://api.github.com/repos/facebook/rocksdb/forks","keys_url":"https://api.github.com/repos/facebook/rocksdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/rocksdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/rocksdb/teams","hooks_url":"https://api.github.com/repos/facebook/rocksdb/hooks","issue_events_url":"https://api.github.com/repos/facebook/rocksdb/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/rocksdb/events","assignees_url":"https://api.github.com/repos/facebook/rocksdb/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/rocksdb/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/rocksdb/tags","blobs_url":"https://api.github.com/repos/facebook/rocksdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/rocksdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/rocksdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/rocksdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/rocksdb/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/rocksdb/languages","stargazers_url":"https://api.github.com/repos/facebook/rocksdb/stargazers","contributors_url":"https://api.github.com/repos/facebook/rocksdb/contributors","subscribers_url":"https://api.github.com/repos/facebook/rocksdb/subscribers","subscription_url":"https://api.github.com/repos/facebook/rocksdb/subscription","commits_url":"https://api.github.com/repos/facebook/rocksdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/rocksdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/rocksdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/rocksdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/rocksdb/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/rocksdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/rocksdb/merges","archive_url":"https://api.github.com/repos/facebook/rocksdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/rocksdb/downloads","issues_url":"https://api.github.com/repos/facebook/rocksdb/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/rocksdb/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/rocksdb/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/rocksdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/rocksdb/labels{/name}","releases_url":"https://api.github.com/repos/facebook/rocksdb/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/rocksdb/deployments","created_at":"2012-11-30T06:16:18Z","updated_at":"2018-07-12T15:22:42Z","pushed_at":"2018-07-12T17:56:38Z","git_url":"git://github.com/facebook/rocksdb.git","ssh_url":"git@github.com:facebook/rocksdb.git","clone_url":"https://github.com/facebook/rocksdb.git","svn_url":"https://github.com/facebook/rocksdb","homepage":"http://rocksdb.org","size":115783,"stargazers_count":11016,"watchers_count":11016,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2414,"mirror_url":null,"archived":false,"open_issues_count":236,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2414,"open_issues":236,"watchers":11016,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4121"},"html":{"href":"https://github.com/facebook/rocksdb/pull/4121"},"issue":{"href":"https://api.github.com/repos/facebook/rocksdb/issues/4121"},"comments":{"href":"https://api.github.com/repos/facebook/rocksdb/issues/4121/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4121/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4121/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/rocksdb/statuses/9c4b31543c035a27a257c5f8ba658c58436605c6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"siying"}}