{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/comments/178230619","pull_request_review_id":108260924,"id":178230619,"diff_hunk":"@@ -0,0 +1,346 @@\n+/*\n+ * Copyright 2018 Google LLC\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+ *     https://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+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.google.cloud.bigtable.data.v2.internal;\n+\n+import com.google.api.core.InternalApi;\n+import com.google.bigtable.v2.ReadRowsRequest;\n+import com.google.bigtable.v2.RowRange;\n+import com.google.bigtable.v2.RowSet;\n+import com.google.cloud.bigtable.data.v2.models.Query;\n+import com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange;\n+import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsResumptionStrategy;\n+import com.google.common.base.Preconditions;\n+import com.google.common.collect.ComparisonChain;\n+import com.google.common.collect.ImmutableSortedSet;\n+import com.google.common.collect.Lists;\n+import com.google.protobuf.ByteString;\n+import java.util.Arrays;\n+import java.util.Comparator;\n+import java.util.List;\n+import java.util.SortedSet;\n+import javax.annotation.Nonnull;\n+import javax.annotation.Nullable;\n+\n+/**\n+ * Internal helper to split a {@link RowSet} into segments based on keys.\n+ *\n+ * <p>This class is considered an internal implementation detail and not meant to be used by\n+ * applications.\n+ *\n+ * @see Query#shard(List)\n+ * @see Query#getBound()\n+ * @see ReadRowsResumptionStrategy#getResumeRequest(ReadRowsRequest)\n+ */\n+@InternalApi\n+public final class RowSetUtil {\n+  private RowSetUtil() {}\n+\n+  /**\n+   * Splits the provided {@link RowSet} on the provided split and returns the second segment. If the\n+   * second segment is empty, then it will return null. Note that the split point represents the\n+   * last row in the first segment.\n+   */\n+  @Nullable\n+  public static RowSet getRemaining(@Nonnull RowSet rowSet, @Nonnull ByteString split) {","path":"google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RowSetUtil.java","position":null,"original_position":57,"commit_id":"c9f36c7c77ec055a48dc2048c2aad0e428eebf89","original_commit_id":"d42887a6112b5049ea1a103dff45da377390fa28","user":{"login":"igorbernstein2","id":23526194,"avatar_url":"https://avatars3.githubusercontent.com/u/23526194?v=4","gravatar_id":"","url":"https://api.github.com/users/igorbernstein2","html_url":"https://github.com/igorbernstein2","followers_url":"https://api.github.com/users/igorbernstein2/followers","following_url":"https://api.github.com/users/igorbernstein2/following{/other_user}","gists_url":"https://api.github.com/users/igorbernstein2/gists{/gist_id}","starred_url":"https://api.github.com/users/igorbernstein2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorbernstein2/subscriptions","organizations_url":"https://api.github.com/users/igorbernstein2/orgs","repos_url":"https://api.github.com/users/igorbernstein2/repos","events_url":"https://api.github.com/users/igorbernstein2/events{/privacy}","received_events_url":"https://api.github.com/users/igorbernstein2/received_events","type":"User","site_admin":false},"body":"done","created_at":"2018-03-30T04:20:47Z","updated_at":"2018-03-30T04:20:48Z","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3103#discussion_r178230619","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/comments/178230619"},"html":{"href":"https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3103#discussion_r178230619"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103"}},"in_reply_to_id":178124893},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103","id":178216297,"html_url":"https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3103","diff_url":"https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3103.diff","patch_url":"https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3103.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/3103","number":3103,"state":"open","locked":false,"title":"Bigtable: Implement query sharding by generalizing ReadRows resume request builder.","user":{"login":"igorbernstein2","id":23526194,"avatar_url":"https://avatars3.githubusercontent.com/u/23526194?v=4","gravatar_id":"","url":"https://api.github.com/users/igorbernstein2","html_url":"https://github.com/igorbernstein2","followers_url":"https://api.github.com/users/igorbernstein2/followers","following_url":"https://api.github.com/users/igorbernstein2/following{/other_user}","gists_url":"https://api.github.com/users/igorbernstein2/gists{/gist_id}","starred_url":"https://api.github.com/users/igorbernstein2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorbernstein2/subscriptions","organizations_url":"https://api.github.com/users/igorbernstein2/orgs","repos_url":"https://api.github.com/users/igorbernstein2/repos","events_url":"https://api.github.com/users/igorbernstein2/events{/privacy}","received_events_url":"https://api.github.com/users/igorbernstein2/received_events","type":"User","site_admin":false},"body":"This extends the work done in #2986 to allow map reduce style frameworks like beam to split queries into shards and execute them in parallel. The mechanism for chopping off part of query in a resume request is very similar to splitting a query into multiple shards. The main difference is how many splits are used.\r\n\r\nThe common functionality is extracted to an internal `RowSetUtil`  class that does all of the heavy lifting. The class is used both by`ReadRowsResumptionStrategy` for computing the resume request and the newly introduced `Query#shard` method.\r\n\r\nAlso expose the ability to get a Query's bounding range. The combination of Query#shard & Query#getBound is needed to implement a Beam source\r\n","created_at":"2018-03-29T03:07:58Z","updated_at":"2018-03-30T04:20:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b634152e8dfe6f74f093aed10a97a68fbfdd0995","assignee":null,"assignees":[],"requested_reviewers":[{"login":"pongad","id":1617025,"avatar_url":"https://avatars1.githubusercontent.com/u/1617025?v=4","gravatar_id":"","url":"https://api.github.com/users/pongad","html_url":"https://github.com/pongad","followers_url":"https://api.github.com/users/pongad/followers","following_url":"https://api.github.com/users/pongad/following{/other_user}","gists_url":"https://api.github.com/users/pongad/gists{/gist_id}","starred_url":"https://api.github.com/users/pongad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pongad/subscriptions","organizations_url":"https://api.github.com/users/pongad/orgs","repos_url":"https://api.github.com/users/pongad/repos","events_url":"https://api.github.com/users/pongad/events{/privacy}","received_events_url":"https://api.github.com/users/pongad/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":175662188,"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/labels/cla:%20yes","name":"cla: yes","color":"c2e0c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/3103/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/statuses/c9f36c7c77ec055a48dc2048c2aad0e428eebf89","head":{"label":"igorbernstein2:query-sharding","ref":"query-sharding","sha":"c9f36c7c77ec055a48dc2048c2aad0e428eebf89","user":{"login":"igorbernstein2","id":23526194,"avatar_url":"https://avatars3.githubusercontent.com/u/23526194?v=4","gravatar_id":"","url":"https://api.github.com/users/igorbernstein2","html_url":"https://github.com/igorbernstein2","followers_url":"https://api.github.com/users/igorbernstein2/followers","following_url":"https://api.github.com/users/igorbernstein2/following{/other_user}","gists_url":"https://api.github.com/users/igorbernstein2/gists{/gist_id}","starred_url":"https://api.github.com/users/igorbernstein2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorbernstein2/subscriptions","organizations_url":"https://api.github.com/users/igorbernstein2/orgs","repos_url":"https://api.github.com/users/igorbernstein2/repos","events_url":"https://api.github.com/users/igorbernstein2/events{/privacy}","received_events_url":"https://api.github.com/users/igorbernstein2/received_events","type":"User","site_admin":false},"repo":{"id":115758265,"name":"google-cloud-java","full_name":"igorbernstein2/google-cloud-java","owner":{"login":"igorbernstein2","id":23526194,"avatar_url":"https://avatars3.githubusercontent.com/u/23526194?v=4","gravatar_id":"","url":"https://api.github.com/users/igorbernstein2","html_url":"https://github.com/igorbernstein2","followers_url":"https://api.github.com/users/igorbernstein2/followers","following_url":"https://api.github.com/users/igorbernstein2/following{/other_user}","gists_url":"https://api.github.com/users/igorbernstein2/gists{/gist_id}","starred_url":"https://api.github.com/users/igorbernstein2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorbernstein2/subscriptions","organizations_url":"https://api.github.com/users/igorbernstein2/orgs","repos_url":"https://api.github.com/users/igorbernstein2/repos","events_url":"https://api.github.com/users/igorbernstein2/events{/privacy}","received_events_url":"https://api.github.com/users/igorbernstein2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/igorbernstein2/google-cloud-java","description":"Google Cloud Client Library for Java","fork":true,"url":"https://api.github.com/repos/igorbernstein2/google-cloud-java","forks_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/forks","keys_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/teams","hooks_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/hooks","issue_events_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/issues/events{/number}","events_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/events","assignees_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/assignees{/user}","branches_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/branches{/branch}","tags_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/tags","blobs_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/statuses/{sha}","languages_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/languages","stargazers_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/stargazers","contributors_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/contributors","subscribers_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/subscribers","subscription_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/subscription","commits_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/contents/{+path}","compare_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/merges","archive_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/downloads","issues_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/issues{/number}","pulls_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/pulls{/number}","milestones_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/milestones{/number}","notifications_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/labels{/name}","releases_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/releases{/id}","deployments_url":"https://api.github.com/repos/igorbernstein2/google-cloud-java/deployments","created_at":"2017-12-29T22:26:47Z","updated_at":"2017-12-29T22:26:54Z","pushed_at":"2018-03-30T04:20:43Z","git_url":"git://github.com/igorbernstein2/google-cloud-java.git","ssh_url":"git@github.com:igorbernstein2/google-cloud-java.git","clone_url":"https://github.com/igorbernstein2/google-cloud-java.git","svn_url":"https://github.com/igorbernstein2/google-cloud-java","homepage":"https://googlecloudplatform.github.io/google-cloud-java/","size":240417,"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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"dd1c50962930a89a91809a999116db132a1efdab","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars0.githubusercontent.com/u/2810941?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":26181278,"name":"google-cloud-java","full_name":"GoogleCloudPlatform/google-cloud-java","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars0.githubusercontent.com/u/2810941?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/google-cloud-java","description":"Google Cloud Client Library for Java","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/deployments","created_at":"2014-11-04T17:57:16Z","updated_at":"2018-03-29T06:18:18Z","pushed_at":"2018-03-30T04:20:45Z","git_url":"git://github.com/GoogleCloudPlatform/google-cloud-java.git","ssh_url":"git@github.com:GoogleCloudPlatform/google-cloud-java.git","clone_url":"https://github.com/GoogleCloudPlatform/google-cloud-java.git","svn_url":"https://github.com/GoogleCloudPlatform/google-cloud-java","homepage":"https://googlecloudplatform.github.io/google-cloud-java/","size":289068,"stargazers_count":614,"watchers_count":614,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":407,"mirror_url":null,"archived":false,"open_issues_count":93,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":407,"open_issues":93,"watchers":614,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103"},"html":{"href":"https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3103"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/3103"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/3103/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/pulls/3103/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/statuses/c9f36c7c77ec055a48dc2048c2aad0e428eebf89"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"igorbernstein2"}}