{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/comments/157410832","pull_request_review_id":84046210,"id":157410832,"diff_hunk":"@@ -0,0 +1,51 @@\n+/*\n+ * Copyright 2017 PingCAP, 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+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.pingcap.tikv.tools;\n+\n+\n+import static java.util.Objects.requireNonNull;\n+\n+import com.google.common.collect.ImmutableList;\n+import com.pingcap.tikv.TiSession;\n+import com.pingcap.tikv.meta.TiTableInfo;\n+import com.pingcap.tikv.predicates.ScanBuilder;\n+import com.pingcap.tikv.predicates.ScanBuilder.ScanPlan;\n+import com.pingcap.tikv.util.RangeSplitter;\n+import com.pingcap.tikv.util.RangeSplitter.RegionTask;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+\n+public class RegionUtils {\n+  static public Map<String, Integer>\n+  getRegionDistribution(TiSession session, String databaseName, String tableName) {\n+    requireNonNull(session, \"session is null\");\n+    requireNonNull(databaseName, \"databaseName is null\");\n+    requireNonNull(tableName, \"tableName is null\");\n+    TiTableInfo table = session.getCatalog().getTable(databaseName, tableName);\n+    requireNonNull(table, String.format(\"Table not find %s.%s\", databaseName, tableName));\n+    ScanBuilder builder = new ScanBuilder();\n+    ScanPlan scanPlan = builder.buildScan(ImmutableList.of(), table);\n+    List<RegionTask> tasks = RangeSplitter\n+        .newSplitter(session.getRegionManager())\n+        .splitRangeByRegion(scanPlan.getKeyRanges());\n+    HashMap<String, Integer> regionMap = new HashMap<>();","path":"src/main/java/com/pingcap/tikv/tools/RegionUtils.java","position":45,"original_position":45,"commit_id":"628ca18ae0dc378ce33a74e035c6787ae194e84c","original_commit_id":"628ca18ae0dc378ce33a74e035c6787ae194e84c","user":{"login":"ilovesoup","id":3347719,"avatar_url":"https://avatars2.githubusercontent.com/u/3347719?v=4","gravatar_id":"","url":"https://api.github.com/users/ilovesoup","html_url":"https://github.com/ilovesoup","followers_url":"https://api.github.com/users/ilovesoup/followers","following_url":"https://api.github.com/users/ilovesoup/following{/other_user}","gists_url":"https://api.github.com/users/ilovesoup/gists{/gist_id}","starred_url":"https://api.github.com/users/ilovesoup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilovesoup/subscriptions","organizations_url":"https://api.github.com/users/ilovesoup/orgs","repos_url":"https://api.github.com/users/ilovesoup/repos","events_url":"https://api.github.com/users/ilovesoup/events{/privacy}","received_events_url":"https://api.github.com/users/ilovesoup/received_events","type":"User","site_admin":false},"body":"done","created_at":"2017-12-18T06:57:09Z","updated_at":"2017-12-18T06:57:26Z","html_url":"https://github.com/pingcap/tikv-client-lib-java/pull/196#discussion_r157410832","pull_request_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/comments/157410832"},"html":{"href":"https://github.com/pingcap/tikv-client-lib-java/pull/196#discussion_r157410832"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196"}},"in_reply_to_id":157006497},"pull_request":{"url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196","id":158007829,"html_url":"https://github.com/pingcap/tikv-client-lib-java/pull/196","diff_url":"https://github.com/pingcap/tikv-client-lib-java/pull/196.diff","patch_url":"https://github.com/pingcap/tikv-client-lib-java/pull/196.patch","issue_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/196","number":196,"state":"open","locked":false,"title":"Add debug utils","user":{"login":"ilovesoup","id":3347719,"avatar_url":"https://avatars2.githubusercontent.com/u/3347719?v=4","gravatar_id":"","url":"https://api.github.com/users/ilovesoup","html_url":"https://github.com/ilovesoup","followers_url":"https://api.github.com/users/ilovesoup/followers","following_url":"https://api.github.com/users/ilovesoup/following{/other_user}","gists_url":"https://api.github.com/users/ilovesoup/gists{/gist_id}","starred_url":"https://api.github.com/users/ilovesoup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilovesoup/subscriptions","organizations_url":"https://api.github.com/users/ilovesoup/orgs","repos_url":"https://api.github.com/users/ilovesoup/repos","events_url":"https://api.github.com/users/ilovesoup/events{/privacy}","received_events_url":"https://api.github.com/users/ilovesoup/received_events","type":"User","site_admin":false},"body":"Add debug utils for various cases.\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/pingcap/tikv-client-lib-java/196)\n<!-- Reviewable:end -->\n","created_at":"2017-12-13T05:41:20Z","updated_at":"2017-12-18T06:57:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0b5159d23f9d1b1e4be05c720ac421fa206dea8e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196/commits","review_comments_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196/comments","review_comment_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/196/comments","statuses_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/statuses/628ca18ae0dc378ce33a74e035c6787ae194e84c","head":{"label":"pingcap:add_debug_utils","ref":"add_debug_utils","sha":"628ca18ae0dc378ce33a74e035c6787ae194e84c","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":89454597,"name":"tikv-client-lib-java","full_name":"pingcap/tikv-client-lib-java","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tikv-client-lib-java","description":"TiKV Java client library","fork":false,"url":"https://api.github.com/repos/pingcap/tikv-client-lib-java","forks_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/forks","keys_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/events","assignees_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/merges","archive_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/deployments","created_at":"2017-04-26T08:01:47Z","updated_at":"2017-12-18T05:32:50Z","pushed_at":"2017-12-18T06:55:11Z","git_url":"git://github.com/pingcap/tikv-client-lib-java.git","ssh_url":"git@github.com:pingcap/tikv-client-lib-java.git","clone_url":"https://github.com/pingcap/tikv-client-lib-java.git","svn_url":"https://github.com/pingcap/tikv-client-lib-java","homepage":"","size":1634,"stargazers_count":31,"watchers_count":31,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":23,"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":12,"open_issues":23,"watchers":31,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"0dfdc585a21bc51b8d5aa6c64023fbcab45549ff","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":89454597,"name":"tikv-client-lib-java","full_name":"pingcap/tikv-client-lib-java","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tikv-client-lib-java","description":"TiKV Java client library","fork":false,"url":"https://api.github.com/repos/pingcap/tikv-client-lib-java","forks_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/forks","keys_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/events","assignees_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/merges","archive_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv-client-lib-java/deployments","created_at":"2017-04-26T08:01:47Z","updated_at":"2017-12-18T05:32:50Z","pushed_at":"2017-12-18T06:55:11Z","git_url":"git://github.com/pingcap/tikv-client-lib-java.git","ssh_url":"git@github.com:pingcap/tikv-client-lib-java.git","clone_url":"https://github.com/pingcap/tikv-client-lib-java.git","svn_url":"https://github.com/pingcap/tikv-client-lib-java","homepage":"","size":1634,"stargazers_count":31,"watchers_count":31,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":23,"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":12,"open_issues":23,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196"},"html":{"href":"https://github.com/pingcap/tikv-client-lib-java/pull/196"},"issue":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/196"},"comments":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/issues/196/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/pulls/196/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tikv-client-lib-java/statuses/628ca18ae0dc378ce33a74e035c6787ae194e84c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ilovesoup"}}