-
Notifications
You must be signed in to change notification settings - Fork 50
feat: support readTime in Datastore query splitter. #763
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
gcf-merge-on-green
merged 6 commits into
googleapis:main
from
yixiaoshen:ys-v1-split-snapshot-read
Jun 21, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aae62bb
feat: support readTime in Datastore query splitter.
yixiaoshen 16120bb
Merge remote-tracking branch 'upstream/main' into ys-v1-split-snapsho…
yixiaoshen 1a1716e
Add tests for query splitter.
yixiaoshen f1f746d
Merge remote-tracking branch 'upstream/main' into ys-v1-split-snapsho…
yixiaoshen 8cca1d1
addressed review comments
yixiaoshen 89b053f
addressed review comments
yixiaoshen 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- see http://mojo.codehaus.org/clirr-maven-plugin/examples/ignored-differences.html --> | ||
| <differences> | ||
| <difference> | ||
| <className>com/google/datastore/v1/client/QuerySplitter</className> | ||
| <method>java.util.List getSplits(com.google.datastore.v1.Query, com.google.datastore.v1.PartitionId, int, com.google.datastore.v1.client.Datastore, com.google.protobuf.Timestamp)</method> | ||
| <differenceType>7012</differenceType> | ||
| </difference> | ||
| </differences> |
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
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
36 changes: 36 additions & 0 deletions
36
...-v1-proto-client/src/main/java/com/google/datastore/v1/client/testing/MockCredential.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,36 @@ | ||
| /* | ||
| * Copyright 2022 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 | ||
| * | ||
| * http://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.datastore.v1.client.testing; | ||
|
|
||
| import com.google.api.client.auth.oauth2.Credential; | ||
| import com.google.api.client.http.HttpRequest; | ||
| import java.io.IOException; | ||
|
|
||
| /** Fake credential used for testing purpose. */ | ||
| public class MockCredential extends Credential { | ||
| public MockCredential() { | ||
| super( | ||
| new AccessMethod() { | ||
| @Override | ||
| public void intercept(HttpRequest request, String accessToken) throws IOException {} | ||
|
|
||
| @Override | ||
| public String getAccessTokenFromRequest(HttpRequest request) { | ||
| return "MockAccessToken"; | ||
| } | ||
| }); | ||
| } | ||
| } |
137 changes: 137 additions & 0 deletions
137
...oto-client/src/main/java/com/google/datastore/v1/client/testing/MockDatastoreFactory.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,137 @@ | ||
| /* | ||
| * Copyright 2022 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 | ||
| * | ||
| * http://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.datastore.v1.client.testing; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkState; | ||
|
|
||
| import com.google.api.client.auth.oauth2.Credential; | ||
| import com.google.api.client.http.GenericUrl; | ||
| import com.google.api.client.http.HttpRequestFactory; | ||
| import com.google.api.client.http.HttpStatusCodes; | ||
| import com.google.api.client.http.HttpTransport; | ||
| import com.google.api.client.http.LowLevelHttpRequest; | ||
| import com.google.api.client.http.LowLevelHttpResponse; | ||
| import com.google.api.client.testing.http.MockHttpTransport; | ||
| import com.google.api.client.testing.http.MockLowLevelHttpRequest; | ||
| import com.google.api.client.testing.http.MockLowLevelHttpResponse; | ||
| import com.google.api.client.testing.util.TestableByteArrayInputStream; | ||
| import com.google.common.collect.Iterables; | ||
| import com.google.datastore.v1.client.DatastoreFactory; | ||
| import com.google.datastore.v1.client.DatastoreOptions; | ||
| import com.google.protobuf.Message; | ||
| import com.google.rpc.Code; | ||
| import com.google.rpc.Status; | ||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| /** Fake Datastore factory used for testing purposes when a true Datastore service is not needed. */ | ||
| public class MockDatastoreFactory extends DatastoreFactory { | ||
| private int nextStatus; | ||
| private Message nextResponse; | ||
| private Status nextError; | ||
| private IOException nextException; | ||
|
|
||
| private String lastPath; | ||
| private String lastMimeType; | ||
| private byte[] lastBody; | ||
| private List<String> lastCookies; | ||
| private String lastApiFormatHeaderValue; | ||
|
|
||
| public void setNextResponse(Message response) { | ||
| nextStatus = HttpStatusCodes.STATUS_CODE_OK; | ||
| nextResponse = response; | ||
| nextError = null; | ||
| nextException = null; | ||
| } | ||
|
|
||
| public void setNextError(int status, Code code, String message) { | ||
| nextStatus = status; | ||
| nextResponse = null; | ||
| nextError = makeErrorContent(message, code); | ||
| nextException = null; | ||
| } | ||
|
|
||
| public void setNextException(IOException exception) { | ||
| nextStatus = 0; | ||
| nextResponse = null; | ||
| nextError = null; | ||
| nextException = exception; | ||
| } | ||
|
|
||
| @Override | ||
| public HttpRequestFactory makeClient(DatastoreOptions options) { | ||
| HttpTransport transport = | ||
| new MockHttpTransport() { | ||
| @Override | ||
| public LowLevelHttpRequest buildRequest(String method, String url) { | ||
| return new MockLowLevelHttpRequest(url) { | ||
| @Override | ||
| public LowLevelHttpResponse execute() throws IOException { | ||
| lastPath = new GenericUrl(getUrl()).getRawPath(); | ||
| lastMimeType = getContentType(); | ||
| lastCookies = getHeaderValues("Cookie"); | ||
| lastApiFormatHeaderValue = | ||
| Iterables.getOnlyElement(getHeaderValues("X-Goog-Api-Format-Version")); | ||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
| getStreamingContent().writeTo(out); | ||
| lastBody = out.toByteArray(); | ||
| if (nextException != null) { | ||
| throw nextException; | ||
| } | ||
| MockLowLevelHttpResponse response = | ||
| new MockLowLevelHttpResponse() | ||
| .setStatusCode(nextStatus) | ||
| .setContentType("application/x-protobuf"); | ||
| if (nextError != null) { | ||
| checkState(nextResponse == null); | ||
| response.setContent(new TestableByteArrayInputStream(nextError.toByteArray())); | ||
| } else { | ||
| response.setContent(new TestableByteArrayInputStream(nextResponse.toByteArray())); | ||
| } | ||
| return response; | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| Credential credential = options.getCredential(); | ||
| return transport.createRequestFactory(credential); | ||
| } | ||
|
|
||
| public String getLastPath() { | ||
| return lastPath; | ||
| } | ||
|
|
||
| public String getLastMimeType() { | ||
| return lastMimeType; | ||
| } | ||
|
|
||
| public String getLastApiFormatHeaderValue() { | ||
| return lastApiFormatHeaderValue; | ||
| } | ||
|
|
||
| public byte[] getLastBody() { | ||
| return lastBody; | ||
| } | ||
|
|
||
| public List<String> getLastCookies() { | ||
| return lastCookies; | ||
| } | ||
|
|
||
| private static Status makeErrorContent(String message, Code code) { | ||
| return Status.newBuilder().setCode(code.getNumber()).setMessage(message).build(); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.