-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Bigtable: 02. Surface: Readrows #2849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pongad
merged 18 commits into
googleapis:master
from
igorbernstein2:02-surface-readrows
Feb 12, 2018
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f374e66
02. Surface: ReadRows
igorbernstein2 8b838cd
codacy fixes
igorbernstein2 cd41c0f
Refactor Range support to allow for a consistent api
igorbernstein2 9b46ae4
tweaks
igorbernstein2 fa5aafc
Truth static import
igorbernstein2 88da7de
cleanup imports
igorbernstein2 e3684fb
reformat
igorbernstein2 90cc127
remove placeholder
igorbernstein2 0e8ff21
fix visibility of clone
igorbernstein2 db00235
tweaks
igorbernstein2 45c7b05
tweaks
igorbernstein2 106b54a
address feedback
igorbernstein2 bc0dae6
move close()
igorbernstein2 8be1339
sanity check query limit
igorbernstein2 1328f6a
oops, forgot to commit this
igorbernstein2 e9c7439
fix error message
igorbernstein2 6e64dc3
address feedback
igorbernstein2 869da95
move close to end
igorbernstein2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...le-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RegexUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Copyright 2018 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.google.cloud.bigtable.data.v2.internal; | ||
|
|
||
| import com.google.api.core.InternalApi; | ||
| import com.google.protobuf.ByteString; | ||
| import com.google.protobuf.ByteString.ByteIterator; | ||
|
|
||
| /** | ||
| * Contains utilities to handle RE2 flavor regular expressions. This differs from {@link | ||
| * java.util.regex.Pattern} in two important ways: | ||
| * | ||
| * <ol> | ||
| * <li>Binary strings are supported. | ||
| * <li>The syntax is a lot more restricted but allows different modifiers. | ||
| * </ol> | ||
| * | ||
| * <p>See <a href="https://github.com/google/re2">https://github.com/google/re2</a> for more | ||
| * details. | ||
| */ | ||
| @InternalApi | ||
| public final class RegexUtil { | ||
| private static final byte[] NULL_BYTES = "\\x00".getBytes(); | ||
|
|
||
| private RegexUtil() {} | ||
|
|
||
| public static String literalRegex(final String value) { | ||
| return literalRegex(ByteString.copyFromUtf8(value)).toStringUtf8(); | ||
| } | ||
| /** Converts the value to a quoted regular expression. */ | ||
| public static ByteString literalRegex(ByteString value) { | ||
| ByteString.Output output = ByteString.newOutput(value.size() * 2); | ||
|
|
||
| ByteIterator it = value.iterator(); | ||
| writeLiteralRegex(it, output); | ||
|
|
||
| return output.toByteString(); | ||
| } | ||
|
|
||
| // Extracted from: re2 QuoteMeta: | ||
| // https://github.com/google/re2/blob/70f66454c255080a54a8da806c52d1f618707f8a/re2/re2.cc#L456 | ||
| private static void writeLiteralRegex(ByteIterator input, ByteString.Output output) { | ||
| while (input.hasNext()) { | ||
| byte unquoted = input.nextByte(); | ||
|
|
||
| if ((unquoted < 'a' || unquoted > 'z') | ||
| && (unquoted < 'A' || unquoted > 'Z') | ||
| && (unquoted < '0' || unquoted > '9') | ||
| && unquoted != '_' | ||
| && | ||
| // If this is the part of a UTF8 or Latin1 character, we need | ||
| // to copy this byte without escaping. Experimentally this is | ||
| // what works correctly with the regexp library. | ||
| (unquoted & 128) == 0) { | ||
|
|
||
| if (unquoted == '\0') { // Special handling for null chars. | ||
| // Note that this special handling is not strictly required for RE2, | ||
| // but this quoting is required for other regexp libraries such as | ||
| // PCRE. | ||
| // Can't use "\\0" since the next character might be a digit. | ||
| output.write(NULL_BYTES, 0, NULL_BYTES.length); | ||
| continue; | ||
| } | ||
|
|
||
| output.write('\\'); | ||
| } | ||
| output.write(unquoted); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.