diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot-hermetic.yaml similarity index 90% rename from .github/.OwlBot.yaml rename to .github/.OwlBot-hermetic.yaml index d89045599..02f0dd37b 100644 --- a/.github/.OwlBot.yaml +++ b/.github/.OwlBot-hermetic.yaml @@ -11,9 +11,6 @@ # 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. - -docker: - image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest" deep-remove-regex: - "/proto-google-.*/src" @@ -29,4 +26,4 @@ deep-copy-regex: dest: "/owl-bot-staging/$1/grpc-google-cloud-datastore-admin-$1/src" # Admin & Data APIs share the same wrapper library. - source: "/google/datastore/admin/(v.*)/.*-java/gapic-google-.*/src" - dest: "/owl-bot-staging/$1/google-cloud-datastore/src" \ No newline at end of file + dest: "/owl-bot-staging/$1/google-cloud-datastore/src" diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml deleted file mode 100644 index 6167135e9..000000000 --- a/.github/.OwlBot.lock.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2024 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. -docker: - image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:81c3ec554428c8ff6c92f0d58668b7ef52265d053a82284c97a326745e786949 -# created: 2024-03-27T17:59:25.436353226Z diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3a7c9a454..2afe7bfe7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -17,15 +17,4 @@ updates: # If a security vulnerability comes in, we will be notified about # it via template in the synthtool repository. ignore: - - dependency-name: "*" - - # rules for the `V3-experimental` branch - - package-ecosystem: maven - directory: "/" - schedule: - interval: daily - commit-message: - # Prefix all commit messages with "deps: " - prefix: "deps" - open-pull-requests-limit: 10 - target-branch: "V3-experimental" + - dependency-name: "*" \ No newline at end of file diff --git a/.github/release-please.yml b/.github/release-please.yml index 53b119627..cbb5be49c 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -30,3 +30,7 @@ branches: handleGHRelease: true releaseType: java-backport branch: 2.17.x + - bumpMinorPreMajor: true + handleGHRelease: true + releaseType: java-backport + branch: 2.19.x diff --git a/.github/scripts/update_generation_config.sh b/.github/scripts/update_generation_config.sh new file mode 100644 index 000000000..91434688c --- /dev/null +++ b/.github/scripts/update_generation_config.sh @@ -0,0 +1,168 @@ +#!/bin/bash +set -e +# This script should be run at the root of the repository. +# This script is used to update googleapis_commitish, gapic_generator_version, +# and libraries_bom_version in generation configuration at the time of running +# and create a pull request. + +# The following commands need to be installed before running the script: +# 1. git +# 2. gh +# 3. jq + +# Utility functions +# Get the latest released version of a Maven artifact. +function get_latest_released_version() { + local group_id=$1 + local artifact_id=$2 + latest=$(curl -s "https://search.maven.org/solrsearch/select?q=g:${group_id}+AND+a:${artifact_id}&core=gav&rows=500&wt=json" | jq -r '.response.docs[] | select(.v | test("^[0-9]+(\\.[0-9]+)*$")) | .v' | sort -V | tail -n 1) + echo "${latest}" +} + +# Update a key to a new value in the generation config. +function update_config() { + local key_word=$1 + local new_value=$2 + local file=$3 + echo "Update ${key_word} to ${new_value} in ${file}" + sed -i -e "s/^${key_word}.*$/${key_word}: ${new_value}/" "${file}" +} + +# Update an action to a new version in GitHub action. +function update_action() { + local key_word=$1 + local new_value=$2 + local file=$3 + echo "Update ${key_word} to ${new_value} in ${file}" + # use a different delimiter because the key_word contains "/". + sed -i -e "s|${key_word}@v.*$|${key_word}@v${new_value}|" "${file}" +} + +# The parameters of this script is: +# 1. base_branch, the base branch of the result pull request. +# 2. repo, organization/repo-name, e.g., googleapis/google-cloud-java +# 3. [optional] generation_config, the path to the generation configuration, +# the default value is generation_config.yaml in the repository root. +# 4. [optional] workflow, the library generation workflow file, +# the default value is .github/workflows/hermetic_library_generation.yaml. +while [[ $# -gt 0 ]]; do +key="$1" +case "${key}" in + --base_branch) + base_branch="$2" + shift + ;; + --repo) + repo="$2" + shift + ;; + --generation_config) + generation_config="$2" + shift + ;; + --workflow) + workflow="$2" + shift + ;; + *) + echo "Invalid option: [$1]" + exit 1 + ;; +esac +shift +done + +if [ -z "${base_branch}" ]; then + echo "missing required argument --base_branch" + exit 1 +fi + +if [ -z "${repo}" ]; then + echo "missing required argument --repo" + exit 1 +fi + +if [ -z "${generation_config}" ]; then + generation_config="generation_config.yaml" + echo "Use default generation config: ${generation_config}" +fi + +if [ -z "${workflow}" ]; then + workflow=".github/workflows/hermetic_library_generation.yaml" + echo "Use default library generation workflow file: ${workflow}" +fi + +current_branch="generate-libraries-${base_branch}" +title="chore: Update generation configuration at $(date)" + +git checkout "${base_branch}" +# Try to find a open pull request associated with the branch +pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number") +# Create a branch if there's no open pull request associated with the +# branch; otherwise checkout the pull request. +if [ -z "${pr_num}" ]; then + git checkout -b "${current_branch}" + # Push the current branch to remote so that we can + # compare the commits later. + git push -u origin "${current_branch}" +else + gh pr checkout "${pr_num}" +fi + +# Only allow fast-forward merging; exit with non-zero result if there's merging +# conflict. +git merge -m "chore: merge ${base_branch} into ${current_branch}" "${base_branch}" + +mkdir tmp-googleapis +# Use partial clone because only commit history is needed. +git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis +pushd tmp-googleapis +git pull +latest_commit=$(git rev-parse HEAD) +popd +rm -rf tmp-googleapis +update_config "googleapis_commitish" "${latest_commit}" "${generation_config}" + +# Update gapic-generator-java version to the latest +latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java") +update_config "gapic_generator_version" "${latest_version}" "${generation_config}" + +# Update composite action version to latest gapic-generator-java version +update_action "googleapis/sdk-platform-java/.github/scripts" \ + "${latest_version}" \ + "${workflow}" + +# Update libraries-bom version to the latest +latest_version=$(get_latest_released_version "com.google.cloud" "libraries-bom") +update_config "libraries_bom_version" "${latest_version}" "${generation_config}" + +git add "${generation_config}" "${workflow}" +changed_files=$(git diff --cached --name-only) +if [[ "${changed_files}" == "" ]]; then + echo "The latest generation config is not changed." + echo "Skip committing to the pull request." +else + git commit -m "${title}" +fi + +# There are potentially at most two commits: merge commit and change commit. +# We want to exit the script if no commit happens (otherwise this will be an +# infinite loop). +# `git cherry` is a way to find whether the local branch has commits that are +# not in the remote branch. +# If we find any such commit, push them to remote branch. +unpushed_commit=$(git cherry -v "origin/${current_branch}" | wc -l) +if [[ "${unpushed_commit}" -eq 0 ]]; then + echo "No unpushed commits, exit" + exit 0 +fi + +if [ -z "${pr_num}" ]; then + git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git" + git fetch -q remote_repo + git push -f remote_repo "${current_branch}" + gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}" +else + git push + gh pr edit "${pr_num}" --title "${title}" --body "${title}" +fi diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 0159d7ae3..203644341 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -15,10 +15,11 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - 'Kokoro - Test: Java GraalVM Native Image' - 'Kokoro - Test: Java 17 GraalVM Native Image' - javadoc + - library_generation + - unmanaged_dependency_check - pattern: 1.106.5-sp isAdminEnforced: true requiredApprovingReviewCount: 1 @@ -62,7 +63,6 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - pattern: 2.2.x isAdminEnforced: true requiredApprovingReviewCount: 1 @@ -77,7 +77,6 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - pattern: 2.12.x isAdminEnforced: true requiredApprovingReviewCount: 1 @@ -92,7 +91,6 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - 'Kokoro - Test: Java GraalVM Native Image' - 'Kokoro - Test: Java 17 GraalVM Native Image' - pattern: multi-db @@ -109,10 +107,24 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - 'Kokoro - Test: Java GraalVM Native Image' - 'Kokoro - Test: Java 17 GraalVM Native Image' - - pattern: V3-experimental + - pattern: 2.15.x + isAdminEnforced: true + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - dependencies (17) + - lint + - clirr + - units (8) + - units (11) + - 'Kokoro - Test: Integration' + - cla/google + - 'Kokoro - Test: Java GraalVM Native Image' + - 'Kokoro - Test: Java 17 GraalVM Native Image' + - pattern: 2.17.x isAdminEnforced: true requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true @@ -125,11 +137,10 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - 'Kokoro - Test: Java GraalVM Native Image' - 'Kokoro - Test: Java 17 GraalVM Native Image' - javadoc - - pattern: 2.15.x + - pattern: grpc-experimental isAdminEnforced: true requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true @@ -142,10 +153,10 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - 'Kokoro - Test: Java GraalVM Native Image' - 'Kokoro - Test: Java 17 GraalVM Native Image' - - pattern: 2.17.x + - javadoc + - pattern: 2.19.x isAdminEnforced: true requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true @@ -158,7 +169,6 @@ branchProtectionRules: - units (11) - 'Kokoro - Test: Integration' - cla/google - - OwlBot Post Processor - 'Kokoro - Test: Java GraalVM Native Image' - 'Kokoro - Test: Java 17 GraalVM Native Image' - javadoc diff --git a/.github/trusted-contribution.yml b/.github/trusted-contribution.yml index a0ba1f7d9..88d3ac9bf 100644 --- a/.github/trusted-contribution.yml +++ b/.github/trusted-contribution.yml @@ -1,3 +1,9 @@ trustedContributors: - renovate-bot - gcf-owl-bot[bot] + +annotations: +- type: comment + text: "/gcbrun" +- type: label + text: "kokoro:force-run" diff --git a/.github/workflows/approve-readme.yaml b/.github/workflows/approve-readme.yaml index f5fc7d516..59f00b8eb 100644 --- a/.github/workflows/approve-readme.yaml +++ b/.github/workflows/approve-readme.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme' steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 with: github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} script: | diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ae66b1973..b91fa381f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,8 +27,8 @@ jobs: matrix: java: [11, 17, 21] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: ${{matrix.java}} @@ -41,8 +41,8 @@ jobs: name: "units (8)" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: java-version: 8 distribution: temurin @@ -51,7 +51,7 @@ jobs: # https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}/bin/java" >> $GITHUB_ENV shell: bash - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: java-version: 17 distribution: temurin @@ -63,8 +63,8 @@ jobs: steps: - name: Support longpaths run: git config --system core.longpaths true - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 8 @@ -78,8 +78,8 @@ jobs: matrix: java: [17] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: ${{matrix.java}} @@ -88,8 +88,8 @@ jobs: javadoc: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 @@ -100,8 +100,8 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 11 @@ -112,8 +112,8 @@ jobs: clirr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 8 diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml new file mode 100644 index 000000000..604b674ba --- /dev/null +++ b/.github/workflows/hermetic_library_generation.yaml @@ -0,0 +1,45 @@ +# Copyright 2024 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. +# GitHub action job to test core java library features on +# downstream client libraries before they are released. +name: Hermetic library generation upon generation config change through pull requests +on: + pull_request: + +env: + REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }} + GITHUB_REPOSITORY: ${{ github.repository }} +jobs: + library_generation: + runs-on: ubuntu-latest + steps: + - name: Determine whether the pull request comes from a fork + run: | + if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then + echo "This PR comes from a fork. Skip library generation." + echo "SHOULD_RUN=false" >> $GITHUB_ENV + else + echo "SHOULD_RUN=true" >> $GITHUB_ENV + fi + - uses: actions/checkout@v4 + if: env.SHOULD_RUN == 'true' + with: + fetch-depth: 0 + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + - uses: googleapis/sdk-platform-java/.github/scripts@v2.51.0 + if: env.SHOULD_RUN == 'true' + with: + base_ref: ${{ github.base_ref }} + head_ref: ${{ github.head_ref }} + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} diff --git a/.github/workflows/renovate_config_check.yaml b/.github/workflows/renovate_config_check.yaml index 87d8eb2be..7c5ec7865 100644 --- a/.github/workflows/renovate_config_check.yaml +++ b/.github/workflows/renovate_config_check.yaml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '20' diff --git a/.github/workflows/samples.yaml b/.github/workflows/samples.yaml index 10d252d77..03b293956 100644 --- a/.github/workflows/samples.yaml +++ b/.github/workflows/samples.yaml @@ -20,8 +20,8 @@ jobs: checkstyle: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 8 diff --git a/.github/workflows/unmanaged_dependency_check.yaml b/.github/workflows/unmanaged_dependency_check.yaml index 851d94b20..87c21c0a0 100644 --- a/.github/workflows/unmanaged_dependency_check.yaml +++ b/.github/workflows/unmanaged_dependency_check.yaml @@ -5,8 +5,8 @@ jobs: unmanaged_dependency_check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 11 @@ -14,6 +14,6 @@ jobs: shell: bash run: .kokoro/build.sh - name: Unmanaged dependency check - uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.29.0 + uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.41.0 with: bom-path: google-cloud-datastore-bom/pom.xml diff --git a/.github/workflows/update_generation_config.yaml b/.github/workflows/update_generation_config.yaml new file mode 100644 index 000000000..3cf773992 --- /dev/null +++ b/.github/workflows/update_generation_config.yaml @@ -0,0 +1,42 @@ +# Copyright 2024 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. +# GitHub action job to test core java library features on +# downstream client libraries before they are released. +name: Update generation configuration +on: + schedule: + - cron: '0 2 * * *' + workflow_dispatch: + +jobs: + update-generation-config: + runs-on: ubuntu-22.04 + env: + # the branch into which the pull request is merged + base_branch: main + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + - name: Update params in generation config to latest + shell: bash + run: | + set -x + [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" + [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" + bash .github/scripts/update_generation_config.sh \ + --base_branch "${base_branch}"\ + --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} diff --git a/.kokoro/presubmit/graalvm-native-17.cfg b/.kokoro/presubmit/graalvm-native-17.cfg index d7a73c2c6..6c760a779 100644 --- a/.kokoro/presubmit/graalvm-native-17.cfg +++ b/.kokoro/presubmit/graalvm-native-17.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.29.0" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.41.0" } env_vars: { diff --git a/.kokoro/presubmit/graalvm-native.cfg b/.kokoro/presubmit/graalvm-native.cfg index b5c7f594b..2a166877f 100644 --- a/.kokoro/presubmit/graalvm-native.cfg +++ b/.kokoro/presubmit/graalvm-native.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.29.0" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.41.0" } env_vars: { diff --git a/.readme-partials.yaml b/.readme-partials.yaml index 9823b5c70..3e8d3a465 100644 --- a/.readme-partials.yaml +++ b/.readme-partials.yaml @@ -105,7 +105,141 @@ custom_content: | running on Compute Engine or from your own desktop. To run the example on App Engine, simply move the code from the main method to your application's servlet class and change the print statements to display on your webpage. + + gRPC Java Datastore Client User Guide + ------- + In this feature launch, the [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance. + + #### Installation Instructions + The client can be built from the `grpc-experimental` branch on GitHub. For private preview, you can also download the artifact with the instructions provided below. + 1. Download the datastore private preview package with dependencies: + ``` + curl -o https://datastore-sdk-feature-release.web.app/google-cloud-datastore-2.20.0-grpc-experimental-1-SNAPSHOT-jar-with-dependencies.jar + ``` + 2. Run the following commands to install JDK locally: + ``` + mvn install:install-file -Dfile= -DgroupId=com.google.cloud -DartifactId=google-cloud-datastore -Dversion=2.20.0-grpc + ``` + 3. Edit your pom.xml to add above package to `` section: + ```xml + + com.google.cloud + google-cloud-datastore + 2.20.0-grpc-experimental-1-SNAPSHOT + + ``` + + And if you have not yet, add below to `` section: + ```xml + + local-repo + file://${user.home}/.m2/repository + + ``` + + #### How to Use + To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation. + + Example: + ```java + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); + ``` + Setting the transport options explicitly to `GrpcTransportOptions` will signal the client to use gRPC instead of HTTP when making calls to the server. + + To revert back to the existing stable behavior and transport, simply remove the transport options line or replace it with `HttpTransportOptions`. Please note this will require an application rebuild and restart. + Example: + ```java + // will default to existing HTTP transport behavior + DatastoreOptions datastoreOptions = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .build(); + + // will also default to existing HTTP transport behavior + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(HttpTransportOptions.newBuilder() + .setConnectTimeout(1000) + .build()).build(); + ``` + + Note: client instantiations that already use `setTransportOptions` with `HttpTransportOptions` will continue to have the same behavior. Only transports that are explicitly set to gRPC will change. + + #### Verify Datastore Transport Options Type + To verify which type of TransportOptions you have successfully configured, you can use the below lines of code to compare transport options type: + ```java + // checks if using gRPC transport options + boolean isGRPC = datastore.getOptions().getTransportOptions() instanceof GrpcTransportOptions; + + // checks if using HTTP transport options + boolean isHTTP = datastore.getOptions().getTransportOptions() instanceof HTTPTransportOptions; + ``` + + #### New Features + There are new gRPC specific features available to use in this update. + + ##### Connection Pool + A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client. + To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions. + ###### Determine the best connection pool size + The default connection pool size is right for most applications, and in most cases there's no need to change it. + + However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number. + + The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers. + + To calculate the optimal connections, gather the following information: + + 1. The maximum number of queries per second (QPS) per client when your application is running a typical workload. + 2. The average latency (the response time for a single request) in ms. + 3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value. + 4. Divide the QPS in seconds by the number of serial requests per second. + 5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.) + 6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size. + + These steps are expressed in the following equations: + ```java + (QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections + (QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections + ``` + + ###### Example + Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second. + Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization + is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel + pool size for this example should be between 10 and 50 connections. + + It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary. + + ###### Set the pool size + The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`. + See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance. + + Code Example + ```java + InstantiatingGrpcChannelProvider channelProvider = + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(MIN_VAL) + .setMaxChannelCount(MAX_VAL) + .build()) + .build(); + + DatastoreOptions options = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setChannelProvider(channelProvider) + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); + ``` Testing ------- diff --git a/.repo-metadata.json b/.repo-metadata.json index e6ebd09de..6ae8c95c0 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,19 +2,21 @@ "api_shortname": "datastore", "name_pretty": "Cloud Datastore", "product_documentation": "https://cloud.google.com/datastore", + "api_description": "is a fully managed, schemaless database for\\nstoring non-relational data. Cloud Datastore automatically scales with\\nyour users and supports ACID transactions, high availability of reads and\\nwrites, strong consistency for reads and ancestor queries, and eventual\\nconsistency for all other queries.", "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-datastore/latest/history", - "issue_tracker": "https://issuetracker.google.com/savedsearches/559768", "release_level": "stable", + "transport": "both", "language": "java", "repo": "googleapis/java-datastore", "repo_short": "java-datastore", "distribution_name": "com.google.cloud:google-cloud-datastore", - "codeowner_team": "@googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk @googleapis/api-firestore-partners", "api_id": "datastore.googleapis.com", "library_type": "GAPIC_COMBO", - "api_description": "is a fully managed, schemaless database for\nstoring non-relational data. Cloud Datastore automatically scales with\nyour users and supports ACID transactions, high availability of reads and\nwrites, strong consistency for reads and ancestor queries, and eventual\nconsistency for all other queries.", + "requires_billing": true, + "codeowner_team": "@googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk @googleapis/api-firestore-partners", "excluded_dependencies": "grpc-google-cloud-datastore-v1", - "extra_versioned_modules": "datastore-v1-proto-client", "excluded_poms": "grpc-google-cloud-datastore-v1", + "issue_tracker": "https://issuetracker.google.com/savedsearches/559768", + "extra_versioned_modules": "datastore-v1-proto-client", "recommended_package": "com.google.cloud.datastore" -} +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ba6bc10ff..adec35297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,199 @@ # Changelog +## [2.25.1](https://github.com/googleapis/java-datastore/compare/v2.25.0...v2.25.1) (2024-12-13) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.51.0 ([106ee4d](https://github.com/googleapis/java-datastore/commit/106ee4dd7ca4dd9e59a5419f59b8625680e60f15)) + + +### Dependencies + +* Update sdk platform java dependencies ([#1685](https://github.com/googleapis/java-datastore/issues/1685)) ([4372350](https://github.com/googleapis/java-datastore/commit/4372350117ba57903f510512a383339b6a4ea47c)) + +## [2.25.0](https://github.com/googleapis/java-datastore/compare/v2.24.3...v2.25.0) (2024-12-11) + + +### Features + +* Introduce `java.time` methods and variables ([#1671](https://github.com/googleapis/java-datastore/issues/1671)) ([5a78a80](https://github.com/googleapis/java-datastore/commit/5a78a8075867f4b2fc598f0423bd2ab65b559856)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.48.0 ([#1605](https://github.com/googleapis/java-datastore/issues/1605)) ([5c6a678](https://github.com/googleapis/java-datastore/commit/5c6a67844f7b5d4c7001cccd1bed3d0d56be6e90)) + + +### Documentation + +* Update gapic upgrade installation instructions ([#1677](https://github.com/googleapis/java-datastore/issues/1677)) ([b3fbfcc](https://github.com/googleapis/java-datastore/commit/b3fbfcc9654bc63bf0d8f3025641d8c50a24ef97)) + +## [2.24.3](https://github.com/googleapis/java-datastore/compare/v2.24.2...v2.24.3) (2024-11-18) + + +### Dependencies + +* Update sdk platform java dependencies ([#1662](https://github.com/googleapis/java-datastore/issues/1662)) ([b4d3ab9](https://github.com/googleapis/java-datastore/commit/b4d3ab9a72bb2a4dff59bf54abcc5d9536b2596b)) + +## [2.24.2](https://github.com/googleapis/java-datastore/compare/v2.24.1...v2.24.2) (2024-11-06) + + +### Bug Fixes + +* **doc:** Add discriptions for TransactionCallable interface ([#1644](https://github.com/googleapis/java-datastore/issues/1644)) ([173a883](https://github.com/googleapis/java-datastore/commit/173a88330cc5693f54504348cf39bf3191db2250)) +* **doc:** Fix return types for batch interface ([#1645](https://github.com/googleapis/java-datastore/issues/1645)) ([1189211](https://github.com/googleapis/java-datastore/commit/11892116f0fb8eacb711a8f48e780e48a232f987)) + +## [2.24.1](https://github.com/googleapis/java-datastore/compare/v2.24.0...v2.24.1) (2024-10-28) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.39.0 ([#1640](https://github.com/googleapis/java-datastore/issues/1640)) ([fe61f66](https://github.com/googleapis/java-datastore/commit/fe61f6691a5e3c8fbfc974b6fe613a69652241ca)) +* Update googleapis/sdk-platform-java action to v2.49.0 ([#1638](https://github.com/googleapis/java-datastore/issues/1638)) ([57598d7](https://github.com/googleapis/java-datastore/commit/57598d7d59cd6917f23a653403613e4edc160c64)) + +## [2.24.0](https://github.com/googleapis/java-datastore/compare/v2.23.0...v2.24.0) (2024-10-24) + + +### Features + +* Add FindNearest API to the stable branch ([3512ba2](https://github.com/googleapis/java-datastore/commit/3512ba2f1bcd358e3c39c36944e05873b3f25f51)) + + +### Bug Fixes + +* **sample:** Change update entity sample to use transaction ([#1633](https://github.com/googleapis/java-datastore/issues/1633)) ([c44f17a](https://github.com/googleapis/java-datastore/commit/c44f17a7bb93d688367611ee2533c59c940ae61f)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.38.0 ([#1632](https://github.com/googleapis/java-datastore/issues/1632)) ([6453f1e](https://github.com/googleapis/java-datastore/commit/6453f1e44f370a13434ef68295ae5638612032c8)) +* Update googleapis/sdk-platform-java action to v2.48.0 ([#1628](https://github.com/googleapis/java-datastore/issues/1628)) ([d3bce79](https://github.com/googleapis/java-datastore/commit/d3bce79467254b3128a8f16d5754e91d29ece525)) + +## [2.23.0](https://github.com/googleapis/java-datastore/compare/v2.22.0...v2.23.0) (2024-10-14) + + +### Features + +* Support for field update operators in the Datastore API and resolution strategies when there is a conflict at write time ([b299266](https://github.com/googleapis/java-datastore/commit/b299266e42037b731ee7bbba21dbded73a37323c)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.46.1 ([678eee2](https://github.com/googleapis/java-datastore/commit/678eee2dfb6d447a852edd436137f8ebfbe50d74)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.47.0 ([b299266](https://github.com/googleapis/java-datastore/commit/b299266e42037b731ee7bbba21dbded73a37323c)) + + +### Dependencies + +* Update sdk platform java dependencies ([#1617](https://github.com/googleapis/java-datastore/issues/1617)) ([6eaff23](https://github.com/googleapis/java-datastore/commit/6eaff23f9de25ae6ad2a4fea67c0b65a243c08fd)) + +## [2.22.0](https://github.com/googleapis/java-datastore/compare/v2.21.3...v2.22.0) (2024-09-26) + + +### Features + +* Add sample code for multiple inequalities indexing consideration query ([#1579](https://github.com/googleapis/java-datastore/issues/1579)) ([1286792](https://github.com/googleapis/java-datastore/commit/1286792d7b49229d698df652cd117d229a5cd97e)) +* Introducing Tracing with OpenTelemetry API [#1537](https://github.com/googleapis/java-datastore/issues/1537) ([#1576](https://github.com/googleapis/java-datastore/issues/1576)) ([5440c22](https://github.com/googleapis/java-datastore/commit/5440c22364074c108450c3a748a6a17d5f1dddda)) + + +### Bug Fixes + +* Update opentelemetry-sdk dependency to be test-only ([#1595](https://github.com/googleapis/java-datastore/issues/1595)) ([9d719e8](https://github.com/googleapis/java-datastore/commit/9d719e809ea830d8602399b72e432580f14ae6bd)) +* Update opentelemetry.version to 1.42.1 to match the BOM version ([#1598](https://github.com/googleapis/java-datastore/issues/1598)) ([23c5c26](https://github.com/googleapis/java-datastore/commit/23c5c2662117370c66c611604c56b878d41f4738)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.43.0 ([#1584](https://github.com/googleapis/java-datastore/issues/1584)) ([fae3b74](https://github.com/googleapis/java-datastore/commit/fae3b74eaa3494a27fd43f56435c01e8fc09e5ee)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.36.0 ([#1590](https://github.com/googleapis/java-datastore/issues/1590)) ([2db9e43](https://github.com/googleapis/java-datastore/commit/2db9e439189baf8f97127f6cff1de5d47efb0073)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.36.1 ([#1602](https://github.com/googleapis/java-datastore/issues/1602)) ([e1b7d4b](https://github.com/googleapis/java-datastore/commit/e1b7d4b205312d7d4c2a285f3d1f61388da65c83)) +* Update dependency com.google.guava:guava-testlib to v33.3.1-jre ([#1592](https://github.com/googleapis/java-datastore/issues/1592)) ([5d078a4](https://github.com/googleapis/java-datastore/commit/5d078a4b294d071716f51f0d4b9baa5d65a0fe90)) +* Update dependency com.google.testparameterinjector:test-parameter-injector to v1.17 ([#1585](https://github.com/googleapis/java-datastore/issues/1585)) ([8f74a49](https://github.com/googleapis/java-datastore/commit/8f74a49c5982d00bd168e78671163683f7b41126)) + +## [2.21.3](https://github.com/googleapis/java-datastore/compare/v2.21.2...v2.21.3) (2024-09-11) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.35.0 ([#1561](https://github.com/googleapis/java-datastore/issues/1561)) ([5a79fd8](https://github.com/googleapis/java-datastore/commit/5a79fd8d1202e65c02423fe40402c41af6050efa)) +* Update dependency com.google.errorprone:error_prone_core to v2.31.0 ([#1523](https://github.com/googleapis/java-datastore/issues/1523)) ([8d3af32](https://github.com/googleapis/java-datastore/commit/8d3af322fb56032cd7a9d29e60fd93d1f3e7e632)) +* Update dependency com.google.guava:guava-testlib to v33.3.0-jre ([#1548](https://github.com/googleapis/java-datastore/issues/1548)) ([18ba37f](https://github.com/googleapis/java-datastore/commit/18ba37f60b5b3e69c95f6e55a28daf8c0de82ba9)) +* Update dependency org.easymock:easymock to v5.4.0 ([#1482](https://github.com/googleapis/java-datastore/issues/1482)) ([ee788a1](https://github.com/googleapis/java-datastore/commit/ee788a162841994e09a61bb81b94cbe93353a78e)) + +## [2.21.2](https://github.com/googleapis/java-datastore/compare/v2.21.1...v2.21.2) (2024-08-22) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.34.0 ([#1547](https://github.com/googleapis/java-datastore/issues/1547)) ([8c5f595](https://github.com/googleapis/java-datastore/commit/8c5f5954d88732ab929b4477a3f15b0052adc2ff)) + +## [2.21.1](https://github.com/googleapis/java-datastore/compare/v2.21.0...v2.21.1) (2024-08-06) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.33.0 ([#1531](https://github.com/googleapis/java-datastore/issues/1531)) ([9e52395](https://github.com/googleapis/java-datastore/commit/9e52395f7ee71315331790284d35e7aad2f387ed)) + +## [2.21.0](https://github.com/googleapis/java-datastore/compare/v2.20.2...v2.21.0) (2024-07-31) + + +### Features + +* Enable hermetic library generation ([#1462](https://github.com/googleapis/java-datastore/issues/1462)) ([d142d9c](https://github.com/googleapis/java-datastore/commit/d142d9c95d91c8cadaf696efc12d6136814938ff)) + +## [2.20.2](https://github.com/googleapis/java-datastore/compare/v2.20.1...v2.20.2) (2024-06-28) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.32.0 ([#1492](https://github.com/googleapis/java-datastore/issues/1492)) ([d940c93](https://github.com/googleapis/java-datastore/commit/d940c937959942d753f9215e7ce940ab6742be46)) + +## [2.20.1](https://github.com/googleapis/java-datastore/compare/v2.20.0...v2.20.1) (2024-06-04) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.31.0 ([#1471](https://github.com/googleapis/java-datastore/issues/1471)) ([42c643d](https://github.com/googleapis/java-datastore/commit/42c643d78562c5cbd6c17c29a0a124be8d05198a)) +* Update dependency com.google.errorprone:error_prone_core to v2.28.0 ([#1469](https://github.com/googleapis/java-datastore/issues/1469)) ([e3fac2b](https://github.com/googleapis/java-datastore/commit/e3fac2bf9992fcb2e91319df0520094865de2d49)) +* Update dependency com.google.guava:guava-testlib to v33.2.1-jre ([#1470](https://github.com/googleapis/java-datastore/issues/1470)) ([614e930](https://github.com/googleapis/java-datastore/commit/614e930f2bdccc517d4733e5fb7f3cefad696a20)) + +## [2.20.0](https://github.com/googleapis/java-datastore/compare/v2.19.3...v2.20.0) (2024-05-27) + + +### Features + +* New PropertyMask field which allows partial commits, lookups, and query results ([#1455](https://github.com/googleapis/java-datastore/issues/1455)) ([ff5e397](https://github.com/googleapis/java-datastore/commit/ff5e39775446216b4806f55f14dacb7fc8e8854b)) + + +### Bug Fixes + +* Migrate off TextPrinter's deprecated methods ([#1452](https://github.com/googleapis/java-datastore/issues/1452)) ([c3c1317](https://github.com/googleapis/java-datastore/commit/c3c131735863d71971110e2ac7ac0244ce16ee92)) +* Set the correct database id on the key parent when calling Key#getParent ([#1457](https://github.com/googleapis/java-datastore/issues/1457)) ([992815d](https://github.com/googleapis/java-datastore/commit/992815d9989d04f7b371dfa320ed17894626a07f)) + +## [2.19.3](https://github.com/googleapis/java-datastore/compare/v2.19.2...v2.19.3) (2024-05-16) + + +### Dependencies + +* Update actions/checkout action to v4 ([#1390](https://github.com/googleapis/java-datastore/issues/1390)) ([80dbca1](https://github.com/googleapis/java-datastore/commit/80dbca1246facf21b08d33e5c6a09b9708b6ce63)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.30.1 ([#1443](https://github.com/googleapis/java-datastore/issues/1443)) ([79f6c46](https://github.com/googleapis/java-datastore/commit/79f6c46bdbabc66082f23e9562ee9541e0fdeac9)) + +## [2.19.2](https://github.com/googleapis/java-datastore/compare/v2.19.1...v2.19.2) (2024-05-03) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.39.0 ([#1406](https://github.com/googleapis/java-datastore/issues/1406)) ([b265fb3](https://github.com/googleapis/java-datastore/commit/b265fb3c3b8ebc972edbe5a7beae816379846dac)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.30.0 ([#1426](https://github.com/googleapis/java-datastore/issues/1426)) ([ac3a1c1](https://github.com/googleapis/java-datastore/commit/ac3a1c10f64c8338346f8fb39f4857f47e8fc639)) +* Update dependency com.google.errorprone:error_prone_core to v2.27.0 ([#1411](https://github.com/googleapis/java-datastore/issues/1411)) ([a3f5a2c](https://github.com/googleapis/java-datastore/commit/a3f5a2c24bff408479541e08278e888cf3166727)) +* Update dependency com.google.errorprone:error_prone_core to v2.27.1 ([#1421](https://github.com/googleapis/java-datastore/issues/1421)) ([48d7daf](https://github.com/googleapis/java-datastore/commit/48d7dafc0c7a49e95bf41d29865ac872b0de0faf)) +* Update dependency com.google.guava:guava-testlib to v33.2.0-jre ([#1422](https://github.com/googleapis/java-datastore/issues/1422)) ([5a5dfdf](https://github.com/googleapis/java-datastore/commit/5a5dfdfb0855cf485b875ab071b79979d24f98dd)) + ## [2.19.1](https://github.com/googleapis/java-datastore/compare/v2.19.0...v2.19.1) (2024-04-19) diff --git a/README.md b/README.md index 3f6f9916c..160907fc0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: com.google.cloud libraries-bom - 26.38.0 + 26.51.0 pom import @@ -36,13 +36,12 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: If you are using Maven without the BOM, add this to your dependencies: - ```xml com.google.cloud google-cloud-datastore - 2.19.1 + 2.25.0 ``` @@ -50,22 +49,21 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.38.0') +implementation platform('com.google.cloud:libraries-bom:26.52.0') implementation 'com.google.cloud:google-cloud-datastore' ``` If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-datastore:2.19.1' +implementation 'com.google.cloud:google-cloud-datastore:2.25.1' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-datastore" % "2.19.1" +libraryDependencies += "com.google.cloud" % "google-cloud-datastore" % "2.25.1" ``` - ## Authentication @@ -80,7 +78,7 @@ The client application making API calls must be granted [authorization scopes][a ### Prerequisites You will need a [Google Cloud Platform Console][developer-console] project with the Cloud Datastore [API enabled][enable-api]. - +You will need to [enable billing][enable-billing] to use Google Cloud Datastore. [Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by [installing the Google Cloud Command Line Interface][cloud-cli] and running the following commands in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`. @@ -93,11 +91,7 @@ to add `google-cloud-datastore` as a dependency in your code. ## About Cloud Datastore -[Cloud Datastore][product-docs] is a fully managed, schemaless database for -storing non-relational data. Cloud Datastore automatically scales with -your users and supports ACID transactions, high availability of reads and -writes, strong consistency for reads and ancestor queries, and eventual -consistency for all other queries. +[Cloud Datastore][product-docs] is a fully managed, schemaless database for\nstoring non-relational data. Cloud Datastore automatically scales with\nyour users and supports ACID transactions, high availability of reads and\nwrites, strong consistency for reads and ancestor queries, and eventual\nconsistency for all other queries. See the [Cloud Datastore client library docs][javadocs] to learn how to use this Cloud Datastore Client Library. @@ -210,6 +204,140 @@ running on Compute Engine or from your own desktop. To run the example on App En the code from the main method to your application's servlet class and change the print statements to display on your webpage. +gRPC Java Datastore Client User Guide +------- +In this feature launch, the [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance. + +#### Installation Instructions +The client can be built from the `grpc-experimental` branch on GitHub. For private preview, you can also download the artifact with the instructions provided below. + +1. Download the datastore private preview package with dependencies: + ``` + curl -o https://datastore-sdk-feature-release.web.app/google-cloud-datastore-2.20.0-grpc-experimental-1-SNAPSHOT-jar-with-dependencies.jar + ``` +2. Run the following commands to install JDK locally: + ``` + mvn install:install-file -Dfile= -DgroupId=com.google.cloud -DartifactId=google-cloud-datastore -Dversion=2.20.0-grpc + ``` +3. Edit your pom.xml to add above package to `` section: + ```xml + + com.google.cloud + google-cloud-datastore + 2.20.0-grpc-experimental-1-SNAPSHOT + + ``` + +And if you have not yet, add below to `` section: + ```xml + + local-repo + file://${user.home}/.m2/repository + + ``` + +#### How to Use +To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation. + +Example: +```java +DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); +``` +Setting the transport options explicitly to `GrpcTransportOptions` will signal the client to use gRPC instead of HTTP when making calls to the server. + +To revert back to the existing stable behavior and transport, simply remove the transport options line or replace it with `HttpTransportOptions`. Please note this will require an application rebuild and restart. +Example: +```java +// will default to existing HTTP transport behavior +DatastoreOptions datastoreOptions = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .build(); + +// will also default to existing HTTP transport behavior +DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(HttpTransportOptions.newBuilder() + .setConnectTimeout(1000) + .build()).build(); +``` + +Note: client instantiations that already use `setTransportOptions` with `HttpTransportOptions` will continue to have the same behavior. Only transports that are explicitly set to gRPC will change. + +#### Verify Datastore Transport Options Type +To verify which type of TransportOptions you have successfully configured, you can use the below lines of code to compare transport options type: +```java +// checks if using gRPC transport options +boolean isGRPC = datastore.getOptions().getTransportOptions() instanceof GrpcTransportOptions; + +// checks if using HTTP transport options +boolean isHTTP = datastore.getOptions().getTransportOptions() instanceof HTTPTransportOptions; +``` + +#### New Features +There are new gRPC specific features available to use in this update. + +##### Connection Pool +A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client. +To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions. +###### Determine the best connection pool size +The default connection pool size is right for most applications, and in most cases there's no need to change it. + +However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number. + +The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers. + +To calculate the optimal connections, gather the following information: + +1. The maximum number of queries per second (QPS) per client when your application is running a typical workload. +2. The average latency (the response time for a single request) in ms. +3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value. +4. Divide the QPS in seconds by the number of serial requests per second. +5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.) +6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size. + +These steps are expressed in the following equations: +```java +(QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections +(QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections +``` + +###### Example +Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second. +Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization +is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel +pool size for this example should be between 10 and 50 connections. + +It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary. + +###### Set the pool size +The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`. +See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance. + +Code Example +```java +InstantiatingGrpcChannelProvider channelProvider = + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(MIN_VAL) + .setMaxChannelCount(MAX_VAL) + .build()) + .build(); + +DatastoreOptions options = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setChannelProvider(channelProvider) + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); +``` Testing ------- @@ -260,7 +388,6 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-datastore/tre | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | -| Native Image Datastore Sample | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/native-image-sample/src/main/java/com/example/datastore/NativeImageDatastoreSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/native-image-sample/src/main/java/com/example/datastore/NativeImageDatastoreSample.java) | | Quickstart Sample | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/QuickstartSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/QuickstartSample.java) | | Avg Aggregation On Kind | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationOnKind.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationOnKind.java) | | Avg Aggregation With Limit | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithLimit.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithLimit.java) | @@ -279,7 +406,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-datastore/tre | Sum Aggregation With Limit | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.java) | | Sum Aggregation With Order By | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.java) | | Sum Aggregation With Property Filter | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.java) | +| Indexing Consideration Query | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java) | | Create a union between two filters | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.java) | +| Order Fields Query | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java) | | Query Profile Explain | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.java) | | Query Profile Explain Aggregation | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.java) | | Query Profile Explain Analyze | [source code](https://github.com/googleapis/java-datastore/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-datastore&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.java) | @@ -292,6 +421,10 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-datastore/tre To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. +## Transport + +Cloud Datastore uses both gRPC and HTTP/JSON for the transport layer. + ## Supported Java Versions Java 8 or above is required for using this client. @@ -384,7 +517,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-datastore/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-datastore.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-datastore/2.19.1 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-datastore/2.25.1 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles @@ -396,7 +529,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [contributing]: https://github.com/googleapis/java-datastore/blob/main/CONTRIBUTING.md [code-of-conduct]: https://github.com/googleapis/java-datastore/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct [license]: https://github.com/googleapis/java-datastore/blob/main/LICENSE - +[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing [enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=datastore.googleapis.com [libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png diff --git a/datastore-v1-proto-client/pom.xml b/datastore-v1-proto-client/pom.xml index e136a9d8c..f71e20221 100644 --- a/datastore-v1-proto-client/pom.xml +++ b/datastore-v1-proto-client/pom.xml @@ -19,12 +19,12 @@ 4.0.0 com.google.cloud.datastore datastore-v1-proto-client - 2.19.2-SNAPSHOT + 2.25.1 com.google.cloud google-cloud-datastore-parent - 2.19.2-SNAPSHOT + 2.25.1 jar @@ -98,7 +98,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test diff --git a/generation_config.yaml b/generation_config.yaml new file mode 100644 index 000000000..54ff42158 --- /dev/null +++ b/generation_config.yaml @@ -0,0 +1,25 @@ +gapic_generator_version: 2.51.0 +googleapis_commitish: 52e410823122cf44d265c3beecb86c773db248a2 +libraries_bom_version: 26.52.0 +libraries: + - api_shortname: datastore + name_pretty: Cloud Datastore + product_documentation: https://cloud.google.com/datastore + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-datastore/latest/history + issue_tracker: https://issuetracker.google.com/savedsearches/559768 + release_level: stable + language: java + repo: googleapis/java-datastore + repo_short: java-datastore + distribution_name: com.google.cloud:google-cloud-datastore + codeowner_team: '@googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk @googleapis/api-firestore-partners' + api_id: datastore.googleapis.com + library_type: GAPIC_COMBO + api_description: is a fully managed, schemaless database for\nstoring non-relational data. Cloud Datastore automatically scales with\nyour users and supports ACID transactions, high availability of reads and\nwrites, strong consistency for reads and ancestor queries, and eventual\nconsistency for all other queries. + excluded_dependencies: grpc-google-cloud-datastore-v1 + extra_versioned_modules: datastore-v1-proto-client + excluded_poms: grpc-google-cloud-datastore-v1 + recommended_package: com.google.cloud.datastore + GAPICs: + - proto_path: google/datastore/v1 + - proto_path: google/datastore/admin/v1 diff --git a/google-cloud-datastore-bom/pom.xml b/google-cloud-datastore-bom/pom.xml index 2651713e3..c9cfd3347 100644 --- a/google-cloud-datastore-bom/pom.xml +++ b/google-cloud-datastore-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-datastore-bom - 2.19.2-SNAPSHOT + 2.25.1 pom com.google.cloud sdk-platform-java-config - 3.29.0 + 3.41.0 Google Cloud datastore BOM @@ -52,22 +52,22 @@ com.google.cloud google-cloud-datastore - 2.19.2-SNAPSHOT + 2.25.1 com.google.api.grpc grpc-google-cloud-datastore-admin-v1 - 2.19.2-SNAPSHOT + 2.25.1 com.google.api.grpc proto-google-cloud-datastore-v1 - 0.110.2-SNAPSHOT + 0.116.1 com.google.api.grpc proto-google-cloud-datastore-admin-v1 - 2.19.2-SNAPSHOT + 2.25.1 diff --git a/google-cloud-datastore/clirr-ignored-differences.xml b/google-cloud-datastore/clirr-ignored-differences.xml index 1620fd752..6275f05c6 100644 --- a/google-cloud-datastore/clirr-ignored-differences.xml +++ b/google-cloud-datastore/clirr-ignored-differences.xml @@ -55,4 +55,21 @@ java.lang.Object execute(com.google.cloud.datastore.Query, com.google.cloud.datastore.ReadOption[]) 7004 + + com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator + RetryAndTraceDatastoreRpcDecorator(com.google.cloud.datastore.spi.v1.DatastoreRpc, com.google.cloud.datastore.TraceUtil, com.google.api.gax.retrying.RetrySettings, com.google.cloud.datastore.DatastoreOptions) + RetryAndTraceDatastoreRpcDecorator(com.google.cloud.datastore.spi.v1.DatastoreRpc, com.google.cloud.datastore.telemetry.TraceUtil, com.google.api.gax.retrying.RetrySettings, com.google.cloud.datastore.DatastoreOptions) + 7005 + + + + + com/google/cloud/datastore/TraceUtil + 8001 + + + com/google/cloud/datastore/testing/RemoteDatastoreHelper + 8001 + + diff --git a/google-cloud-datastore/pom.xml b/google-cloud-datastore/pom.xml index 8d6b79e8d..6f22c2be2 100644 --- a/google-cloud-datastore/pom.xml +++ b/google-cloud-datastore/pom.xml @@ -2,7 +2,7 @@ 4.0.0 google-cloud-datastore - 2.19.2-SNAPSHOT + 2.25.1 jar Google Cloud Datastore https://github.com/googleapis/java-datastore @@ -12,11 +12,24 @@ com.google.cloud google-cloud-datastore-parent - 2.19.2-SNAPSHOT + 2.25.1 google-cloud-datastore + 1.42.1 + + + + + com.google.cloud + gapic-libraries-bom + 1.48.0 + pom + import + + + com.google.api.grpc @@ -38,6 +51,10 @@ com.google.cloud.datastore datastore-v1-proto-client + + com.google.auth + google-auth-library-credentials + io.grpc grpc-api @@ -111,6 +128,19 @@ jsr305 + + + io.opentelemetry + opentelemetry-api + ${opentelemetry.version} + + + io.opentelemetry + opentelemetry-context + ${opentelemetry.version} + + + ${project.groupId} @@ -118,11 +148,10 @@ test-jar test - com.google.guava guava-testlib - 33.1.0-jre + 33.3.1-jre test @@ -157,9 +186,65 @@ com.google.truth truth - 1.4.2 + 1.4.4 + test + + + com.google.testparameterinjector + test-parameter-injector + 1.17 + test + + + + io.opentelemetry + opentelemetry-sdk + ${opentelemetry.version} + test + + + io.opentelemetry + opentelemetry-sdk-common + ${opentelemetry.version} + test + + + io.opentelemetry + opentelemetry-sdk-testing + ${opentelemetry.version} + test + + + io.opentelemetry + opentelemetry-sdk-trace + ${opentelemetry.version} + test + + + io.opentelemetry + opentelemetry-semconv + 1.1.0-alpha + test + + + + + com.google.cloud.opentelemetry + exporter-trace + 0.15.0 + test + + + com.google.cloud + google-cloud-trace + test + + + com.google.api.grpc + proto-google-cloud-trace-v1 test + diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.java index eb4abd854..882a4db25 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.java @@ -53,9 +53,13 @@ interface Response { /** * {@inheritDoc} * - *

If an entity for {@code entity.getKey()} does not exists, {@code entity} is inserted. + *

If an entity for {@code entity.getKey()} does not exist, {@code entity} is inserted. * Otherwise, {@link #submit()} will throw a {@link DatastoreException} with {@link * DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}. + * + * @param entity the entity to be added to the datastore + * @return The entity that was added + * @throws DatastoreException if there was any failure */ @Override Entity add(FullEntity entity); @@ -67,6 +71,10 @@ interface Response { * exists, {@link #submit()} will throw a {@link DatastoreException} with {@link * DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}. All entities in {@code * entities} whose key did not exist are inserted. + * + * @param entities entities to be added to the datastore + * @return A list of entities that have been added + * @throws DatastoreException if there was any failure */ @Override List add(FullEntity... entities); @@ -74,10 +82,15 @@ interface Response { /** * Submit the batch to the Datastore. * - * @throws DatastoreException if there was any failure or if batch is not longer active + * @return Response of the batch submit operation. + * @throws DatastoreException if there was any failure or if batch is no longer active */ Response submit(); - /** Returns the batch associated {@link Datastore}. */ + /** + * Returns the batch associated {@link Datastore}. + * + * @return The batch associated datastore + */ Datastore getDatastore(); } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Datastore.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Datastore.java index 5bd8384a3..45cecbf25 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Datastore.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Datastore.java @@ -51,6 +51,13 @@ public interface Datastore extends Service, DatastoreReaderWri * @param the type of the return value */ interface TransactionCallable { + /** + * Callback's invoke method for the TransactionCallable. + * + * @param readerWriter DatastoreReaderWriter associated with the new transaction + * @return T The transaction result + * @throws Exception upon failure + */ T run(DatastoreReaderWriter readerWriter) throws Exception; } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java index a3bfb3796..2bf8389fd 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java @@ -16,6 +16,26 @@ package com.google.cloud.datastore; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_DEFERRED; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_DOCUMENT_COUNT; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_MISSING; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_MORE_RESULTS; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_READ_CONSISTENCY; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_RECEIVED; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_TRANSACTIONAL; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_TRANSACTION_ID; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ALLOCATE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_BEGIN_TRANSACTION; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RESERVE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ROLLBACK; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_QUERY; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN_QUERY; + import com.google.api.core.BetaApi; import com.google.api.gax.retrying.RetrySettings; import com.google.cloud.BaseService; @@ -25,20 +45,23 @@ import com.google.cloud.ServiceOptions; import com.google.cloud.datastore.execution.AggregationQueryExecutor; import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.cloud.datastore.telemetry.TraceUtil; +import com.google.cloud.datastore.telemetry.TraceUtil.Scope; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import com.google.common.collect.AbstractIterator; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import com.google.datastore.v1.CommitResponse; import com.google.datastore.v1.ExplainOptions; import com.google.datastore.v1.ReadOptions; import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.RunQueryResponse; import com.google.datastore.v1.TransactionOptions; import com.google.protobuf.ByteString; -import io.opencensus.common.Scope; -import io.opencensus.trace.Span; -import io.opencensus.trace.Status; +import io.opentelemetry.context.Context; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -50,6 +73,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.Callable; +import javax.annotation.Nullable; final class DatastoreImpl extends BaseService implements Datastore { @@ -59,7 +83,9 @@ final class DatastoreImpl extends BaseService implements Datas TransactionExceptionHandler.build(); private static final ExceptionHandler TRANSACTION_OPERATION_EXCEPTION_HANDLER = TransactionOperationExceptionHandler.build(); - private final TraceUtil traceUtil = TraceUtil.getInstance(); + + private final com.google.cloud.datastore.telemetry.TraceUtil otelTraceUtil = + getOptions().getTraceUtil(); private final ReadOptionProtoPreparer readOptionProtoPreparer; private final AggregationQueryExecutor aggregationQueryExecutor; @@ -73,7 +99,8 @@ final class DatastoreImpl extends BaseService implements Datas readOptionProtoPreparer = new ReadOptionProtoPreparer(); aggregationQueryExecutor = new AggregationQueryExecutor( - new RetryAndTraceDatastoreRpcDecorator(datastoreRpc, traceUtil, retrySettings, options), + new RetryAndTraceDatastoreRpcDecorator( + datastoreRpc, otelTraceUtil, retrySettings, options), options); } @@ -92,8 +119,68 @@ public Transaction newTransaction() { return new TransactionImpl(this); } - static class ReadWriteTransactionCallable implements Callable { + static class TracedReadWriteTransactionCallable implements Callable { + private final Datastore datastore; + private final TransactionCallable callable; + private volatile TransactionOptions options; + private volatile Transaction transaction; + + private final TraceUtil.Span parentSpan; + + TracedReadWriteTransactionCallable( + Datastore datastore, + TransactionCallable callable, + TransactionOptions options, + @Nullable com.google.cloud.datastore.telemetry.TraceUtil.Span parentSpan) { + this.datastore = datastore; + this.callable = callable; + this.options = options; + this.transaction = null; + this.parentSpan = parentSpan; + } + + Datastore getDatastore() { + return datastore; + } + + TransactionOptions getOptions() { + return options; + } + + Transaction getTransaction() { + return transaction; + } + + void setPrevTransactionId(ByteString transactionId) { + TransactionOptions.ReadWrite readWrite = + TransactionOptions.ReadWrite.newBuilder().setPreviousTransaction(transactionId).build(); + options = options.toBuilder().setReadWrite(readWrite).build(); + } + + @Override + public T call() throws DatastoreException { + try (io.opentelemetry.context.Scope ignored = + Context.current().with(parentSpan.getSpan()).makeCurrent()) { + transaction = datastore.newTransaction(options); + T value = callable.run(transaction); + transaction.commit(); + return value; + } catch (Exception ex) { + transaction.rollback(); + throw DatastoreException.propagateUserException(ex); + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } + if (options != null + && options.getModeCase().equals(TransactionOptions.ModeCase.READ_WRITE)) { + setPrevTransactionId(transaction.getTransactionId()); + } + } + } + } + static class ReadWriteTransactionCallable implements Callable { private final Datastore datastore; private final TransactionCallable callable; private volatile TransactionOptions options; @@ -127,8 +214,8 @@ void setPrevTransactionId(ByteString transactionId) { @Override public T call() throws DatastoreException { - transaction = datastore.newTransaction(options); try { + transaction = datastore.newTransaction(options); T value = callable.run(transaction); transaction.commit(); return value; @@ -149,36 +236,47 @@ public T call() throws DatastoreException { @Override public T runInTransaction(final TransactionCallable callable) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_TRANSACTION); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + TraceUtil.Span span = otelTraceUtil.startSpan(SPAN_NAME_TRANSACTION_RUN); + Callable transactionCallable = + (getOptions().getOpenTelemetryOptions().isEnabled() + ? new TracedReadWriteTransactionCallable( + this, callable, /*transactionOptions=*/ null, span) + : new ReadWriteTransactionCallable(this, callable, /*transactionOptions=*/ null)); + try (Scope ignored = span.makeCurrent()) { return RetryHelper.runWithRetries( - new ReadWriteTransactionCallable(this, callable, null), + transactionCallable, retrySettings, TRANSACTION_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @Override public T runInTransaction( final TransactionCallable callable, TransactionOptions transactionOptions) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_TRANSACTION); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + TraceUtil.Span span = otelTraceUtil.startSpan(SPAN_NAME_TRANSACTION_RUN); + + Callable transactionCallable = + (getOptions().getOpenTelemetryOptions().isEnabled() + ? new TracedReadWriteTransactionCallable(this, callable, transactionOptions, span) + : new ReadWriteTransactionCallable(this, callable, transactionOptions)); + + try (Scope ignored = span.makeCurrent()) { return RetryHelper.runWithRetries( - new ReadWriteTransactionCallable(this, callable, transactionOptions), + transactionCallable, retrySettings, TRANSACTION_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @@ -236,20 +334,39 @@ public AggregationResults runAggregation( com.google.datastore.v1.RunQueryResponse runQuery( final com.google.datastore.v1.RunQueryRequest requestPb) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_RUNQUERY); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { - return RetryHelper.runWithRetries( - () -> datastoreRpc.runQuery(requestPb), - retrySettings, - requestPb.getReadOptions().getTransaction().isEmpty() - ? EXCEPTION_HANDLER - : TRANSACTION_OPERATION_EXCEPTION_HANDLER, - getOptions().getClock()); + ReadOptions readOptions = requestPb.getReadOptions(); + boolean isTransactional = readOptions.hasTransaction() || readOptions.hasNewTransaction(); + String spanName = (isTransactional ? SPAN_NAME_TRANSACTION_RUN_QUERY : SPAN_NAME_RUN_QUERY); + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(spanName); + + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + RunQueryResponse response = + RetryHelper.runWithRetries( + () -> datastoreRpc.runQuery(requestPb), + retrySettings, + requestPb.getReadOptions().getTransaction().isEmpty() + ? EXCEPTION_HANDLER + : TRANSACTION_OPERATION_EXCEPTION_HANDLER, + getOptions().getClock()); + span.addEvent( + spanName + " complete.", + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, response.getBatch().getEntityResultsCount()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, isTransactional) + .put(ATTRIBUTES_KEY_READ_CONSISTENCY, readOptions.getReadConsistency().toString()) + .put( + ATTRIBUTES_KEY_TRANSACTION_ID, + (isTransactional + ? requestPb.getReadOptions().getTransaction().toStringUtf8() + : "")) + .put(ATTRIBUTES_KEY_MORE_RESULTS, response.getBatch().getMoreResults().toString()) + .build()); + return response; } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @@ -291,8 +408,9 @@ public List allocateId(IncompleteKey... keys) { private com.google.datastore.v1.AllocateIdsResponse allocateIds( final com.google.datastore.v1.AllocateIdsRequest requestPb) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_ALLOCATEIDS); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_ALLOCATE_IDS); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { return RetryHelper.runWithRetries( new Callable() { @Override @@ -304,10 +422,10 @@ public com.google.datastore.v1.AllocateIdsResponse call() throws DatastoreExcept EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @@ -450,14 +568,27 @@ protected Entity computeNext() { com.google.datastore.v1.LookupResponse lookup( final com.google.datastore.v1.LookupRequest requestPb) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_LOOKUP); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + ReadOptions readOptions = requestPb.getReadOptions(); + boolean isTransactional = readOptions.hasTransaction() || readOptions.hasNewTransaction(); + String spanName = (isTransactional ? SPAN_NAME_TRANSACTION_LOOKUP : SPAN_NAME_LOOKUP); + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(spanName); + + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { return RetryHelper.runWithRetries( - new Callable() { - @Override - public com.google.datastore.v1.LookupResponse call() throws DatastoreException { - return datastoreRpc.lookup(requestPb); - } + () -> { + com.google.datastore.v1.LookupResponse response = datastoreRpc.lookup(requestPb); + span.addEvent( + spanName + " complete.", + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_RECEIVED, response.getFoundCount()) + .put(ATTRIBUTES_KEY_MISSING, response.getMissingCount()) + .put(ATTRIBUTES_KEY_DEFERRED, response.getDeferredCount()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, isTransactional) + .put( + ATTRIBUTES_KEY_TRANSACTION_ID, + isTransactional ? readOptions.getTransaction().toStringUtf8() : "") + .build()); + return response; }, retrySettings, requestPb.getReadOptions().getTransaction().isEmpty() @@ -465,10 +596,10 @@ public com.google.datastore.v1.LookupResponse call() throws DatastoreException { : TRANSACTION_OPERATION_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @@ -492,8 +623,9 @@ public List reserveIds(Key... keys) { com.google.datastore.v1.ReserveIdsResponse reserveIds( final com.google.datastore.v1.ReserveIdsRequest requestPb) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_RESERVEIDS); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_RESERVE_IDS); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { return RetryHelper.runWithRetries( new Callable() { @Override @@ -505,10 +637,10 @@ public com.google.datastore.v1.ReserveIdsResponse call() throws DatastoreExcepti EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @@ -602,20 +734,34 @@ private com.google.datastore.v1.CommitResponse commitMutation( com.google.datastore.v1.CommitResponse commit( final com.google.datastore.v1.CommitRequest requestPb) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_COMMIT); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { - return RetryHelper.runWithRetries( - () -> datastoreRpc.commit(requestPb), - retrySettings, - requestPb.getTransaction().isEmpty() - ? EXCEPTION_HANDLER - : TRANSACTION_OPERATION_EXCEPTION_HANDLER, - getOptions().getClock()); + final boolean isTransactional = + requestPb.hasTransaction() || requestPb.hasSingleUseTransaction(); + final String spanName = isTransactional ? SPAN_NAME_TRANSACTION_COMMIT : SPAN_NAME_COMMIT; + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(spanName); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + CommitResponse response = + RetryHelper.runWithRetries( + () -> datastoreRpc.commit(requestPb), + retrySettings, + requestPb.getTransaction().isEmpty() + ? EXCEPTION_HANDLER + : TRANSACTION_OPERATION_EXCEPTION_HANDLER, + getOptions().getClock()); + span.addEvent( + spanName + " complete.", + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, response.getMutationResultsCount()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, isTransactional) + .put( + ATTRIBUTES_KEY_TRANSACTION_ID, + isTransactional ? requestPb.getTransaction().toStringUtf8() : "") + .build()); + return response; } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @@ -626,24 +772,19 @@ ByteString requestTransactionId( com.google.datastore.v1.BeginTransactionResponse beginTransaction( final com.google.datastore.v1.BeginTransactionRequest requestPb) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_BEGINTRANSACTION); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_BEGIN_TRANSACTION); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope scope = span.makeCurrent()) { return RetryHelper.runWithRetries( - new Callable() { - @Override - public com.google.datastore.v1.BeginTransactionResponse call() - throws DatastoreException { - return datastoreRpc.beginTransaction(requestPb); - } - }, + () -> datastoreRpc.beginTransaction(requestPb), retrySettings, EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } @@ -657,8 +798,9 @@ void rollbackTransaction(ByteString transaction) { } void rollback(final com.google.datastore.v1.RollbackRequest requestPb) { - Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_ROLLBACK); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_ROLLBACK); + try (Scope scope = span.makeCurrent()) { RetryHelper.runWithRetries( new Callable() { @Override @@ -670,11 +812,16 @@ public Void call() throws DatastoreException { retrySettings, EXCEPTION_HANDLER, getOptions().getClock()); + span.addEvent( + SPAN_NAME_ROLLBACK, + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_TRANSACTION_ID, requestPb.getTransaction().toStringUtf8()) + .build()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOpenTelemetryOptions.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOpenTelemetryOptions.java new file mode 100644 index 000000000..ac266562e --- /dev/null +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOpenTelemetryOptions.java @@ -0,0 +1,97 @@ +/* + * Copyright 2024 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.cloud.datastore; + +import io.opentelemetry.api.OpenTelemetry; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class DatastoreOpenTelemetryOptions { + private final boolean enabled; + private final @Nullable OpenTelemetry openTelemetry; + + DatastoreOpenTelemetryOptions(Builder builder) { + this.enabled = builder.enabled; + this.openTelemetry = builder.openTelemetry; + } + + public boolean isEnabled() { + return enabled; + } + + @Nullable + public OpenTelemetry getOpenTelemetry() { + return openTelemetry; + } + + @Nonnull + public DatastoreOpenTelemetryOptions.Builder toBuilder() { + return new DatastoreOpenTelemetryOptions.Builder(this); + } + + @Nonnull + public static DatastoreOpenTelemetryOptions.Builder newBuilder() { + return new DatastoreOpenTelemetryOptions.Builder(); + } + + public static class Builder { + + private boolean enabled; + + @Nullable private OpenTelemetry openTelemetry; + + private Builder() { + enabled = false; + openTelemetry = null; + } + + private Builder(DatastoreOpenTelemetryOptions options) { + this.enabled = options.enabled; + this.openTelemetry = options.openTelemetry; + } + + @Nonnull + public DatastoreOpenTelemetryOptions build() { + return new DatastoreOpenTelemetryOptions(this); + } + + /** + * Sets whether tracing should be enabled. + * + * @param enabled Whether tracing should be enabled. + */ + @Nonnull + public DatastoreOpenTelemetryOptions.Builder setTracingEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Sets the {@link OpenTelemetry} to use with this Datastore instance. If telemetry collection + * is enabled, but an `OpenTelemetry` is not provided, the Datastore SDK will attempt to use the + * `GlobalOpenTelemetry`. + * + * @param openTelemetry The OpenTelemetry that should be used by this Datastore instance. + */ + @Nonnull + public DatastoreOpenTelemetryOptions.Builder setOpenTelemetry( + @Nonnull OpenTelemetry openTelemetry) { + this.openTelemetry = openTelemetry; + return this; + } + } +} diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java index 8437c3e22..cef40eedd 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java @@ -18,6 +18,7 @@ import static com.google.cloud.datastore.Validator.validateNamespace; +import com.google.api.core.BetaApi; import com.google.cloud.ServiceDefaults; import com.google.cloud.ServiceOptions; import com.google.cloud.ServiceRpc; @@ -31,6 +32,8 @@ import java.lang.reflect.Method; import java.util.Objects; import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class DatastoreOptions extends ServiceOptions { @@ -43,6 +46,9 @@ public class DatastoreOptions extends ServiceOptions { private String namespace; private String databaseId; + @Nullable private DatastoreOpenTelemetryOptions openTelemetryOptions = null; + private Builder() {} private Builder(DatastoreOptions options) { super(options); namespace = options.namespace; databaseId = options.databaseId; + this.openTelemetryOptions = options.openTelemetryOptions; } @Override @@ -100,10 +120,30 @@ public Builder setDatabaseId(String databaseId) { this.databaseId = databaseId; return this; } + + /** + * Sets the {@link DatastoreOpenTelemetryOptions} to be used for this Firestore instance. + * + * @param openTelemetryOptions The `DatastoreOpenTelemetryOptions` to use. + */ + @BetaApi + @Nonnull + public Builder setOpenTelemetryOptions( + @Nonnull DatastoreOpenTelemetryOptions openTelemetryOptions) { + this.openTelemetryOptions = openTelemetryOptions; + return this; + } } private DatastoreOptions(Builder builder) { super(DatastoreFactory.class, DatastoreRpcFactory.class, builder, new DatastoreDefaults()); + + this.openTelemetryOptions = + builder.openTelemetryOptions != null + ? builder.openTelemetryOptions + : DatastoreOpenTelemetryOptions.newBuilder().build(); + this.traceUtil = com.google.cloud.datastore.telemetry.TraceUtil.getInstance(this); + namespace = MoreObjects.firstNonNull(builder.namespace, defaultNamespace()); databaseId = MoreObjects.firstNonNull(builder.databaseId, DEFAULT_DATABASE_ID); } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/IncompleteKey.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/IncompleteKey.java index db9973cb5..71e31b94d 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/IncompleteKey.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/IncompleteKey.java @@ -91,9 +91,11 @@ public Key getParent() { PathElement parent = ancestors.get(ancestors.size() - 1); Key.Builder keyBuilder; if (parent.hasName()) { - keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getName()); + keyBuilder = + Key.newBuilder(getProjectId(), parent.getKind(), parent.getName(), getDatabaseId()); } else { - keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getId()); + keyBuilder = + Key.newBuilder(getProjectId(), parent.getKind(), parent.getId(), getDatabaseId()); } String namespace = getNamespace(); if (namespace != null) { diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Key.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Key.java index 9e851d0cb..14fe264bb 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Key.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Key.java @@ -145,7 +145,7 @@ public Object getNameOrId() { /** Returns the key in an encoded form that can be used as part of a URL. */ public String toUrlSafe() { try { - return URLEncoder.encode(TextFormat.printToString(toPb()), UTF_8.name()); + return URLEncoder.encode(TextFormat.printer().printToString(toPb()), UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("Unexpected encoding exception", e); } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator.java index c4a85caab..e1ea6e8dd 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator.java @@ -16,13 +16,13 @@ package com.google.cloud.datastore; import static com.google.cloud.BaseService.EXCEPTION_HANDLER; -import static com.google.cloud.datastore.TraceUtil.SPAN_NAME_RUN_AGGREGATION_QUERY; import com.google.api.core.InternalApi; import com.google.api.gax.retrying.RetrySettings; import com.google.cloud.RetryHelper; import com.google.cloud.RetryHelper.RetryHelperException; import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.cloud.datastore.telemetry.TraceUtil; import com.google.datastore.v1.AllocateIdsRequest; import com.google.datastore.v1.AllocateIdsResponse; import com.google.datastore.v1.BeginTransactionRequest; @@ -31,6 +31,7 @@ import com.google.datastore.v1.CommitResponse; import com.google.datastore.v1.LookupRequest; import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReadOptions; import com.google.datastore.v1.ReserveIdsRequest; import com.google.datastore.v1.ReserveIdsResponse; import com.google.datastore.v1.RollbackRequest; @@ -39,9 +40,6 @@ import com.google.datastore.v1.RunAggregationQueryResponse; import com.google.datastore.v1.RunQueryRequest; import com.google.datastore.v1.RunQueryResponse; -import io.opencensus.common.Scope; -import io.opencensus.trace.Span; -import io.opencensus.trace.Status; import java.util.concurrent.Callable; /** @@ -52,19 +50,19 @@ public class RetryAndTraceDatastoreRpcDecorator implements DatastoreRpc { private final DatastoreRpc datastoreRpc; - private final TraceUtil traceUtil; + private final com.google.cloud.datastore.telemetry.TraceUtil otelTraceUtil; private final RetrySettings retrySettings; private final DatastoreOptions datastoreOptions; public RetryAndTraceDatastoreRpcDecorator( DatastoreRpc datastoreRpc, - TraceUtil traceUtil, + TraceUtil otelTraceUtil, RetrySettings retrySettings, DatastoreOptions datastoreOptions) { this.datastoreRpc = datastoreRpc; - this.traceUtil = traceUtil; this.retrySettings = retrySettings; this.datastoreOptions = datastoreOptions; + this.otelTraceUtil = otelTraceUtil; } @Override @@ -105,20 +103,26 @@ public RunQueryResponse runQuery(RunQueryRequest request) { @Override public RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request) { - return invokeRpc( - () -> datastoreRpc.runAggregationQuery(request), SPAN_NAME_RUN_AGGREGATION_QUERY); + ReadOptions readOptions = request.getReadOptions(); + boolean isTransactional = readOptions.hasTransaction() || readOptions.hasNewTransaction(); + String spanName = + (isTransactional + ? com.google.cloud.datastore.telemetry.TraceUtil + .SPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY + : com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_AGGREGATION_QUERY); + return invokeRpc(() -> datastoreRpc.runAggregationQuery(request), spanName); } public O invokeRpc(Callable block, String startSpan) { - Span span = traceUtil.startSpan(startSpan); - try (Scope scope = traceUtil.getTracer().withSpan(span)) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(startSpan); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { return RetryHelper.runWithRetries( block, this.retrySettings, EXCEPTION_HANDLER, this.datastoreOptions.getClock()); } catch (RetryHelperException e) { - span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); + span.end(e); throw DatastoreException.translateAndThrow(e); } finally { - span.end(TraceUtil.END_SPAN_OPTIONS); + span.end(); } } } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TraceUtil.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TraceUtil.java deleted file mode 100644 index 57525d15d..000000000 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TraceUtil.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2020 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.cloud.datastore; - -import com.google.cloud.datastore.spi.v1.HttpDatastoreRpc; -import io.opencensus.trace.EndSpanOptions; -import io.opencensus.trace.Span; -import io.opencensus.trace.Tracer; -import io.opencensus.trace.Tracing; - -/** - * Helper class for tracing utility. It is used for instrumenting {@link HttpDatastoreRpc} with - * OpenCensus APIs. - * - *

TraceUtil instances are created by the {@link TraceUtil#getInstance()} method. - */ -public class TraceUtil { - private final Tracer tracer = Tracing.getTracer(); - private static final TraceUtil traceUtil = new TraceUtil(); - static final String SPAN_NAME_ALLOCATEIDS = "CloudDatastoreOperation.allocateIds"; - static final String SPAN_NAME_TRANSACTION = "CloudDatastoreOperation.readWriteTransaction"; - static final String SPAN_NAME_BEGINTRANSACTION = "CloudDatastoreOperation.beginTransaction"; - static final String SPAN_NAME_COMMIT = "CloudDatastoreOperation.commit"; - static final String SPAN_NAME_LOOKUP = "CloudDatastoreOperation.lookup"; - static final String SPAN_NAME_RESERVEIDS = "CloudDatastoreOperation.reserveIds"; - static final String SPAN_NAME_ROLLBACK = "CloudDatastoreOperation.rollback"; - static final String SPAN_NAME_RUNQUERY = "CloudDatastoreOperation.runQuery"; - static final String SPAN_NAME_RUN_AGGREGATION_QUERY = - "CloudDatastoreOperation.runAggregationQuery"; - static final EndSpanOptions END_SPAN_OPTIONS = - EndSpanOptions.builder().setSampleToLocalSpanStore(true).build(); - - /** - * Starts a new span. - * - * @param spanName The name of the returned Span. - * @return The newly created {@link Span}. - */ - protected Span startSpan(String spanName) { - return tracer.spanBuilder(spanName).startSpan(); - } - - /** - * Return the global {@link Tracer}. - * - * @return The global {@link Tracer}. - */ - public Tracer getTracer() { - return tracer; - } - - /** - * Return TraceUtil Object. - * - * @return An instance of {@link TraceUtil} - */ - public static TraceUtil getInstance() { - return traceUtil; - } - - private TraceUtil() {} -} diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionImpl.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionImpl.java index f08a908ec..e730db81f 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionImpl.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionImpl.java @@ -20,6 +20,7 @@ import com.google.api.core.BetaApi; import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.telemetry.TraceUtil; import com.google.common.collect.ImmutableList; import com.google.datastore.v1.ReadOptions; import com.google.datastore.v1.TransactionOptions; @@ -28,6 +29,7 @@ import java.util.Iterator; import java.util.List; import java.util.Optional; +import javax.annotation.Nonnull; final class TransactionImpl extends BaseDatastoreBatchWriter implements Transaction { @@ -37,6 +39,8 @@ final class TransactionImpl extends BaseDatastoreBatchWriter implements Transact private final ReadOptionProtoPreparer readOptionProtoPreparer; + @Nonnull private final TraceUtil traceUtil; + static class ResponseImpl implements Transaction.Response { private final com.google.datastore.v1.CommitResponse response; @@ -78,6 +82,7 @@ public List getGeneratedKeys() { transactionId = datastore.requestTransactionId(requestPb); this.readOptionProtoPreparer = new ReadOptionProtoPreparer(); + this.traceUtil = datastore.getOptions().getTraceUtil(); } @Override diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java index 4bae1f6f3..4db454e20 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java @@ -65,7 +65,9 @@ *

The builder of this class is recursive, so contained classes are themselves builders. When * build() is called, the tree of builders is called to create the complete settings object. * - *

For example, to set the total timeout of getIndex to 30 seconds: + *

For example, to set the + * [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) + * of getIndex: * *

{@code
  * // This snippet has been automatically generated and should be regarded as a code template only.
@@ -82,10 +84,47 @@
  *             .getIndexSettings()
  *             .getRetrySettings()
  *             .toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .setInitialRetryDelayDuration(Duration.ofSeconds(1))
+ *             .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
+ *             .setMaxAttempts(5)
+ *             .setMaxRetryDelayDuration(Duration.ofSeconds(30))
+ *             .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
+ *             .setRetryDelayMultiplier(1.3)
+ *             .setRpcTimeoutMultiplier(1.5)
+ *             .setTotalTimeoutDuration(Duration.ofSeconds(300))
  *             .build());
  * DatastoreAdminSettings datastoreAdminSettings = datastoreAdminSettingsBuilder.build();
  * }
+ * + * Please refer to the [Client Side Retry + * Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for + * additional support in setting retries. + * + *

To configure the RetrySettings of a Long Running Operation method, create an + * OperationTimedPollAlgorithm object and update the RPC's polling algorithm. For example, to + * configure the RetrySettings for exportEntities: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreAdminSettings.Builder datastoreAdminSettingsBuilder =
+ *     DatastoreAdminSettings.newBuilder();
+ * TimedRetryAlgorithm timedRetryAlgorithm =
+ *     OperationalTimedPollAlgorithm.create(
+ *         RetrySettings.newBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofMillis(500))
+ *             .setRetryDelayMultiplier(1.5)
+ *             .setMaxRetryDelayDuration(Duration.ofMillis(5000))
+ *             .setTotalTimeoutDuration(Duration.ofHours(24))
+ *             .build());
+ * datastoreAdminSettingsBuilder
+ *     .createClusterOperationSettings()
+ *     .setPollingAlgorithm(timedRetryAlgorithm)
+ *     .build();
+ * }
*/ @Generated("by gapic-generator-java") public class DatastoreAdminSettings extends ClientSettings { diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java index 64ad035d8..aa10d582f 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java @@ -21,6 +21,7 @@ import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; @@ -66,9 +67,9 @@ import com.google.longrunning.Operation; import com.google.protobuf.Empty; import java.io.IOException; +import java.time.Duration; import java.util.List; import javax.annotation.Generated; -import org.threeten.bp.Duration; // AUTO-GENERATED DOCUMENTATION AND CLASS. /** @@ -85,7 +86,9 @@ *

The builder of this class is recursive, so contained classes are themselves builders. When * build() is called, the tree of builders is called to create the complete settings object. * - *

For example, to set the total timeout of getIndex to 30 seconds: + *

For example, to set the + * [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) + * of getIndex: * *

{@code
  * // This snippet has been automatically generated and should be regarded as a code template only.
@@ -102,10 +105,47 @@
  *             .getIndexSettings()
  *             .getRetrySettings()
  *             .toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .setInitialRetryDelayDuration(Duration.ofSeconds(1))
+ *             .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
+ *             .setMaxAttempts(5)
+ *             .setMaxRetryDelayDuration(Duration.ofSeconds(30))
+ *             .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
+ *             .setRetryDelayMultiplier(1.3)
+ *             .setRpcTimeoutMultiplier(1.5)
+ *             .setTotalTimeoutDuration(Duration.ofSeconds(300))
  *             .build());
  * DatastoreAdminStubSettings datastoreAdminSettings = datastoreAdminSettingsBuilder.build();
  * }
+ * + * Please refer to the [Client Side Retry + * Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for + * additional support in setting retries. + * + *

To configure the RetrySettings of a Long Running Operation method, create an + * OperationTimedPollAlgorithm object and update the RPC's polling algorithm. For example, to + * configure the RetrySettings for exportEntities: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreAdminStubSettings.Builder datastoreAdminSettingsBuilder =
+ *     DatastoreAdminStubSettings.newBuilder();
+ * TimedRetryAlgorithm timedRetryAlgorithm =
+ *     OperationalTimedPollAlgorithm.create(
+ *         RetrySettings.newBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofMillis(500))
+ *             .setRetryDelayMultiplier(1.5)
+ *             .setMaxRetryDelayDuration(Duration.ofMillis(5000))
+ *             .setTotalTimeoutDuration(Duration.ofHours(24))
+ *             .build());
+ * datastoreAdminSettingsBuilder
+ *     .createClusterOperationSettings()
+ *     .setPollingAlgorithm(timedRetryAlgorithm)
+ *     .build();
+ * }
*/ @Generated("by gapic-generator-java") public class DatastoreAdminStubSettings extends StubSettings { @@ -163,9 +203,7 @@ public String extractNextToken(ListIndexesResponse payload) { @Override public Iterable extractResources(ListIndexesResponse payload) { - return payload.getIndexesList() == null - ? ImmutableList.of() - : payload.getIndexesList(); + return payload.getIndexesList(); } }; @@ -258,15 +296,6 @@ public DatastoreAdminStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -279,6 +308,7 @@ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuild } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "datastore.googleapis.com:443"; } @@ -419,21 +449,21 @@ public static class Builder extends StubSettings.Builder getIndexSettings() { return listIndexesSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public DatastoreAdminStubSettings build() throws IOException { return new DatastoreAdminStubSettings(this); diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java index 52184a01a..6738d84e3 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java @@ -15,25 +15,27 @@ */ package com.google.cloud.datastore.models; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; + import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.cloud.Structs; import com.google.common.base.Objects; import java.util.Map; -import org.threeten.bp.Duration; /** Model class for {@link com.google.datastore.v1.ExecutionStats} */ @BetaApi public class ExecutionStats { private final long resultsReturned; - private final Duration executionDuration; + private final java.time.Duration executionDuration; private final long readOperations; private final Map debugStats; @InternalApi public ExecutionStats(com.google.datastore.v1.ExecutionStats proto) { this.resultsReturned = proto.getResultsReturned(); - this.executionDuration = Duration.ofNanos(proto.getExecutionDuration().getNanos()); + this.executionDuration = java.time.Duration.ofNanos(proto.getExecutionDuration().getNanos()); this.readOperations = proto.getReadOperations(); this.debugStats = Structs.asMap(proto.getDebugStats()); } @@ -51,8 +53,14 @@ public Map getDebugStats() { return debugStats; } + /** This method is obsolete. Use {@link #getExecutionDurationJavaTime()} instead. */ + @ObsoleteApi("Use getExecutionDurationJavaTime() instead") + public org.threeten.bp.Duration getExecutionDuration() { + return toThreetenDuration(getExecutionDurationJavaTime()); + } + /** Returns the total time to execute the query in the backend. */ - public Duration getExecutionDuration() { + public java.time.Duration getExecutionDurationJavaTime() { return executionDuration; } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.java index fd3cdc658..d927a2d7f 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.java @@ -21,7 +21,6 @@ import com.google.api.client.http.HttpTransport; import com.google.cloud.datastore.DatastoreException; import com.google.cloud.datastore.DatastoreOptions; -import com.google.cloud.datastore.TraceUtil; import com.google.cloud.http.CensusHttpModule; import com.google.cloud.http.HttpTransportOptions; import com.google.datastore.v1.AllocateIdsRequest; @@ -40,6 +39,7 @@ import com.google.datastore.v1.RunAggregationQueryResponse; import com.google.datastore.v1.RunQueryRequest; import com.google.datastore.v1.RunQueryResponse; +import io.opencensus.trace.Tracing; import java.io.IOException; import java.net.InetAddress; import java.net.URL; @@ -80,8 +80,7 @@ public HttpDatastoreRpc(DatastoreOptions options) { private HttpRequestInitializer getHttpRequestInitializer( final DatastoreOptions options, HttpTransportOptions httpTransportOptions) { // Open Census initialization - CensusHttpModule censusHttpModule = - new CensusHttpModule(TraceUtil.getInstance().getTracer(), true); + CensusHttpModule censusHttpModule = new CensusHttpModule(Tracing.getTracer(), true); final HttpRequestInitializer censusHttpModuleHttpRequestInitializer = censusHttpModule.getHttpRequestInitializer( httpTransportOptions.getHttpRequestInitializer(options)); diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/DisabledTraceUtil.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/DisabledTraceUtil.java new file mode 100644 index 000000000..ebb630515 --- /dev/null +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/DisabledTraceUtil.java @@ -0,0 +1,131 @@ +/* + * Copyright 2024 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.cloud.datastore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.telemetry.TraceUtil.Context; +import io.grpc.ManagedChannelBuilder; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanBuilder; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.api.trace.TracerProvider; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Tracing utility implementation, used to stub out tracing instrumentation when tracing is + * disabled. + */ +@InternalApi +public class DisabledTraceUtil implements TraceUtil { + static class Span implements TraceUtil.Span { + @Override + public void end() {} + + @Override + public void end(Throwable error) {} + + @Override + public void endAtFuture(ApiFuture futureValue) {} + + @Override + public TraceUtil.Span addEvent(String name) { + return this; + } + + @Override + public TraceUtil.Span addEvent(String name, Map attributes) { + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, int value) { + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, String value) { + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, boolean value) { + return this; + } + + public io.opentelemetry.api.trace.Span getSpan() { + return null; + } + + @Override + public Scope makeCurrent() { + return new Scope(); + } + } + + static class Context implements TraceUtil.Context { + @Override + public Scope makeCurrent() { + return new Scope(); + } + } + + static class Scope implements TraceUtil.Scope { + @Override + public void close() {} + } + + @Nullable + @Override + public ApiFunction getChannelConfigurator() { + return null; + } + + @Override + public Span startSpan(String spanName) { + return new Span(); + } + + @Override + public TraceUtil.Span startSpan(String spanName, TraceUtil.Span parentSpan) { + return new Span(); + } + + public SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder) { + return getTracer().spanBuilder("TRACING_DISABLED_NO_OP"); + } + + @Nonnull + @Override + public TraceUtil.Span getCurrentSpan() { + return new Span(); + } + + @Nonnull + @Override + public TraceUtil.Context getCurrentContext() { + return new Context(); + } + + @Override + public Tracer getTracer() { + return TracerProvider.noop().get(LIBRARY_NAME); + } +} diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/EnabledTraceUtil.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/EnabledTraceUtil.java new file mode 100644 index 000000000..40fc7308e --- /dev/null +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/EnabledTraceUtil.java @@ -0,0 +1,323 @@ +/* + * Copyright 2024 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.cloud.datastore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutureCallback; +import com.google.api.core.ApiFutures; +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.telemetry.TraceUtil.Context; +import com.google.cloud.datastore.telemetry.TraceUtil.Scope; +import com.google.cloud.datastore.telemetry.TraceUtil.Span; +import com.google.common.base.Throwables; +import io.grpc.ManagedChannelBuilder; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.api.trace.SpanBuilder; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.api.trace.StatusCode; +import io.opentelemetry.api.trace.Tracer; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Tracing utility implementation, used to stub out tracing instrumentation when tracing is enabled. + */ +@InternalApi +public class EnabledTraceUtil implements TraceUtil { + private final Tracer tracer; + private final OpenTelemetry openTelemetry; + private final DatastoreOptions datastoreOptions; + + EnabledTraceUtil(DatastoreOptions datastoreOptions) { + OpenTelemetry openTelemetry = datastoreOptions.getOpenTelemetryOptions().getOpenTelemetry(); + + // If tracing is enabled, but an OpenTelemetry instance is not provided, fall back + // to using GlobalOpenTelemetry. + if (openTelemetry == null) { + openTelemetry = GlobalOpenTelemetry.get(); + } + + this.datastoreOptions = datastoreOptions; + this.openTelemetry = openTelemetry; + this.tracer = openTelemetry.getTracer(LIBRARY_NAME); + } + + public OpenTelemetry getOpenTelemetry() { + return openTelemetry; + } + + @Override + @Nullable + public ApiFunction getChannelConfigurator() { + // TODO(jimit) Update this to return a gRPC Channel Configurator after gRPC upgrade. + return null; + } + + static class Span implements TraceUtil.Span { + private final io.opentelemetry.api.trace.Span span; + private final String spanName; + + public Span(io.opentelemetry.api.trace.Span span, String spanName) { + this.span = span; + this.spanName = spanName; + } + + @Override + public io.opentelemetry.api.trace.Span getSpan() { + return this.span; + } + + /** Ends this span. */ + @Override + public void end() { + span.end(); + } + + /** Ends this span in an error. */ + @Override + public void end(Throwable error) { + span.setStatus(StatusCode.ERROR, error.getMessage()); + span.recordException( + error, + Attributes.builder() + .put("exception.message", error.getMessage()) + .put("exception.type", error.getClass().getName()) + .put("exception.stacktrace", Throwables.getStackTraceAsString(error)) + .build()); + span.end(); + } + + /** + * If an operation ends in the future, its relevant span should end _after_ the future has been + * completed. This method "appends" the span completion code at the completion of the given + * future. In order for telemetry info to be recorded, the future returned by this method should + * be completed. + */ + @Override + public void endAtFuture(ApiFuture futureValue) { + io.opentelemetry.context.Context asyncContext = io.opentelemetry.context.Context.current(); + ApiFutures.addCallback( + futureValue, + new ApiFutureCallback() { + @Override + public void onFailure(Throwable t) { + try (io.opentelemetry.context.Scope scope = asyncContext.makeCurrent()) { + span.addEvent(spanName + " failed."); + end(t); + } + } + + @Override + public void onSuccess(T result) { + try (io.opentelemetry.context.Scope scope = asyncContext.makeCurrent()) { + span.addEvent(spanName + " succeeded."); + end(); + } + } + }); + } + + /** Adds the given event to this span. */ + @Override + public TraceUtil.Span addEvent(String name) { + span.addEvent(name); + return this; + } + + @Override + public TraceUtil.Span addEvent(String name, Map attributes) { + AttributesBuilder attributesBuilder = Attributes.builder(); + attributes.forEach( + (key, value) -> { + if (value instanceof Integer) { + attributesBuilder.put(key, (int) value); + } else if (value instanceof Long) { + attributesBuilder.put(key, (long) value); + } else if (value instanceof Double) { + attributesBuilder.put(key, (double) value); + } else if (value instanceof Float) { + attributesBuilder.put(key, (float) value); + } else if (value instanceof Boolean) { + attributesBuilder.put(key, (boolean) value); + } else if (value instanceof String) { + attributesBuilder.put(key, (String) value); + } else { + // OpenTelemetry APIs do not support any other type. + throw new IllegalArgumentException( + "Unknown attribute type:" + value.getClass().getSimpleName()); + } + }); + span.addEvent(name, attributesBuilder.build()); + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, int value) { + span.setAttribute(ATTRIBUTE_SERVICE_PREFIX + key, value); + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, String value) { + span.setAttribute(ATTRIBUTE_SERVICE_PREFIX + key, value); + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, boolean value) { + span.setAttribute(ATTRIBUTE_SERVICE_PREFIX + key, value); + return this; + } + + @Override + public Scope makeCurrent() { + try (io.opentelemetry.context.Scope scope = span.makeCurrent()) { + return new Scope(scope); + } + } + } + + static class Scope implements TraceUtil.Scope { + private final io.opentelemetry.context.Scope scope; + + Scope(io.opentelemetry.context.Scope scope) { + this.scope = scope; + } + + @Override + public void close() { + scope.close(); + } + } + + static class Context implements TraceUtil.Context { + private final io.opentelemetry.context.Context context; + + Context(io.opentelemetry.context.Context context) { + this.context = context; + } + + @Override + public Scope makeCurrent() { + try (io.opentelemetry.context.Scope scope = context.makeCurrent()) { + return new Scope(scope); + } + } + } + + /** Applies the current Datastore instance settings as attributes to the current Span */ + @Override + public SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder) { + spanBuilder = + spanBuilder.setAllAttributes( + Attributes.builder() + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.databaseId", + datastoreOptions.getDatabaseId()) + .put(ATTRIBUTE_SERVICE_PREFIX + "settings.host", datastoreOptions.getHost()) + .build()); + + if (datastoreOptions.getCredentials() != null) { + spanBuilder = + spanBuilder.setAttribute( + ATTRIBUTE_SERVICE_PREFIX + "settings.credentials.authenticationType", + datastoreOptions.getCredentials().getAuthenticationType()); + } + + if (datastoreOptions.getRetrySettings() != null) { + spanBuilder = + spanBuilder.setAllAttributes( + Attributes.builder() + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.initialRetryDelay", + datastoreOptions.getRetrySettings().getInitialRetryDelay().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.maxRetryDelay", + datastoreOptions.getRetrySettings().getMaxRetryDelay().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.retryDelayMultiplier", + String.valueOf(datastoreOptions.getRetrySettings().getRetryDelayMultiplier())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.maxAttempts", + String.valueOf(datastoreOptions.getRetrySettings().getMaxAttempts())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.initialRpcTimeout", + datastoreOptions.getRetrySettings().getInitialRpcTimeout().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.maxRpcTimeout", + datastoreOptions.getRetrySettings().getMaxRpcTimeout().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.rpcTimeoutMultiplier", + String.valueOf(datastoreOptions.getRetrySettings().getRpcTimeoutMultiplier())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.totalTimeout", + datastoreOptions.getRetrySettings().getTotalTimeout().toString()) + .build()); + } + + // Add the memory utilization of the client at the time this trace was collected. + long totalMemory = Runtime.getRuntime().totalMemory(); + long freeMemory = Runtime.getRuntime().freeMemory(); + double memoryUtilization = ((double) (totalMemory - freeMemory)) / totalMemory; + spanBuilder.setAttribute( + ATTRIBUTE_SERVICE_PREFIX + "memoryUtilization", + String.format("%.2f", memoryUtilization * 100) + "%"); + + return spanBuilder; + } + + @Override + public Span startSpan(String spanName) { + SpanBuilder spanBuilder = tracer.spanBuilder(spanName).setSpanKind(SpanKind.PRODUCER); + io.opentelemetry.api.trace.Span span = + addSettingsAttributesToCurrentSpan(spanBuilder).startSpan(); + return new Span(span, spanName); + } + + @Override + public TraceUtil.Span startSpan(String spanName, TraceUtil.Span parentSpan) { + SpanBuilder spanBuilder = + tracer + .spanBuilder(spanName) + .setSpanKind(SpanKind.PRODUCER) + .setParent(io.opentelemetry.context.Context.current().with(parentSpan.getSpan())); + return new Span(addSettingsAttributesToCurrentSpan(spanBuilder).startSpan(), spanName); + } + + @Nonnull + @Override + public TraceUtil.Span getCurrentSpan() { + return new Span(io.opentelemetry.api.trace.Span.current(), ""); + } + + @Nonnull + @Override + public TraceUtil.Context getCurrentContext() { + return new Context(io.opentelemetry.context.Context.current()); + } + + @Override + public Tracer getTracer() { + return this.tracer; + } +} diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TraceUtil.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TraceUtil.java new file mode 100644 index 000000000..fd616a733 --- /dev/null +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TraceUtil.java @@ -0,0 +1,167 @@ +/* + * Copyright 2024 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.cloud.datastore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.datastore.DatastoreOptions; +import io.grpc.ManagedChannelBuilder; +import io.opentelemetry.api.trace.SpanBuilder; +import io.opentelemetry.api.trace.Tracer; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Utility interface to manage OpenTelemetry tracing instrumentation based on the configuration. */ +@InternalExtensionOnly +public interface TraceUtil { + static final String ATTRIBUTE_SERVICE_PREFIX = "gcp.datastore."; + static final String ENABLE_TRACING_ENV_VAR = "DATASTORE_ENABLE_TRACING"; + static final String LIBRARY_NAME = "com.google.cloud.datastore"; + static final String SPAN_NAME_LOOKUP = "Lookup"; + static final String SPAN_NAME_ALLOCATE_IDS = "AllocateIds"; + static final String SPAN_NAME_RESERVE_IDS = "ReserveIds"; + static final String SPAN_NAME_COMMIT = "Commit"; + static final String SPAN_NAME_RUN_QUERY = "RunQuery"; + static final String SPAN_NAME_RUN_AGGREGATION_QUERY = "RunAggregationQuery"; + static final String SPAN_NAME_TRANSACTION_RUN = "Transaction.Run"; + static final String SPAN_NAME_BEGIN_TRANSACTION = "Transaction.Begin"; + static final String SPAN_NAME_TRANSACTION_LOOKUP = "Transaction.Lookup"; + static final String SPAN_NAME_TRANSACTION_COMMIT = "Transaction.Commit"; + static final String SPAN_NAME_TRANSACTION_RUN_QUERY = "Transaction.RunQuery"; + static final String SPAN_NAME_ROLLBACK = "Transaction.Rollback"; + static final String SPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY = + "Transaction.RunAggregationQuery"; + static final String ATTRIBUTES_KEY_DOCUMENT_COUNT = "doc_count"; + static final String ATTRIBUTES_KEY_TRANSACTIONAL = "transactional"; + static final String ATTRIBUTES_KEY_TRANSACTION_ID = "transaction_id"; + static final String ATTRIBUTES_KEY_READ_CONSISTENCY = "read_consistency"; + static final String ATTRIBUTES_KEY_RECEIVED = "Received"; + static final String ATTRIBUTES_KEY_MISSING = "Missing"; + static final String ATTRIBUTES_KEY_DEFERRED = "Deferred"; + static final String ATTRIBUTES_KEY_MORE_RESULTS = "mor_results"; + + /** + * Creates and returns an instance of the TraceUtil class. + * + * @param datastoreOptions The DatastoreOptions object that is requesting an instance of + * TraceUtil. + * @return An instance of the TraceUtil class. + */ + static TraceUtil getInstance(@Nonnull DatastoreOptions datastoreOptions) { + boolean createEnabledInstance = datastoreOptions.getOpenTelemetryOptions().isEnabled(); + + // The environment variable can override options to enable/disable telemetry collection. + String enableTracingEnvVar = System.getenv(ENABLE_TRACING_ENV_VAR); + if (enableTracingEnvVar != null) { + if (enableTracingEnvVar.equalsIgnoreCase("true") + || enableTracingEnvVar.equalsIgnoreCase("on")) { + createEnabledInstance = true; + } + if (enableTracingEnvVar.equalsIgnoreCase("false") + || enableTracingEnvVar.equalsIgnoreCase("off")) { + createEnabledInstance = false; + } + } + + if (createEnabledInstance) { + return new EnabledTraceUtil(datastoreOptions); + } else { + return new DisabledTraceUtil(); + } + } + + /** Returns a channel configurator for gRPC, or {@code null} if tracing is disabled. */ + @Nullable + ApiFunction getChannelConfigurator(); + + /** Represents a trace span. */ + interface Span { + /** Adds the given event to this span. */ + Span addEvent(String name); + + /** Adds the given event with the given attributes to this span. */ + Span addEvent(String name, Map attributes); + + /** Adds the given attribute to this span. */ + Span setAttribute(String key, int value); + + /** Adds the given attribute to this span. */ + Span setAttribute(String key, String value); + + /** Adds the given attribute to this span. */ + Span setAttribute(String key, boolean value); + + io.opentelemetry.api.trace.Span getSpan(); + + /** Marks this span as the current span. */ + Scope makeCurrent(); + + /** Ends this span. */ + void end(); + + /** Ends this span in an error. */ + void end(Throwable error); + + /** + * If an operation ends in the future, its relevant span should end _after_ the future has been + * completed. This method "appends" the span completion code at the completion of the given + * future. In order for telemetry info to be recorded, the future returned by this method should + * be completed. + */ + void endAtFuture(ApiFuture futureValue); + } + + /** Represents a trace context. */ + interface Context { + /** Makes this context the current context. */ + Scope makeCurrent(); + } + + /** Represents a trace scope. */ + interface Scope extends AutoCloseable { + /** Closes the current scope. */ + void close(); + } + + /** Starts a new span with the given name, sets it as the current span, and returns it. */ + Span startSpan(String spanName); + + /** + * Starts a new span with the given name and the span represented by the parentSpan as its parent, + * sets it as the current span and returns it. + */ + Span startSpan(String spanName, Span parentSpan); + + /** + * Adds common SpanAttributes to the current span, useful when hand-creating a new Span without + * using the TraceUtil.Span interface. + */ + SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder); + + /** Returns the current span. */ + @Nonnull + Span getCurrentSpan(); + + /** Returns the current Context. */ + @Nonnull + Context getCurrentContext(); + + /** Returns the current OpenTelemetry Tracer when OpenTelemetry SDK is provided. */ + Tracer getTracer(); +} diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java index 2723325ee..32bf9611c 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java @@ -16,9 +16,11 @@ package com.google.cloud.datastore.testing; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; import static com.google.common.base.MoreObjects.firstNonNull; import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.cloud.NoCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.datastore.DatastoreOptions; @@ -38,7 +40,6 @@ import java.util.UUID; import java.util.concurrent.TimeoutException; import java.util.logging.Logger; -import org.threeten.bp.Duration; /** * Utility to start and stop local Google Cloud Datastore emulators. @@ -307,6 +308,14 @@ public void reset() throws IOException { sendPostRequest("/reset"); } + /** This method is obsolete. Use {@link #stopDuration(java.time.Duration)} instead */ + @ObsoleteApi("Use stopDuration(java.time.Duration) instead") + @Override + public void stop(org.threeten.bp.Duration timeout) + throws IOException, InterruptedException, TimeoutException { + stopDuration(toJavaTimeDuration(timeout)); + } + /** * Stops the Datastore emulator. * @@ -319,15 +328,16 @@ public void reset() throws IOException { * this value high to ensure proper shutdown, like 5 seconds or more. */ @Override - public void stop(Duration timeout) throws IOException, InterruptedException, TimeoutException { + public void stopDuration(java.time.Duration timeout) + throws IOException, InterruptedException, TimeoutException { sendPostRequest("/shutdown"); - waitForProcess(timeout); + waitForProcessDuration(timeout); deleteRecursively(gcdPath); } /** - * Stops the Datastore emulator. The same as {@link #stop(Duration)} but with timeout duration of - * 20 seconds. + * Stops the Datastore emulator. The same as {@link #stopDuration(java.time.Duration)} but with + * timeout duration of 20 seconds. * *

It is important to stop the emulator. Since the emulator runs in its own process, not * stopping it might cause it to become orphan. @@ -335,7 +345,7 @@ public void stop(Duration timeout) throws IOException, InterruptedException, Tim *

It is not required to call {@link #reset()} before {@code stop()}. */ public void stop() throws IOException, InterruptedException, TimeoutException { - stop(Duration.ofSeconds(20)); + stopDuration(java.time.Duration.ofSeconds(20)); } static void deleteRecursively(Path path) throws IOException { diff --git a/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.admin.v1/reflect-config.json b/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.admin.v1/reflect-config.json index 5ed5e01e5..dfe000730 100644 --- a/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.admin.v1/reflect-config.json +++ b/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.admin.v1/reflect-config.json @@ -305,6 +305,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.api.PythonSettings$ExperimentalFeatures", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings$ExperimentalFeatures$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.api.ResourceDescriptor", "queryAllDeclaredConstructors": true, @@ -377,6 +395,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.api.SelectiveGapicGeneration", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.SelectiveGapicGeneration$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.datastore.admin.v1.CommonMetadata", "queryAllDeclaredConstructors": true, diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java index a545580e2..85703f739 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java @@ -70,6 +70,20 @@ public void testHost() { assertEquals("http://localhost:" + PORT, options.build().getHost()); } + @Test + public void testOpenTelemetryOptionsEnabled() { + options.setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()); + assertTrue(options.build().getOpenTelemetryOptions().isEnabled()); + } + + @Test + public void testOpenTelemetryOptionsDisabled() { + options.setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(false).build()); + assertTrue(!options.build().getOpenTelemetryOptions().isEnabled()); + } + @Test public void testNamespace() { assertTrue(options.build().getNamespace().isEmpty()); diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java index cd768f986..459278f25 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java @@ -68,6 +68,7 @@ import com.google.datastore.v1.TransactionOptions; import com.google.protobuf.ByteString; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -87,7 +88,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class DatastoreTest { @@ -176,6 +176,8 @@ public static void beforeClass() throws IOException, InterruptedException { public void setUp() { rpcFactoryMock = EasyMock.createStrictMock(DatastoreRpcFactory.class); rpcMock = EasyMock.createStrictMock(DatastoreRpc.class); + DatastoreOpenTelemetryOptions.Builder otelOptionsBuilder = + DatastoreOpenTelemetryOptions.newBuilder(); rpcMockOptions = options .toBuilder() @@ -191,7 +193,7 @@ public void setUp() { @AfterClass public static void afterClass() throws IOException, InterruptedException, TimeoutException { - helper.stop(Duration.ofMinutes(1)); + helper.stopDuration(Duration.ofMinutes(1)); } @Test diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/IncompleteKeyTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/IncompleteKeyTest.java index a1f8956b5..75549e5ea 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/IncompleteKeyTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/IncompleteKeyTest.java @@ -25,15 +25,17 @@ public class IncompleteKeyTest { - private static IncompleteKey pk1, pk2, pk4; - private static Key parent1; + private static IncompleteKey pk1, pk2, pk4, pk5; + private static Key parent1, parent2; @Before public void setUp() { pk1 = IncompleteKey.newBuilder("ds", "kind1").build(); parent1 = Key.newBuilder("ds", "kind2", 10).setNamespace("ns").build(); + parent2 = Key.newBuilder("ds", "kind2", 10, "test-db").setNamespace("ns").build(); pk2 = IncompleteKey.newBuilder(parent1, "kind3").build(); pk4 = IncompleteKey.newBuilderWithDatabaseId("ds", "kind3", "test-db").build(); + pk5 = IncompleteKey.newBuilder(parent2, "kind4").build(); } @Test @@ -59,12 +61,18 @@ public void testBuilders() { assertEquals("test-db", pk4.getDatabaseId()); assertEquals("kind3", pk4.getKind()); assertTrue(pk4.getAncestors().isEmpty()); + + assertEquals("ds", pk5.getProjectId()); + assertEquals("test-db", pk5.getDatabaseId()); + assertEquals("kind4", pk5.getKind()); + assertEquals(parent2.getPath(), pk5.getAncestors()); } @Test public void testParent() { assertNull(pk1.getParent()); assertEquals(parent1, pk2.getParent()); + assertEquals(parent2, pk5.getParent()); Key parent2 = Key.newBuilder("ds", "kind3", "name").setNamespace("ns").build(); IncompleteKey pk3 = IncompleteKey.newBuilder(parent2, "kind3").build(); assertEquals(parent2, pk3.getParent()); diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecoratorTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecoratorTest.java deleted file mode 100644 index b86355afa..000000000 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecoratorTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - * - * 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.datastore; - -import static com.google.cloud.datastore.TraceUtil.END_SPAN_OPTIONS; -import static com.google.cloud.datastore.TraceUtil.SPAN_NAME_RUN_AGGREGATION_QUERY; -import static com.google.common.truth.Truth.assertThat; -import static com.google.rpc.Code.UNAVAILABLE; -import static org.easymock.EasyMock.createNiceMock; -import static org.easymock.EasyMock.createStrictMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -import com.google.api.gax.retrying.RetrySettings; -import com.google.cloud.datastore.spi.v1.DatastoreRpc; -import com.google.datastore.v1.RunAggregationQueryRequest; -import com.google.datastore.v1.RunAggregationQueryResponse; -import io.opencensus.trace.Span; -import io.opencensus.trace.Tracer; -import org.junit.Before; -import org.junit.Test; - -public class RetryAndTraceDatastoreRpcDecoratorTest { - - public static final int MAX_ATTEMPTS = 3; - private DatastoreRpc mockDatastoreRpc; - private TraceUtil mockTraceUtil; - private DatastoreOptions datastoreOptions = - DatastoreOptions.newBuilder().setProjectId("project-id").build(); - private RetrySettings retrySettings = - RetrySettings.newBuilder().setMaxAttempts(MAX_ATTEMPTS).build(); - - private RetryAndTraceDatastoreRpcDecorator datastoreRpcDecorator; - - @Before - public void setUp() throws Exception { - mockDatastoreRpc = createStrictMock(DatastoreRpc.class); - mockTraceUtil = createStrictMock(TraceUtil.class); - datastoreRpcDecorator = - new RetryAndTraceDatastoreRpcDecorator( - mockDatastoreRpc, mockTraceUtil, retrySettings, datastoreOptions); - } - - @Test - public void testRunAggregationQuery() { - Span mockSpan = createStrictMock(Span.class); - RunAggregationQueryRequest aggregationQueryRequest = - RunAggregationQueryRequest.getDefaultInstance(); - RunAggregationQueryResponse aggregationQueryResponse = - RunAggregationQueryResponse.getDefaultInstance(); - - expect(mockDatastoreRpc.runAggregationQuery(aggregationQueryRequest)) - .andThrow( - new DatastoreException( - UNAVAILABLE.getNumber(), "API not accessible currently", UNAVAILABLE.name())) - .times(2) - .andReturn(aggregationQueryResponse); - expect(mockTraceUtil.startSpan(SPAN_NAME_RUN_AGGREGATION_QUERY)).andReturn(mockSpan); - expect(mockTraceUtil.getTracer()).andReturn(createNiceMock(Tracer.class)); - mockSpan.end(END_SPAN_OPTIONS); - - replay(mockDatastoreRpc, mockTraceUtil, mockSpan); - - RunAggregationQueryResponse actualAggregationQueryResponse = - datastoreRpcDecorator.runAggregationQuery(aggregationQueryRequest); - - assertThat(actualAggregationQueryResponse).isSameInstanceAs(aggregationQueryResponse); - verify(mockDatastoreRpc, mockTraceUtil, mockSpan); - } -} diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java index 09dcd2116..bf0c20dce 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java @@ -81,6 +81,7 @@ import com.google.common.truth.Truth; import com.google.datastore.v1.TransactionOptions; import com.google.datastore.v1.TransactionOptions.ReadOnly; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -103,7 +104,6 @@ import org.junit.rules.Timeout; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.threeten.bp.Duration; @RunWith(Parameterized.class) public class ITDatastoreTest { @@ -144,6 +144,7 @@ public class ITDatastoreTest { private static Key KEY3; private static Key KEY4; private static Key KEY5; + private static Key KEY6; private static final String MARKS_KIND = "Marks"; private static FullEntity PARTIAL_ENTITY1; private static FullEntity PARTIAL_ENTITY2; @@ -193,6 +194,10 @@ public ITDatastoreTest( KEY3 = Key.newBuilder(KEY2).setName("bla").setNamespace(NAMESPACE).build(); KEY4 = Key.newBuilder(KEY2).setName("newName1").setNamespace(NAMESPACE).build(); KEY5 = Key.newBuilder(KEY2).setName("newName2").setNamespace(NAMESPACE).build(); + KEY6 = + Key.newBuilder(options.getProjectId(), KIND2, 100, options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build(); LIST_VALUE2 = ListValue.of(Collections.singletonList(KeyValue.of(KEY1))); @@ -669,7 +674,7 @@ private void assertExecutionStats( Truth.assertThat(debugStats.get("index_entries_scanned")) .isEqualTo(expectedIndexEntriesScanned); - Duration executionDuration = executionStats.getExecutionDuration(); + Duration executionDuration = executionStats.getExecutionDurationJavaTime(); Truth.assertThat(executionDuration).isIn(Range.greaterThan(Duration.ofMillis(0))); long readOperations = executionStats.getReadOperations(); @@ -1787,6 +1792,21 @@ public void testGet() { assertFalse(entity.contains("bla")); } + @Test + public void testIncompleteKey() { + Key parentKey = null; + try { + IncompleteKey incompleteKey = IncompleteKey.newBuilder(KEY6, KIND1).build(); + parentKey = incompleteKey.getParent(); + Entity entity = Entity.newBuilder(parentKey).set("name", "val").build(); + datastore.put(entity); + Entity retrievedEntity = datastore.get(parentKey); + assertThat(retrievedEntity).isEqualTo(entity); + } finally { + datastore.delete(parentKey); + } + } + @Test public void testGetWithReadTime() throws InterruptedException { Key key = diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITE2ETracingTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITE2ETracingTest.java new file mode 100644 index 000000000..bee54a1f0 --- /dev/null +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITE2ETracingTest.java @@ -0,0 +1,1009 @@ +/* + * Copyright 2024 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.cloud.datastore.it; + +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ALLOCATE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_BEGIN_TRANSACTION; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RESERVE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ROLLBACK; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_AGGREGATION_QUERY; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_QUERY; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN_QUERY; +import static com.google.common.truth.Truth.assertThat; +import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.google.api.gax.rpc.NotFoundException; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.IncompleteKey; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.Transaction; +import com.google.cloud.datastore.testing.RemoteDatastoreHelper; +import com.google.cloud.opentelemetry.trace.TraceConfiguration; +import com.google.cloud.opentelemetry.trace.TraceExporter; +import com.google.cloud.trace.v1.TraceServiceClient; +import com.google.common.base.Preconditions; +import com.google.devtools.cloudtrace.v1.Trace; +import com.google.devtools.cloudtrace.v1.TraceSpan; +import com.google.testing.junit.testparameterinjector.TestParameter; +import com.google.testing.junit.testparameterinjector.TestParameterInjector; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.api.trace.TraceFlags; +import io.opentelemetry.api.trace.TraceState; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; +import io.opentelemetry.sdk.trace.samplers.Sampler; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.TreeMap; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +// This End-to-End test verifies Client-side Tracing Functionality instrumented using the +// OpenTelemetry API. +// The test depends on the following external APIs/Services: +// 1. Java OpenTelemetry SDK +// 2. Cloud Trace Exporter +// 3. TraceServiceClient from Cloud Trace API v1. +// +// Permissions required to run this test (https://cloud.google.com/trace/docs/iam#trace-roles): +// 1. gcloud auth application-default login must be run with the test user. +// 2. To write traces, test user must have one of roles/cloudtrace.[admin|agent|user] roles. +// 3. To read traces, test user must have one of roles/cloudtrace.[admin|user] roles. +// +// Each test-case has the following workflow: +// 1. OpenTelemetry SDK is initialized with Cloud Trace Exporter and 100% Trace Sampling +// 2. On initialization, Datastore client is provided the OpenTelemetry SDK object from (1) +// 3. A custom TraceID is generated and injected using a custom SpanContext +// 4. Datastore operations are run inside a root TraceSpan created using the custom SpanContext from +// (3). +// 5. Traces are read-back using TraceServiceClient and verified against expected Call Stacks. +@RunWith(TestParameterInjector.class) +public class ITE2ETracingTest { + + protected boolean isUsingGlobalOpenTelemetrySDK() { + return useGlobalOpenTelemetrySDK; + } + + protected String datastoreNamedDatabase() { + return datastoreNamedDatabase; + } + + // Helper class to track call-stacks in a trace + protected static class TraceContainer { + + // Maps Span ID to TraceSpan + private final Map idSpanMap; + + // Maps Parent Span ID to a list of Child SpanIDs, useful for top-down traversal + private final Map> parentChildIdMap; + + // Tracks the Root Span ID + private long rootId; + + public TraceContainer(String rootSpanName, Trace trace) { + idSpanMap = new TreeMap<>(); + parentChildIdMap = new TreeMap<>(); + for (TraceSpan span : trace.getSpansList()) { + long spanId = span.getSpanId(); + idSpanMap.put(spanId, span); + if (rootSpanName.equals(span.getName())) { + rootId = span.getSpanId(); + } + + // Add self as a child of the parent span + if (!parentChildIdMap.containsKey(span.getParentSpanId())) { + parentChildIdMap.put(span.getParentSpanId(), new ArrayList<>()); + } + parentChildIdMap.get(span.getParentSpanId()).add(spanId); + } + } + + String spanName(long spanId) { + return idSpanMap.get(spanId).getName(); + } + + List childSpans(long spanId) { + return parentChildIdMap.get(spanId); + } + + // This method only works for matching call stacks with traces which have children of distinct + // type at all levels. This is good enough as the intention is to validate if the e2e path is + // WAI - the intention is not to validate Cloud Trace's correctness w.r.t. durability of all + // kinds of traces. + boolean containsCallStack(String... callStack) throws RuntimeException { + List expectedCallStack = Arrays.asList(callStack); + if (expectedCallStack.isEmpty()) { + throw new RuntimeException("Input callStack is empty"); + } + return dfsContainsCallStack(rootId, expectedCallStack); + } + + // Depth-first check for call stack in the trace + private boolean dfsContainsCallStack(long spanId, List expectedCallStack) { + logger.info( + "span=" + + spanName(spanId) + + ", expectedCallStack[0]=" + + (expectedCallStack.isEmpty() ? "null" : expectedCallStack.get(0))); + if (expectedCallStack.isEmpty()) { + return false; + } + if (spanName(spanId).equals(expectedCallStack.get(0))) { + // Recursion termination + if (childSpans(spanId) == null) { + logger.info("No more children for " + spanName(spanId)); + return expectedCallStack.size() <= 1; + } else { + // Examine the child spans + for (Long childSpan : childSpans(spanId)) { + int callStackListSize = expectedCallStack.size(); + logger.info( + "childSpan=" + + spanName(childSpan) + + ", expectedCallStackSize=" + + callStackListSize); + if (dfsContainsCallStack( + childSpan, + expectedCallStack.subList( + /*fromIndexInclusive=*/ 1, /*toIndexExclusive*/ callStackListSize))) { + return true; + } + } + } + } else { + logger.info(spanName(spanId) + " didn't match " + expectedCallStack.get(0)); + } + return false; + } + } + + private static final Logger logger = Logger.getLogger(ITE2ETracingTest.class.getName()); + + private static final String RUN_AGGREGATION_QUERY_RPC_NAME = "RunAggregationQuery"; + + private static final String RUN_QUERY_RPC_NAME = "RunQuery"; + + private static final int NUM_TRACE_ID_BYTES = 32; + + private static final int NUM_SPAN_ID_BYTES = 16; + + private static final int GET_TRACE_RETRY_COUNT = 60; + + private static final int GET_TRACE_RETRY_BACKOFF_MILLIS = 1000; + + private static final int TRACE_FORCE_FLUSH_MILLIS = 5000; + + private static final int TRACE_PROVIDER_SHUTDOWN_MILLIS = 1000; + + private static Key KEY1; + + private static Key KEY2; + + private static Key KEY3; + + private static Key KEY4; + + // Random int generator for trace ID and span ID + private static Random random; + + private static TraceExporter traceExporter; + + // Required for reading back traces from Cloud Trace for validation + private static TraceServiceClient traceClient_v1; + + // Custom SpanContext for each test, required for TraceID injection + private static SpanContext customSpanContext; + + // Trace read back from Cloud Trace using traceClient_v1 for verification + private static Trace retrievedTrace; + + private static String rootSpanName; + private static Tracer tracer; + + // Required to set custom-root span + private static OpenTelemetrySdk openTelemetrySdk; + + private static String projectId; + + private static DatastoreOptions options; + + private static Datastore datastore; + + private static RemoteDatastoreHelper remoteDatastoreHelper; + + @TestParameter boolean useGlobalOpenTelemetrySDK; + + @TestParameter({ + /*(default)*/ + "", + "test-db" + }) + String datastoreNamedDatabase; + + @BeforeClass + public static void setup() throws IOException { + projectId = DatastoreOptions.getDefaultProjectId(); + traceExporter = + TraceExporter.createWithConfiguration( + TraceConfiguration.builder().setProjectId(projectId).build()); + traceClient_v1 = TraceServiceClient.create(); + random = new Random(); + } + + @Before + public void before() throws Exception { + // Set up OTel SDK + Resource resource = + Resource.getDefault().merge(Resource.builder().put(SERVICE_NAME, "Sparky").build()); + + if (isUsingGlobalOpenTelemetrySDK()) { + openTelemetrySdk = + OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder() + .setResource(resource) + .addSpanProcessor(BatchSpanProcessor.builder(traceExporter).build()) + .setSampler(Sampler.alwaysOn()) + .build()) + .buildAndRegisterGlobal(); + } else { + openTelemetrySdk = + OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder() + .setResource(resource) + .addSpanProcessor(BatchSpanProcessor.builder(traceExporter).build()) + .setSampler(Sampler.alwaysOn()) + .build()) + .build(); + } + + // Initialize the Datastore DB w/ the OTel SDK. Ideally we'd do this is the @BeforeAll method + // but because gRPC traces need to be deterministically force-flushed for every test + String namedDb = datastoreNamedDatabase(); + logger.log(Level.INFO, "Integration test using named database " + namedDb); + remoteDatastoreHelper = RemoteDatastoreHelper.create(namedDb, openTelemetrySdk); + options = remoteDatastoreHelper.getOptions(); + datastore = options.getService(); + + Preconditions.checkNotNull( + datastore, + "Error instantiating Datastore. Check that the service account credentials " + + "were properly set."); + + String projectId = options.getProjectId(); + String kind1 = "kind1"; + KEY1 = + Key.newBuilder(projectId, kind1, "key1", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY2 = + Key.newBuilder(projectId, kind1, "key2", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY3 = + Key.newBuilder(projectId, kind1, "key3", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY4 = + Key.newBuilder(projectId, kind1, "key4", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + // Set up the tracer for custom TraceID injection + rootSpanName = + String.format("%s%d", this.getClass().getSimpleName(), System.currentTimeMillis()); + if (isUsingGlobalOpenTelemetrySDK()) { + tracer = GlobalOpenTelemetry.getTracer(rootSpanName); + } else { + tracer = + datastore + .getOptions() + .getOpenTelemetryOptions() + .getOpenTelemetry() + .getTracer(rootSpanName); + } + + // Get up a new SpanContext (ergo TraceId) for each test + customSpanContext = getNewSpanContext(); + assertNotNull(customSpanContext); + assertNull(retrievedTrace); + } + + @After + public void after() throws Exception { + if (isUsingGlobalOpenTelemetrySDK()) { + GlobalOpenTelemetry.resetForTest(); + } + remoteDatastoreHelper.deleteNamespace(); + rootSpanName = null; + tracer = null; + retrievedTrace = null; + customSpanContext = null; + openTelemetrySdk = null; + } + + @AfterClass + public static void teardown() throws Exception { + traceClient_v1.close(); + } + + // Generates a random hex string of length `numBytes` + private String generateRandomHexString(int numBytes) { + StringBuilder newTraceId = new StringBuilder(); + while (newTraceId.length() < numBytes) { + newTraceId.append(Integer.toHexString(random.nextInt())); + } + return newTraceId.substring(0, numBytes); + } + + protected String generateNewTraceId() { + return generateRandomHexString(NUM_TRACE_ID_BYTES); + } + + // Generates a random 16-byte hex string + protected String generateNewSpanId() { + return generateRandomHexString(NUM_SPAN_ID_BYTES); + } + + // Generates a new SpanContext w/ random traceId,spanId + protected SpanContext getNewSpanContext() { + String traceId = generateNewTraceId(); + String spanId = generateNewSpanId(); + logger.info("traceId=" + traceId + ", spanId=" + spanId); + + return SpanContext.create(traceId, spanId, TraceFlags.getSampled(), TraceState.getDefault()); + } + + protected Span getNewRootSpanWithContext() { + // Execute the DB operation in the context of the custom root span. + return tracer + .spanBuilder(rootSpanName) + .setParent(Context.root().with(Span.wrap(customSpanContext))) + .startSpan(); + } + + protected void waitForTracesToComplete() throws Exception { + logger.info("Flushing traces..."); + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().forceFlush(); + completableResultCode.join(TRACE_FORCE_FLUSH_MILLIS, TimeUnit.MILLISECONDS); + } + + // Validates `retrievedTrace`. Cloud Trace indexes traces w/ eventual consistency, even when + // indexing traceId, therefore the test must retry a few times before the complete trace is + // available. + // For Transaction traces, there may be more spans than in the trace than specified in + // `callStack`. So `numExpectedSpans` is the expected total number of spans (and not just the + // spans in `callStack`) + protected void fetchAndValidateTrace( + String traceId, int numExpectedSpans, List> callStackList) + throws InterruptedException { + // Large enough count to accommodate eventually consistent Cloud Trace backend + int numRetries = GET_TRACE_RETRY_COUNT; + // Account for rootSpanName + numExpectedSpans++; + + // Fetch traces + do { + try { + retrievedTrace = traceClient_v1.getTrace(projectId, traceId); + assertEquals(traceId, retrievedTrace.getTraceId()); + + logger.info( + "expectedSpanCount=" + + numExpectedSpans + + ", retrievedSpanCount=" + + retrievedTrace.getSpansCount()); + } catch (NotFoundException notFound) { + logger.info("Trace not found, retrying in " + GET_TRACE_RETRY_BACKOFF_MILLIS + " ms"); + } catch (IndexOutOfBoundsException outOfBoundsException) { + logger.info("Call stack not found in trace. Retrying."); + } + if (retrievedTrace == null || numExpectedSpans != retrievedTrace.getSpansCount()) { + Thread.sleep(GET_TRACE_RETRY_BACKOFF_MILLIS); + } + } while (numRetries-- > 0 + && (retrievedTrace == null || numExpectedSpans != retrievedTrace.getSpansCount())); + + if (retrievedTrace == null || numExpectedSpans != retrievedTrace.getSpansCount()) { + throw new RuntimeException( + "Expected number of spans: " + + numExpectedSpans + + ", Actual number of spans: " + + (retrievedTrace != null + ? retrievedTrace.getSpansList().toString() + : "Trace NOT_FOUND")); + } + + TraceContainer traceContainer = new TraceContainer(rootSpanName, retrievedTrace); + + for (List callStack : callStackList) { + // Update all call stacks to be rooted at rootSpanName + ArrayList expectedCallStack = new ArrayList<>(callStack); + + // numExpectedSpans should account for rootSpanName (not passed in callStackList) + expectedCallStack.add(0, rootSpanName); + + // *May be* the full trace was returned + logger.info("Checking if TraceContainer contains the callStack"); + String[] expectedCallList = new String[expectedCallStack.size()]; + if (!traceContainer.containsCallStack(expectedCallStack.toArray(expectedCallList))) { + throw new RuntimeException( + "Expected spans: " + + Arrays.toString(expectedCallList) + + ", Actual spans: " + + (retrievedTrace != null + ? retrievedTrace.getSpansList().toString() + : "Trace NOT_FOUND")); + } + logger.severe("CallStack not found in TraceContainer."); + } + } + + // Validates `retrievedTrace`. Cloud Trace indexes traces w/ eventual consistency, even when + // indexing traceId, therefore the test must retry a few times before the complete trace is + // available. + // For Non-Transaction traces, there is a 1:1 ratio of spans in `spanNames` and in the trace. + protected void fetchAndValidateTrace(String traceId, String... spanNames) + throws InterruptedException { + fetchAndValidateTrace(traceId, spanNames.length, Arrays.asList(Arrays.asList(spanNames))); + } + + @Test + public void traceContainerTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity entity = datastore.get(KEY1); + assertNull(entity); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + Trace traceResp = null; + int expectedSpanCount = 2; + + int numRetries = GET_TRACE_RETRY_COUNT; + do { + try { + traceResp = traceClient_v1.getTrace(projectId, customSpanContext.getTraceId()); + if (traceResp.getSpansCount() == expectedSpanCount) { + logger.info("Success: Got " + expectedSpanCount + " spans."); + break; + } + } catch (NotFoundException notFoundException) { + Thread.sleep(GET_TRACE_RETRY_BACKOFF_MILLIS); + logger.info("Trace not found, retrying in " + GET_TRACE_RETRY_BACKOFF_MILLIS + " ms"); + } + logger.info( + "Trace Found. The trace did not contain " + + expectedSpanCount + + " spans. Going to retry."); + numRetries--; + } while (numRetries > 0); + + // Make sure we got as many spans as we expected. + assertNotNull(traceResp); + assertEquals(expectedSpanCount, traceResp.getSpansCount()); + + TraceContainer traceCont = new TraceContainer(rootSpanName, traceResp); + + // Contains exact path + assertTrue(traceCont.containsCallStack(rootSpanName, SPAN_NAME_LOOKUP)); + + // Top-level mismatch + assertFalse(traceCont.containsCallStack(SPAN_NAME_LOOKUP, RUN_QUERY_RPC_NAME)); + + // Leaf-level mismatch/missing + assertFalse( + traceCont.containsCallStack( + rootSpanName, SPAN_NAME_LOOKUP, RUN_AGGREGATION_QUERY_RPC_NAME)); + } + + @Test + public void lookupTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity entity = datastore.get(KEY1); + assertNull(entity); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_LOOKUP); + } + + @Test + public void allocateIdsTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + String kind1 = "kind1"; + KeyFactory keyFactory = datastore.newKeyFactory().setKind(kind1); + IncompleteKey pk1 = keyFactory.newKey(); + Key key1 = datastore.allocateId(pk1); + assertEquals(key1.getProjectId(), pk1.getProjectId()); + assertEquals(key1.getNamespace(), pk1.getNamespace()); + assertEquals(key1.getAncestors(), pk1.getAncestors()); + assertEquals(key1.getKind(), pk1.getKind()); + assertTrue(key1.hasId()); + assertFalse(key1.hasName()); + assertEquals(Key.newBuilder(pk1, key1.getId()).build(), key1); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_ALLOCATE_IDS); + } + + @Test + public void reserveIdsTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind"); + Key key1 = keyFactory.newKey(10); + Key key2 = keyFactory.newKey("name"); + List keyList = datastore.reserveIds(key1, key2); + assertEquals(2, keyList.size()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_RESERVE_IDS); + } + + @Test + public void commitTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity response = datastore.add(entity1); + assertEquals(entity1, response); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void putTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void updateTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity entity1_update = + Entity.newBuilder(entity1).set("test_field", "new_test_value1").build(); + Entity entity2_update = + Entity.newBuilder(entity2).set("test_field", "new_test_value1").build(); + datastore.update(entity1_update, entity2_update); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void deleteTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + + Span rootSpan = getNewRootSpanWithContext(); + + try (Scope ignored = rootSpan.makeCurrent()) { + datastore.delete(entity1.getKey()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void runQueryTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_RUN_QUERY); + } + + @Test + public void runAggregationQueryTraceTest() throws Exception { + Entity entity1 = + Entity.newBuilder(KEY1) + .set("pepper_name", "jalapeno") + .set("max_scoville_level", 10000) + .build(); + Entity entity2 = + Entity.newBuilder(KEY2) + .set("pepper_name", "serrano") + .set("max_scoville_level", 25000) + .build(); + Entity entity3 = + Entity.newBuilder(KEY3) + .set("pepper_name", "habanero") + .set("max_scoville_level", 350000) + .build(); + Entity entity4 = + Entity.newBuilder(KEY4) + .set("pepper_name", "ghost") + .set("max_scoville_level", 1500000) + .build(); + + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + entityList.add(entity3); + entityList.add(entity4); + + List response = datastore.add(entity1, entity2, entity3, entity4); + assertEquals(entityList, response); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + PropertyFilter mediumSpicyFilters = PropertyFilter.lt("max_scoville_level", 100000); + StructuredQuery mediumSpicyQuery = + Query.newEntityQueryBuilder() + .setKind(KEY1.getKind()) + .setFilter(mediumSpicyFilters) + .build(); + AggregationQuery countSpicyPeppers = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("count")) + .over(mediumSpicyQuery) + .build(); + AggregationResults results = datastore.runAggregation(countSpicyPeppers); + assertThat(results.size()).isEqualTo(1); + AggregationResult result = results.get(0); + assertThat(result.getLong("count")).isEqualTo(2L); + } finally { + rootSpan.end(); + } + + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_RUN_AGGREGATION_QUERY); + } + + @Test + public void newTransactionReadTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + Entity entity = datastore.get(KEY1, ReadOption.transactionId(transaction.getTransactionId())); + transaction.commit(); + assertNull(entity); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /*numExpectedSpans=*/ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_LOOKUP), + Collections.singletonList(SPAN_NAME_TRANSACTION_COMMIT))); + } + + @Test + public void newTransactionQueryTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + assertNotNull(customSpanContext); + + // Test + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = transaction.run(query); + transaction.commit(); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /*numExpectedSpans=*/ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_RUN_QUERY), + Collections.singletonList(SPAN_NAME_TRANSACTION_COMMIT))); + } + + @Test + public void newTransactionReadWriteTraceTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("pepper_type", "jalapeno").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("pepper_type", "habanero").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + String simplified_spice_level = "not_spicy"; + Entity entity1update = + Entity.newBuilder(entity1).set("spice_level", simplified_spice_level).build(); + + assertNotNull(customSpanContext); + + // Test + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + entity1 = transaction.get(KEY1); + switch (entity1.getString("pepper_type")) { + case "jalapeno": + simplified_spice_level = "mild"; + break; + + case "habanero": + simplified_spice_level = "hot"; + break; + } + transaction.update(entity1update); + transaction.delete(KEY2); + transaction.commit(); + assertFalse(transaction.isActive()); + } finally { + rootSpan.end(); + } + + waitForTracesToComplete(); + + List list = datastore.fetch(KEY1, KEY2); + assertEquals(list.get(0), entity1update); + assertNull(list.get(1)); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /*numExpectedSpans=*/ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_LOOKUP), + Collections.singletonList(SPAN_NAME_TRANSACTION_COMMIT))); + } + + @Test + public void newTransactionRollbackTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("pepper_type", "jalapeno").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("pepper_type", "habanero").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + String simplified_spice_level = "not_spicy"; + Entity entity1update = + Entity.newBuilder(entity1).set("spice_level", simplified_spice_level).build(); + + assertNotNull(customSpanContext); + + // Test + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + entity1 = transaction.get(KEY1); + switch (entity1.getString("pepper_type")) { + case "jalapeno": + simplified_spice_level = "mild"; + break; + + case "habanero": + simplified_spice_level = "hot"; + break; + } + transaction.update(entity1update); + transaction.delete(KEY2); + transaction.rollback(); + assertFalse(transaction.isActive()); + } finally { + rootSpan.end(); + } + + waitForTracesToComplete(); + + List list = datastore.fetch(KEY1, KEY2); + assertEquals(list.get(0), entity1); + assertEquals(list.get(1), entity2); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /*numExpectedSpans=*/ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_LOOKUP), + Collections.singletonList(SPAN_NAME_ROLLBACK))); + } + + @Test + public void runInTransactionQueryTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + Datastore.TransactionCallable callable = + transaction -> { + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + return true; + }; + datastore.runInTransaction(callable); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /*numExpectedSpans=*/ 4, + Arrays.asList( + Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_BEGIN_TRANSACTION), + Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_RUN_QUERY), + Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_TRANSACTION_COMMIT))); + } +} diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITTracingTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITTracingTest.java new file mode 100644 index 000000000..aefb51352 --- /dev/null +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITTracingTest.java @@ -0,0 +1,849 @@ +/* + * Copyright 2024 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.cloud.datastore.it; + +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.cloud.datastore.telemetry.TraceUtil.*; +import static com.google.common.truth.Truth.assertThat; +import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.IncompleteKey; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.Transaction; +import com.google.cloud.datastore.testing.RemoteDatastoreHelper; +import com.google.common.base.Preconditions; +import com.google.testing.junit.testparameterinjector.TestParameter; +import com.google.testing.junit.testparameterinjector.TestParameterInjector; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.OpenTelemetrySdkBuilder; +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.SpanProcessor; +import io.opentelemetry.sdk.trace.data.EventData; +import io.opentelemetry.sdk.trace.data.SpanData; +import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; +import io.opentelemetry.sdk.trace.samplers.Sampler; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nullable; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; + +@RunWith(TestParameterInjector.class) +public class ITTracingTest { + protected boolean isUsingGlobalOpenTelemetrySDK() { + return useGlobalOpenTelemetrySDK; + } + + protected String datastoreNamedDatabase() { + return datastoreNamedDatabase; + } + + private static final Logger logger = + Logger.getLogger(com.google.cloud.datastore.it.ITTracingTest.class.getName()); + + private static final int TRACE_FORCE_FLUSH_MILLIS = 1000; + private static final int TRACE_PROVIDER_SHUTDOWN_MILLIS = 1000; + private static final int IN_MEMORY_SPAN_EXPORTER_DELAY_MILLIS = 50; + private static final String SERVICE = "google.datastore.v1.Datastore/"; + + private static Key KEY1; + + private static Key KEY2; + + private static Key KEY3; + + private static Key KEY4; + + private static OpenTelemetrySdk openTelemetrySdk; + + // We use an InMemorySpanExporter for testing which keeps all generated trace spans + // in memory so that we can check their correctness. + protected InMemorySpanExporter inMemorySpanExporter; + private static DatastoreOptions options; + + protected Datastore datastore; + private static RemoteDatastoreHelper remoteDatastoreHelper; + + @TestParameter boolean useGlobalOpenTelemetrySDK; + + @TestParameter({ + /*(default)*/ + "", + "test-db" + }) + String datastoreNamedDatabase; + + Map spanNameToSpanId = new HashMap<>(); + Map spanIdToParentSpanId = new HashMap<>(); + Map spanNameToSpanData = new HashMap<>(); + + @Rule public TestName testName = new TestName(); + + @Before + public void before() { + inMemorySpanExporter = InMemorySpanExporter.create(); + + Resource resource = + Resource.getDefault().merge(Resource.builder().put(SERVICE_NAME, "Sparky").build()); + SpanProcessor inMemorySpanProcessor = SimpleSpanProcessor.create(inMemorySpanExporter); + DatastoreOptions.Builder optionsBuilder = DatastoreOptions.newBuilder(); + DatastoreOpenTelemetryOptions.Builder otelOptionsBuilder = + DatastoreOpenTelemetryOptions.newBuilder(); + OpenTelemetrySdkBuilder openTelemetrySdkBuilder = + OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder() + .setResource(resource) + .addSpanProcessor(inMemorySpanProcessor) + .setSampler(Sampler.alwaysOn()) + .build()); + + if (isUsingGlobalOpenTelemetrySDK()) { + GlobalOpenTelemetry.resetForTest(); + openTelemetrySdk = openTelemetrySdkBuilder.buildAndRegisterGlobal(); + optionsBuilder.setOpenTelemetryOptions(otelOptionsBuilder.setTracingEnabled(true).build()); + } else { + openTelemetrySdk = openTelemetrySdkBuilder.build(); + optionsBuilder.setOpenTelemetryOptions( + otelOptionsBuilder.setTracingEnabled(true).setOpenTelemetry(openTelemetrySdk).build()); + } + + String namedDb = datastoreNamedDatabase(); + logger.log(Level.INFO, "Integration test using named database " + namedDb); + remoteDatastoreHelper = RemoteDatastoreHelper.create(namedDb, openTelemetrySdk); + options = remoteDatastoreHelper.getOptions(); + datastore = options.getService(); + + Preconditions.checkNotNull( + datastore, + "Error instantiating Datastore. Check that the service account credentials " + + "were properly set."); + + String projectId = options.getProjectId(); + String kind1 = "kind1"; + KEY1 = + Key.newBuilder(projectId, kind1, "key1", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY2 = + Key.newBuilder(projectId, kind1, "key2", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY3 = + Key.newBuilder(projectId, kind1, "key3", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY4 = + Key.newBuilder(projectId, kind1, "key4", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + cleanupTestSpanContext(); + } + + @After + public void after() throws Exception { + if (isUsingGlobalOpenTelemetrySDK()) { + GlobalOpenTelemetry.resetForTest(); + } + remoteDatastoreHelper.deleteNamespace(); + inMemorySpanExporter.reset(); + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().shutdown(); + completableResultCode.join(TRACE_PROVIDER_SHUTDOWN_MILLIS, TimeUnit.MILLISECONDS); + openTelemetrySdk = null; + } + + @AfterClass + public static void teardown() {} + + void waitForTracesToComplete() throws Exception { + // The same way that querying the Cloud Trace backend may not give us the + // full trace on the first try, querying the in-memory traces may not result + // in the full trace immediately. Note that performing the `flush` is not + // enough. This doesn't pose an issue in practice, but can make tests flaky. + // Therefore, we're adding a delay to make sure we avoid any flakiness. + inMemorySpanExporter.flush().join(IN_MEMORY_SPAN_EXPORTER_DELAY_MILLIS, TimeUnit.MILLISECONDS); + TimeUnit.MILLISECONDS.sleep(IN_MEMORY_SPAN_EXPORTER_DELAY_MILLIS); + + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().forceFlush(); + completableResultCode.join(TRACE_FORCE_FLUSH_MILLIS, TimeUnit.MILLISECONDS); + } + + // Prepares all the spans in memory for inspection. + List prepareSpans() throws Exception { + waitForTracesToComplete(); + List spans = inMemorySpanExporter.getFinishedSpanItems(); + buildSpanMaps(spans); + printSpans(); + return spans; + } + + void buildSpanMaps(List spans) { + for (SpanData spanData : spans) { + spanNameToSpanData.put(spanData.getName(), spanData); + spanNameToSpanId.put(spanData.getName(), spanData.getSpanId()); + spanIdToParentSpanId.put(spanData.getSpanId(), spanData.getParentSpanId()); + } + } + + // Returns the SpanData object for the span with the given name. + // Returns null if no span with the given name exists. + @Nullable + SpanData getSpanByName(String spanName) { + return spanNameToSpanData.get(spanName); + } + + // Returns the SpanData object for the gRPC span with the given RPC name. + // Returns null if no such span exists. + @Nullable + SpanData getGrpcSpanByName(String rpcName) { + return getSpanByName(SERVICE + rpcName); + } + + String grpcSpanName(String rpcName) { + return SERVICE + rpcName; + } + + void assertSameTrace(SpanData... spans) { + if (spans.length > 1) { + String traceId = spans[0].getTraceId(); + for (SpanData spanData : spans) { + assertEquals(traceId, spanData.getTraceId()); + } + } + } + + // Helper to see the spans in standard output while developing tests + void printSpans() { + for (SpanData spanData : spanNameToSpanData.values()) { + logger.log( + Level.FINE, + String.format( + "SPAN ID:%s, ParentID:%s, KIND:%s, TRACE ID:%s, NAME:%s, ATTRIBUTES:%s, EVENTS:%s\n", + spanData.getSpanId(), + spanData.getParentSpanId(), + spanData.getKind(), + spanData.getTraceId(), + spanData.getName(), + spanData.getAttributes().toString(), + spanData.getEvents().toString())); + } + } + + // Asserts that the span hierarchy exists for the given span names. The hierarchy starts with the + // root span, followed + // by the child span, grandchild span, and so on. It also asserts that all the given spans belong + // to the same trace, + // and that datastore-generated spans contain the expected datastore attributes. + void assertSpanHierarchy(String... spanNamesHierarchy) { + List spanNames = Arrays.asList(spanNamesHierarchy); + + for (int i = 0; i + 1 < spanNames.size(); ++i) { + String parentSpanName = spanNames.get(i); + String childSpanName = spanNames.get(i + 1); + SpanData parentSpan = getSpanByName(parentSpanName); + SpanData childSpan = getSpanByName(childSpanName); + assertNotNull(parentSpan); + assertNotNull(childSpan); + assertEquals(childSpan.getParentSpanId(), parentSpan.getSpanId()); + assertSameTrace(childSpan, parentSpan); + // gRPC spans do not have datastore attributes. + if (!parentSpanName.startsWith(SERVICE)) { + assertHasExpectedAttributes(parentSpan); + } + if (!childSpanName.startsWith(SERVICE)) { + assertHasExpectedAttributes(childSpan); + } + } + } + + void assertHasExpectedAttributes(SpanData spanData, String... additionalExpectedAttributes) { + // All datastore-generated spans have the settings attributes. + List expectedAttributes = + Arrays.asList( + "gcp.datastore.memoryUtilization", + "gcp.datastore.settings.host", + "gcp.datastore.settings.databaseId", + "gcp.datastore.settings.retrySettings.maxRpcTimeout", + "gcp.datastore.settings.retrySettings.retryDelayMultiplier", + "gcp.datastore.settings.retrySettings.initialRetryDelay", + "gcp.datastore.settings.credentials.authenticationType", + "gcp.datastore.settings.retrySettings.maxAttempts", + "gcp.datastore.settings.retrySettings.maxRetryDelay", + "gcp.datastore.settings.retrySettings.rpcTimeoutMultiplier", + "gcp.datastore.settings.retrySettings.totalTimeout", + "gcp.datastore.settings.retrySettings.initialRpcTimeout"); + + expectedAttributes.addAll(Arrays.asList(additionalExpectedAttributes)); + + Attributes spanAttributes = spanData.getAttributes(); + for (String expectedAttribute : expectedAttributes) { + assertNotNull(spanAttributes.get(AttributeKey.stringKey(expectedAttribute))); + } + } + + // Returns true if and only if the given span data contains an event with the given name and the + // given expected + // attributes. + boolean hasEvent(SpanData spanData, String eventName, @Nullable Attributes expectedAttributes) { + if (spanData == null) { + return false; + } + + logger.log( + Level.INFO, + String.format( + "Checking if span named '%s' (ID='%s') contains an event named '%s'", + spanData.getName(), spanData.getSpanId(), eventName)); + + List events = spanData.getEvents(); + for (EventData event : events) { + if (event.getName().equals(eventName)) { + if (expectedAttributes == null) { + return true; + } + + // Make sure attributes also match. + Attributes eventAttributes = event.getAttributes(); + return expectedAttributes.equals(eventAttributes); + } + } + return false; + } + + void cleanupTestSpanContext() { + inMemorySpanExporter.reset(); + spanNameToSpanId.clear(); + spanIdToParentSpanId.clear(); + spanNameToSpanData.clear(); + } + + // This is a POJO used for testing APIs that take a POJO. + public static class Pojo { + public int bar; + + public Pojo() { + bar = 0; + } + + public Pojo(int bar) { + this.bar = bar; + } + + public int getBar() { + return bar; + } + + public void setBar(int bar) { + this.bar = bar; + } + } + + @Test + public void lookupTraceTest() throws Exception { + Entity entity = datastore.get(KEY1); + assertNull(entity); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_LOOKUP); + SpanData span = getSpanByName(SPAN_NAME_LOOKUP); + assertTrue( + hasEvent( + span, + SPAN_NAME_LOOKUP + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_RECEIVED, 0) + .put(ATTRIBUTES_KEY_MISSING, 1) + .put(ATTRIBUTES_KEY_DEFERRED, 0) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + } + + @Test + public void allocateIdsTraceTest() throws Exception { + String kind1 = "kind1"; + KeyFactory keyFactory = datastore.newKeyFactory().setKind(kind1); + IncompleteKey pk1 = keyFactory.newKey(); + Key key1 = datastore.allocateId(pk1); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_ALLOCATE_IDS); + } + + @Test + public void reserveIdsTraceTest() throws Exception { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind"); + Key key1 = keyFactory.newKey(10); + Key key2 = keyFactory.newKey("name"); + List keyList = datastore.reserveIds(key1, key2); + assertEquals(2, keyList.size()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_RESERVE_IDS); + } + + @Test + public void commitTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.add(entity1); + assertEquals(entity1, response); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + } + + @Test + public void putTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + } + + @Test + public void updateTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + + SpanData spanData = getSpanByName(SPAN_NAME_COMMIT); + assertTrue( + hasEvent( + spanData, + SPAN_NAME_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, response.size()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + + // Clean Up test span context to verify update spans + cleanupTestSpanContext(); + + Entity entity1_update = Entity.newBuilder(entity1).set("test_field", "new_test_value1").build(); + Entity entity2_update = Entity.newBuilder(entity2).set("test_field", "new_test_value1").build(); + datastore.update(entity1_update, entity2_update); + + waitForTracesToComplete(); + + spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + } + + @Test + public void deleteTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + + SpanData spanData = getSpanByName(SPAN_NAME_COMMIT); + assertTrue( + hasEvent( + spanData, + SPAN_NAME_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + + // Clean Up test span context to verify update spans + cleanupTestSpanContext(); + + datastore.delete(entity1.getKey()); + + waitForTracesToComplete(); + + spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + + spanData = getSpanByName(SPAN_NAME_COMMIT); + assertTrue( + hasEvent( + spanData, + SPAN_NAME_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + } + + @Test + public void runQueryTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify RunQuery spans + cleanupTestSpanContext(); + + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_RUN_QUERY); + + SpanData span = getSpanByName(SPAN_NAME_RUN_QUERY); + assertTrue( + hasEvent( + span, + SPAN_NAME_RUN_QUERY + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_READ_CONSISTENCY, "READ_CONSISTENCY_UNSPECIFIED") + .put(ATTRIBUTES_KEY_MORE_RESULTS, "NO_MORE_RESULTS") + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + } + + @Test + public void runAggregationQueryTraceTest() throws Exception { + Entity entity1 = + Entity.newBuilder(KEY1) + .set("pepper_name", "jalapeno") + .set("max_scoville_level", 10000) + .build(); + Entity entity2 = + Entity.newBuilder(KEY2) + .set("pepper_name", "serrano") + .set("max_scoville_level", 25000) + .build(); + Entity entity3 = + Entity.newBuilder(KEY3) + .set("pepper_name", "habanero") + .set("max_scoville_level", 350000) + .build(); + Entity entity4 = + Entity.newBuilder(KEY4) + .set("pepper_name", "ghost") + .set("max_scoville_level", 1500000) + .build(); + + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + entityList.add(entity3); + entityList.add(entity4); + + List response = datastore.add(entity1, entity2, entity3, entity4); + assertEquals(entityList, response); + + // Clean Up test span context to verify RunAggregationQuery spans + cleanupTestSpanContext(); + + PropertyFilter mediumSpicyFilters = PropertyFilter.lt("max_scoville_level", 100000); + StructuredQuery mediumSpicyQuery = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(mediumSpicyFilters).build(); + AggregationQuery countSpicyPeppers = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("count")) + .over(mediumSpicyQuery) + .build(); + AggregationResults results = datastore.runAggregation(countSpicyPeppers); + assertThat(results.size()).isEqualTo(1); + AggregationResult result = results.get(0); + assertThat(result.getLong("count")).isEqualTo(2L); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_RUN_AGGREGATION_QUERY); + } + + @Test + public void newTransactionReadWriteTraceTest() throws Exception { + // Transaction.Begin + Transaction transaction = datastore.newTransaction(); + + // Transaction.Lookup + Entity entity = datastore.get(KEY1, ReadOption.transactionId(transaction.getTransactionId())); + assertNull(entity); + + Entity updatedEntity = Entity.newBuilder(KEY1).set("test_field", "new_test_value1").build(); + transaction.put(updatedEntity); + + // Transaction.Commit + transaction.commit(); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + + assertSpanHierarchy(SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_LOOKUP); + SpanData span = getSpanByName(SPAN_NAME_TRANSACTION_LOOKUP); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_LOOKUP + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DEFERRED, 0) + .put(ATTRIBUTES_KEY_MISSING, 1) + .put(ATTRIBUTES_KEY_RECEIVED, 0) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + + assertSpanHierarchy(SPAN_NAME_TRANSACTION_COMMIT); + span = getSpanByName(SPAN_NAME_TRANSACTION_COMMIT); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + } + + @Test + public void newTransactionQueryTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify Transaction RunQuery spans + cleanupTestSpanContext(); + + Transaction transaction = datastore.newTransaction(); + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = transaction.run(query); + transaction.commit(); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + + assertSpanHierarchy(SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN_QUERY); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_COMMIT); + SpanData span = getSpanByName(SPAN_NAME_TRANSACTION_RUN_QUERY); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_RUN_QUERY + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_READ_CONSISTENCY, "READ_CONSISTENCY_UNSPECIFIED") + .put(ATTRIBUTES_KEY_MORE_RESULTS, "NO_MORE_RESULTS") + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + } + + @Test + public void newTransactionRollbackTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("pepper_type", "jalapeno").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("pepper_type", "habanero").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify Transaction Rollback spans + cleanupTestSpanContext(); + + String simplified_spice_level = "not_spicy"; + Entity entity1update = + Entity.newBuilder(entity1).set("spice_level", simplified_spice_level).build(); + Transaction transaction = datastore.newTransaction(); + entity1 = transaction.get(KEY1); + switch (entity1.getString("pepper_type")) { + case "jalapeno": + simplified_spice_level = "mild"; + break; + + case "habanero": + simplified_spice_level = "hot"; + break; + } + transaction.update(entity1update); + transaction.delete(KEY2); + transaction.rollback(); + assertFalse(transaction.isActive()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + + assertSpanHierarchy(SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_LOOKUP); + SpanData span = getSpanByName(SPAN_NAME_TRANSACTION_LOOKUP); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_LOOKUP + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DEFERRED, 0) + .put(ATTRIBUTES_KEY_MISSING, 0) + .put(ATTRIBUTES_KEY_RECEIVED, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + + assertSpanHierarchy(SPAN_NAME_ROLLBACK); + span = getSpanByName(SPAN_NAME_ROLLBACK); + assertTrue( + hasEvent( + span, + SPAN_NAME_ROLLBACK, + Attributes.builder() + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + } + + @Test + public void runInTransactionQueryTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify Transaction Rollback spans + cleanupTestSpanContext(); + + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + Datastore.TransactionCallable callable = + transaction -> { + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + return true; + }; + datastore.runInTransaction(callable); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(4, spans.size()); + + // Since the runInTransaction method runs the TransactionCallable opaquely in a transaction + // there is no way for the API user to know the transaction ID, so we will not validate it here. + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_RUN_QUERY); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_TRANSACTION_COMMIT); + } +} diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java index 4706e3b86..a0e778cee 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java @@ -41,8 +41,8 @@ public class ExecutionStatsTest { @Test public void testModel() { Truth.assertThat(executionStats.getDebugStats()).isEqualTo(Structs.asMap(struct)); - Truth.assertThat(executionStats.getExecutionDuration()) - .isEqualTo(org.threeten.bp.Duration.ofNanos(duration.getNanos())); + Truth.assertThat(executionStats.getExecutionDurationJavaTime()) + .isEqualTo(java.time.Duration.ofNanos(duration.getNanos())); Truth.assertThat(executionStats.getReadOperations()).isEqualTo(2); Truth.assertThat(executionStats.getResultsReturned()).isEqualTo(3); } diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/DisabledTraceUtilTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/DisabledTraceUtilTest.java new file mode 100644 index 000000000..c80ef9353 --- /dev/null +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/DisabledTraceUtilTest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2024 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.cloud.datastore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.Test; + +public class DisabledTraceUtilTest { + @Test + public void disabledTraceUtilDoesNotProvideChannelConfigurator() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.getChannelConfigurator()).isNull(); + } + + @Test + public void usesDisabledContext() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.getCurrentContext() instanceof DisabledTraceUtil.Context).isTrue(); + } + + @Test + public void usesDisabledSpan() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.getCurrentSpan() instanceof DisabledTraceUtil.Span).isTrue(); + assertThat(traceUtil.startSpan("foo") instanceof DisabledTraceUtil.Span).isTrue(); + assertThat( + traceUtil.startSpan("foo", traceUtil.getCurrentSpan()) + instanceof DisabledTraceUtil.Span) + .isTrue(); + } + + @Test + public void usesDisabledScope() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.getCurrentContext().makeCurrent() instanceof DisabledTraceUtil.Scope) + .isTrue(); + assertThat(traceUtil.getCurrentSpan().makeCurrent() instanceof DisabledTraceUtil.Scope) + .isTrue(); + } +} diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/EnabledTraceUtilTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/EnabledTraceUtilTest.java new file mode 100644 index 000000000..50d7b6820 --- /dev/null +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/EnabledTraceUtilTest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2024 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.cloud.datastore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.NoCredentials; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; +import com.google.cloud.datastore.DatastoreOptions; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import org.junit.Before; +import org.junit.Test; + +public class EnabledTraceUtilTest { + @Before + public void setUp() { + GlobalOpenTelemetry.resetForTest(); + } + + DatastoreOptions.Builder getBaseOptions() { + return DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()); + } + + DatastoreOptions getTracingEnabledOptions() { + return getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()) + .build(); + } + + EnabledTraceUtil newEnabledTraceUtil() { + return new EnabledTraceUtil(getTracingEnabledOptions()); + } + + @Test + public void usesOpenTelemetryFromOptions() { + OpenTelemetrySdk myOpenTelemetrySdk = OpenTelemetrySdk.builder().build(); + DatastoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder() + .setTracingEnabled(true) + .setOpenTelemetry(myOpenTelemetrySdk) + .build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(firestoreOptions); + assertThat(traceUtil.getOpenTelemetry()).isEqualTo(myOpenTelemetrySdk); + } + + @Test + public void usesGlobalOpenTelemetryIfOpenTelemetryInstanceNotProvided() { + OpenTelemetrySdk ignored = OpenTelemetrySdk.builder().buildAndRegisterGlobal(); + DatastoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(firestoreOptions); + assertThat(traceUtil.getOpenTelemetry()).isEqualTo(GlobalOpenTelemetry.get()); + } + + @Test + public void enabledTraceUtilProvidesChannelConfigurator() { + assertThat(newEnabledTraceUtil().getChannelConfigurator()).isNull(); + } + + @Test + public void usesEnabledContext() { + assertThat(newEnabledTraceUtil().getCurrentContext() instanceof EnabledTraceUtil.Context) + .isTrue(); + } + + @Test + public void usesEnabledSpan() { + EnabledTraceUtil traceUtil = newEnabledTraceUtil(); + assertThat(traceUtil.getCurrentSpan() instanceof EnabledTraceUtil.Span).isTrue(); + assertThat(traceUtil.startSpan("foo") != null).isTrue(); + assertThat( + traceUtil.startSpan("foo", traceUtil.getCurrentSpan()) instanceof EnabledTraceUtil.Span) + .isTrue(); + } + + @Test + public void usesEnabledScope() { + EnabledTraceUtil traceUtil = newEnabledTraceUtil(); + assertThat(traceUtil.getCurrentContext().makeCurrent() instanceof EnabledTraceUtil.Scope) + .isTrue(); + assertThat(traceUtil.getCurrentSpan().makeCurrent() instanceof EnabledTraceUtil.Scope).isTrue(); + } +} diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/TraceUtilTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/TraceUtilTest.java new file mode 100644 index 000000000..f1cce8006 --- /dev/null +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/TraceUtilTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2024 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.cloud.datastore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.NoCredentials; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; +import com.google.cloud.datastore.DatastoreOptions; +import org.junit.Test; + +public class TraceUtilTest { + @Test + public void defaultOptionsUseDisabledTraceUtil() { + TraceUtil traceUtil = + TraceUtil.getInstance( + DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()) + .build()); + assertThat(traceUtil instanceof DisabledTraceUtil).isTrue(); + } + + @Test + public void tracingDisabledOptionsUseDisabledTraceUtil() { + TraceUtil traceUtil = + TraceUtil.getInstance( + DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()) + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(false).build()) + .build()); + assertThat(traceUtil instanceof DisabledTraceUtil).isTrue(); + } + + @Test + public void tracingEnabledOptionsUseEnabledTraceUtil() { + TraceUtil traceUtil = + TraceUtil.getInstance( + DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()) + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()) + .build()); + assertThat(traceUtil instanceof EnabledTraceUtil).isTrue(); + } +} diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java index 3ebd3ef4a..dfa2255a0 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Duration; import java.util.concurrent.TimeoutException; import org.junit.After; import org.junit.Assert; @@ -39,7 +40,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class ITLocalDatastoreHelperTest { @@ -178,7 +178,7 @@ public void testStartStopReset() throws IOException, InterruptedException, Timeo assertNotNull(datastore.get(key)); helper.reset(); assertNull(datastore.get(key)); - helper.stop(Duration.ofMinutes(1)); + helper.stopDuration(Duration.ofMinutes(1)); datastore.get(key); Assert.fail(); } catch (DatastoreException ex) { @@ -198,7 +198,7 @@ public void testStartStopResetWithBuilder() assertNotNull(datastore.get(key)); helper.reset(); assertNull(datastore.get(key)); - helper.stop(Duration.ofMinutes(1)); + helper.stopDuration(Duration.ofMinutes(1)); datastore.get(key); Assert.fail(); } catch (DatastoreException ex) { diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java similarity index 74% rename from google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java rename to google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java index 596ce96d8..a4b389a1e 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java @@ -19,14 +19,17 @@ import com.google.api.core.InternalApi; import com.google.api.gax.retrying.RetrySettings; import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; import com.google.cloud.datastore.DatastoreOptions; import com.google.cloud.datastore.Key; import com.google.cloud.datastore.Query; import com.google.cloud.datastore.QueryResults; import com.google.cloud.datastore.StructuredQuery; import com.google.cloud.http.HttpTransportOptions; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import java.time.Duration; import java.util.UUID; -import org.threeten.bp.Duration; +import javax.annotation.Nullable; /** * Utility to create a remote datastore configuration for testing. Datastore options can be obtained @@ -38,13 +41,13 @@ * RetrySettings#getTotalTimeout()} is {@code 120000} and {@link * RetrySettings#getInitialRetryDelay()} is {@code 250}. {@link * HttpTransportOptions#getConnectTimeout()} and {@link HttpTransportOptions#getReadTimeout()} are - * both both set to {@code 60000}. + * both both set to {@code 60000}. If an OpenTelemetrySdk object is passed in, OpenTelemetry Trace + * collection will be enabled for the Client application. * *

Internal testing use only */ @InternalApi public class RemoteDatastoreHelper { - private final DatastoreOptions options; private final Datastore datastore; private final String namespace; @@ -78,30 +81,42 @@ public static RemoteDatastoreHelper create() { } /** Creates a {@code RemoteStorageHelper} object. */ - public static RemoteDatastoreHelper create(String databaseId) { + public static RemoteDatastoreHelper create( + String databaseId, @Nullable OpenTelemetrySdk openTelemetrySdk) { HttpTransportOptions transportOptions = DatastoreOptions.getDefaultHttpTransportOptions(); transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build(); - DatastoreOptions datastoreOption = + DatastoreOptions.Builder datastoreOptionBuilder = DatastoreOptions.newBuilder() .setDatabaseId(databaseId) .setNamespace(UUID.randomUUID().toString()) .setRetrySettings(retrySettings()) - .setTransportOptions(transportOptions) - .build(); - return new RemoteDatastoreHelper(datastoreOption); + .setTransportOptions(transportOptions); + + if (openTelemetrySdk != null) { + datastoreOptionBuilder.setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder() + .setOpenTelemetry(openTelemetrySdk) + .setTracingEnabled(true) + .build()); + } + return new RemoteDatastoreHelper(datastoreOptionBuilder.build()); + } + + public static RemoteDatastoreHelper create(String databaseId) { + return create(databaseId, /*openTelemetrySdk=*/ null); } private static RetrySettings retrySettings() { return RetrySettings.newBuilder() .setMaxAttempts(10) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(120000L)) - .setInitialRetryDelay(Duration.ofMillis(250L)) + .setMaxRetryDelayDuration(Duration.ofMillis(30000L)) + .setTotalTimeoutDuration(Duration.ofMillis(120000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(250L)) .setRetryDelayMultiplier(1.0) - .setInitialRpcTimeout(Duration.ofMillis(120000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(120000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(120000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(120000L)) .build(); } } diff --git a/grpc-google-cloud-datastore-admin-v1/pom.xml b/grpc-google-cloud-datastore-admin-v1/pom.xml index 150832cde..74b964682 100644 --- a/grpc-google-cloud-datastore-admin-v1/pom.xml +++ b/grpc-google-cloud-datastore-admin-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-datastore-admin-v1 - 2.19.2-SNAPSHOT + 2.25.1 grpc-google-cloud-datastore-admin-v1 GRPC library for google-cloud-datastore com.google.cloud google-cloud-datastore-parent - 2.19.2-SNAPSHOT + 2.25.1 diff --git a/pom.xml b/pom.xml index eeb20ad87..4a8583e61 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-datastore-parent pom - 2.19.2-SNAPSHOT + 2.25.1 Google Cloud Datastore Parent https://github.com/googleapis/java-datastore @@ -14,7 +14,7 @@ com.google.cloud sdk-platform-java-config - 3.29.0 + 3.41.0 @@ -143,7 +143,7 @@ github google-cloud-datastore-parent https://googleapis.dev/java/google-api-grpc/latest - 2.27.0 + 2.31.0 @@ -159,27 +159,27 @@ com.google.api.grpc proto-google-cloud-datastore-admin-v1 - 2.19.2-SNAPSHOT + 2.25.1 com.google.api.grpc grpc-google-cloud-datastore-admin-v1 - 2.19.2-SNAPSHOT + 2.25.1 com.google.cloud google-cloud-datastore - 2.19.2-SNAPSHOT + 2.25.1 com.google.api.grpc proto-google-cloud-datastore-v1 - 0.110.2-SNAPSHOT + 0.116.1 com.google.cloud.datastore datastore-v1-proto-client - 2.19.2-SNAPSHOT + 2.25.1 com.google.api.grpc @@ -197,7 +197,7 @@ org.easymock easymock - 5.2.0 + 5.4.0 test diff --git a/proto-google-cloud-datastore-admin-v1/clirr-ignored-differences.xml b/proto-google-cloud-datastore-admin-v1/clirr-ignored-differences.xml index c384c422e..7cf3ac808 100644 --- a/proto-google-cloud-datastore-admin-v1/clirr-ignored-differences.xml +++ b/proto-google-cloud-datastore-admin-v1/clirr-ignored-differences.xml @@ -16,4 +16,66 @@ com/google/datastore/admin/v1/*OrBuilder boolean has*(*) + + + + 7006 + com/google/datastore/admin/v1/** + * getDefaultInstanceForType() + ** + + + 7006 + com/google/datastore/admin/v1/** + * addRepeatedField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * clear() + ** + + + 7006 + com/google/datastore/admin/v1/** + * clearField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * clearOneof(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * clone() + ** + + + 7006 + com/google/datastore/admin/v1/** + * mergeUnknownFields(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * setField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * setRepeatedField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * setUnknownFields(*) + ** + diff --git a/proto-google-cloud-datastore-admin-v1/pom.xml b/proto-google-cloud-datastore-admin-v1/pom.xml index 58e80a474..28ed4b0e7 100644 --- a/proto-google-cloud-datastore-admin-v1/pom.xml +++ b/proto-google-cloud-datastore-admin-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-datastore-admin-v1 - 2.19.2-SNAPSHOT + 2.25.1 proto-google-cloud-datastore-admin-v1 Proto library for google-cloud-datastore com.google.cloud google-cloud-datastore-parent - 2.19.2-SNAPSHOT + 2.25.1 diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadata.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadata.java index 2c078756d..3bd274168 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadata.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadata.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadataOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadataOrBuilder.java index fa127dc7c..3ef2919c4 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadataOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadataOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface CommonMetadataOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequest.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequest.java index c86b9a967..6a14a8152 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequest.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequestOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequestOrBuilder.java index 537fb10b9..0d87e8faa 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequestOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface CreateIndexRequestOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminProto.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminProto.java index 9a4bb925f..838a55b36 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminProto.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminProto.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public final class DatastoreAdminProto { diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadata.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadata.java index a0695ffd0..ea0e28ff1 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadata.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadata.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadataOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadataOrBuilder.java index 3bf3c03f8..2f6c2ae7c 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadataOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadataOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface DatastoreFirestoreMigrationMetadataOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequest.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequest.java index 0b82ce7cc..d4f87d2a8 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequest.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequestOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequestOrBuilder.java index 9ac5d5411..ab53b6df5 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequestOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface DeleteIndexRequestOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilter.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilter.java index a4c6617c3..3a6b14377 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilter.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilter.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilterOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilterOrBuilder.java index 59fff0657..3f75daeff 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilterOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilterOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface EntityFilterOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadata.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadata.java index 360a2c5c6..a6bded093 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadata.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadata.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadataOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadataOrBuilder.java index a65dedc9c..099f4bb5b 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadataOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadataOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ExportEntitiesMetadataOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequest.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequest.java index acad36a3e..88eeb5b0f 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequest.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequestOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequestOrBuilder.java index 01f5ec35d..9ddd587f9 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequestOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ExportEntitiesRequestOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponse.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponse.java index fd3350685..b4f183c04 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponse.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponse.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponseOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponseOrBuilder.java index 77bf913fb..338f4ff99 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponseOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponseOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ExportEntitiesResponseOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequest.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequest.java index 00fb79822..2513a6c2b 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequest.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequestOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequestOrBuilder.java index e33a2bd2e..da3d4617d 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequestOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface GetIndexRequestOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadata.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadata.java index f89135ebd..9e8265e49 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadata.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadata.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadataOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadataOrBuilder.java index 71c6928af..2ed2c3684 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadataOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadataOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ImportEntitiesMetadataOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequest.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequest.java index 596bbfa1a..1ca992dd5 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequest.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequestOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequestOrBuilder.java index 922616586..c1d8424fe 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequestOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ImportEntitiesRequestOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Index.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Index.java index 7244182dc..cb5c4b96c 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Index.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Index.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/index.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadata.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadata.java index 96b2a12ac..c524fb3b2 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadata.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadata.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadataOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadataOrBuilder.java index 20348e044..e85b0747a 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadataOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadataOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface IndexOperationMetadataOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOrBuilder.java index 25373353b..b45823f6a 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/index.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface IndexOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexProto.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexProto.java index 9dbdecdf1..e44ad1c73 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexProto.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexProto.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/index.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public final class IndexProto { diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequest.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequest.java index 5eb553c33..8472db7dc 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequest.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequestOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequestOrBuilder.java index 389feb19a..dc18f1b63 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequestOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ListIndexesRequestOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponse.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponse.java index 05da1f24d..abce952f3 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponse.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponse.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponseOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponseOrBuilder.java index e6b8e4376..a305da039 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponseOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponseOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ListIndexesResponseOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEvent.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEvent.java index d69e36b88..a35cd49ca 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEvent.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEvent.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/migration.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEventOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEventOrBuilder.java index 68441b30b..4db619cd0 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEventOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEventOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/migration.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface MigrationProgressEventOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProto.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProto.java index 0c1110444..63e6e1186 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProto.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProto.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/migration.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public final class MigrationProto { diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationState.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationState.java index 1cc537677..a5b46ab83 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationState.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationState.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/migration.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEvent.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEvent.java index 54f20a287..203980b3a 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEvent.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEvent.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/migration.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEventOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEventOrBuilder.java index 3920f71c7..de901f9e3 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEventOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEventOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/migration.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface MigrationStateEventOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStep.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStep.java index 6810cfd53..46a80ff31 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStep.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStep.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/migration.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/OperationType.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/OperationType.java index b8a5f327b..34316b3be 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/OperationType.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/OperationType.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Progress.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Progress.java index 347508413..7e010b15d 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Progress.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Progress.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; /** diff --git a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ProgressOrBuilder.java b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ProgressOrBuilder.java index faa613564..cc6b6c27b 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ProgressOrBuilder.java +++ b/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ProgressOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/admin/v1/datastore_admin.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.admin.v1; public interface ProgressOrBuilder diff --git a/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/datastore_admin.proto b/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/datastore_admin.proto index 79ca3df68..a8b3f9986 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/datastore_admin.proto +++ b/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/datastore_admin.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/index.proto b/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/index.proto index 60bb5af5f..6a1d12227 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/index.proto +++ b/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/index.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/migration.proto b/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/migration.proto index e5f7477da..813de87dd 100644 --- a/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/migration.proto +++ b/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/migration.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-datastore-v1/clirr-ignored-differences.xml b/proto-google-cloud-datastore-v1/clirr-ignored-differences.xml index 064bc1b32..34662f77c 100644 --- a/proto-google-cloud-datastore-v1/clirr-ignored-differences.xml +++ b/proto-google-cloud-datastore-v1/clirr-ignored-differences.xml @@ -58,4 +58,66 @@ STATS_FIELD_NUMBER 6011 + + + + 7006 + com/google/datastore/v1/** + * getDefaultInstanceForType() + ** + + + 7006 + com/google/datastore/v1/** + * addRepeatedField(*) + ** + + + 7006 + com/google/datastore/v1/** + * clear() + ** + + + 7006 + com/google/datastore/v1/** + * clearField(*) + ** + + + 7006 + com/google/datastore/v1/** + * clearOneof(*) + ** + + + 7006 + com/google/datastore/v1/** + * clone() + ** + + + 7006 + com/google/datastore/v1/** + * mergeUnknownFields(*) + ** + + + 7006 + com/google/datastore/v1/** + * setField(*) + ** + + + 7006 + com/google/datastore/v1/** + * setRepeatedField(*) + ** + + + 7006 + com/google/datastore/v1/** + * setUnknownFields(*) + ** + diff --git a/proto-google-cloud-datastore-v1/pom.xml b/proto-google-cloud-datastore-v1/pom.xml index f7533666e..a2fc2f2a8 100644 --- a/proto-google-cloud-datastore-v1/pom.xml +++ b/proto-google-cloud-datastore-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-datastore-v1 - 0.110.2-SNAPSHOT + 0.116.1 proto-google-cloud-datastore-v1 PROTO library for proto-google-cloud-datastore-v1 com.google.cloud google-cloud-datastore-parent - 2.19.2-SNAPSHOT + 2.25.1 diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQuery.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQuery.java index 654257a1d..fa056f1b1 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQuery.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQuery.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQueryOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQueryOrBuilder.java index bfb5e8448..d71b7a7ec 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQueryOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQueryOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface AggregationQueryOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResult.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResult.java index 5a6afdcff..5566884f0 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResult.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResult.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/aggregation_result.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatch.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatch.java index 040d282df..d40e87f16 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatch.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatch.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/aggregation_result.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatchOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatchOrBuilder.java index 5c1fb1daa..280f19bd4 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatchOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatchOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/aggregation_result.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface AggregationResultBatchOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultOrBuilder.java index 4bcde0f95..470d13243 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/aggregation_result.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface AggregationResultOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultProto.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultProto.java index a924705f1..5a3b32a73 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultProto.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultProto.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/aggregation_result.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public final class AggregationResultProto { @@ -63,13 +63,13 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "tastore.v1.AggregationResult\022K\n\014more_res" + "ults\030\002 \001(\01625.google.datastore.v1.QueryRe" + "sultBatch.MoreResultsType\022-\n\tread_time\030\003" - + " \001(\0132\032.google.protobuf.TimestampB\310\001\n\027com" + + " \001(\0132\032.google.protobuf.TimestampB\307\001\n\027com" + ".google.datastore.v1B\026AggregationResultP" - + "rotoP\001Z + * Nearest Neighbors search config. The ordering provided by FindNearest + * supersedes the order_by stage. If multiple documents have the same vector + * distance, the returned document order is not guaranteed to be stable between + * queries. + * + * + * Protobuf type {@code google.datastore.v1.FindNearest} + */ +public final class FindNearest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.FindNearest) + FindNearestOrBuilder { + private static final long serialVersionUID = 0L; + // Use FindNearest.newBuilder() to construct. + private FindNearest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private FindNearest() { + distanceMeasure_ = 0; + distanceResultProperty_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new FindNearest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.FindNearest.class, + com.google.datastore.v1.FindNearest.Builder.class); + } + + /** + * + * + *

+   * The distance measure to use when comparing vectors.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.FindNearest.DistanceMeasure} + */ + public enum DistanceMeasure implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Should not be set.
+     * 
+ * + * DISTANCE_MEASURE_UNSPECIFIED = 0; + */ + DISTANCE_MEASURE_UNSPECIFIED(0), + /** + * + * + *
+     * Measures the EUCLIDEAN distance between the vectors. See
+     * [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
+     * more. The resulting distance decreases the more similar two vectors are.
+     * 
+ * + * EUCLIDEAN = 1; + */ + EUCLIDEAN(1), + /** + * + * + *
+     * COSINE distance compares vectors based on the angle between them, which
+     * allows you to measure similarity that isn't based on the vectors
+     * magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
+     * instead of COSINE distance, which is mathematically equivalent with
+     * better performance. See [Cosine
+     * Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
+     * more about COSINE similarity and COSINE distance. The resulting COSINE
+     * distance decreases the more similar two vectors are.
+     * 
+ * + * COSINE = 2; + */ + COSINE(2), + /** + * + * + *
+     * Similar to cosine but is affected by the magnitude of the vectors. See
+     * [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
+     * The resulting distance increases the more similar two vectors are.
+     * 
+ * + * DOT_PRODUCT = 3; + */ + DOT_PRODUCT(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Should not be set.
+     * 
+ * + * DISTANCE_MEASURE_UNSPECIFIED = 0; + */ + public static final int DISTANCE_MEASURE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * Measures the EUCLIDEAN distance between the vectors. See
+     * [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
+     * more. The resulting distance decreases the more similar two vectors are.
+     * 
+ * + * EUCLIDEAN = 1; + */ + public static final int EUCLIDEAN_VALUE = 1; + /** + * + * + *
+     * COSINE distance compares vectors based on the angle between them, which
+     * allows you to measure similarity that isn't based on the vectors
+     * magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
+     * instead of COSINE distance, which is mathematically equivalent with
+     * better performance. See [Cosine
+     * Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
+     * more about COSINE similarity and COSINE distance. The resulting COSINE
+     * distance decreases the more similar two vectors are.
+     * 
+ * + * COSINE = 2; + */ + public static final int COSINE_VALUE = 2; + /** + * + * + *
+     * Similar to cosine but is affected by the magnitude of the vectors. See
+     * [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
+     * The resulting distance increases the more similar two vectors are.
+     * 
+ * + * DOT_PRODUCT = 3; + */ + public static final int DOT_PRODUCT_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DistanceMeasure valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static DistanceMeasure forNumber(int value) { + switch (value) { + case 0: + return DISTANCE_MEASURE_UNSPECIFIED; + case 1: + return EUCLIDEAN; + case 2: + return COSINE; + case 3: + return DOT_PRODUCT; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DistanceMeasure findValueByNumber(int number) { + return DistanceMeasure.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.FindNearest.getDescriptor().getEnumTypes().get(0); + } + + private static final DistanceMeasure[] VALUES = values(); + + public static DistanceMeasure valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DistanceMeasure(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.FindNearest.DistanceMeasure) + } + + private int bitField0_; + public static final int VECTOR_PROPERTY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PropertyReference vectorProperty_; + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorProperty field is set. + */ + @java.lang.Override + public boolean hasVectorProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorProperty. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getVectorProperty() { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getVectorPropertyOrBuilder() { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } + + public static final int QUERY_VECTOR_FIELD_NUMBER = 2; + private com.google.datastore.v1.Value queryVector_; + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + @java.lang.Override + public boolean hasQueryVector() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + @java.lang.Override + public com.google.datastore.v1.Value getQueryVector() { + return queryVector_ == null ? com.google.datastore.v1.Value.getDefaultInstance() : queryVector_; + } + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + return queryVector_ == null ? com.google.datastore.v1.Value.getDefaultInstance() : queryVector_; + } + + public static final int DISTANCE_MEASURE_FIELD_NUMBER = 3; + private int distanceMeasure_ = 0; + /** + * + * + *
+   * Required. The Distance Measure to use, required.
+   * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + @java.lang.Override + public int getDistanceMeasureValue() { + return distanceMeasure_; + } + /** + * + * + *
+   * Required. The Distance Measure to use, required.
+   * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.datastore.v1.FindNearest.DistanceMeasure getDistanceMeasure() { + com.google.datastore.v1.FindNearest.DistanceMeasure result = + com.google.datastore.v1.FindNearest.DistanceMeasure.forNumber(distanceMeasure_); + return result == null + ? com.google.datastore.v1.FindNearest.DistanceMeasure.UNRECOGNIZED + : result; + } + + public static final int LIMIT_FIELD_NUMBER = 4; + private com.google.protobuf.Int32Value limit_; + /** + * + * + *
+   * Required. The number of nearest neighbors to return. Must be a positive
+   * integer of no more than 100.
+   * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the limit field is set. + */ + @java.lang.Override + public boolean hasLimit() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+   * Required. The number of nearest neighbors to return. Must be a positive
+   * integer of no more than 100.
+   * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The limit. + */ + @java.lang.Override + public com.google.protobuf.Int32Value getLimit() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + /** + * + * + *
+   * Required. The number of nearest neighbors to return. Must be a positive
+   * integer of no more than 100.
+   * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + @java.lang.Override + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + + public static final int DISTANCE_RESULT_PROPERTY_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object distanceResultProperty_ = ""; + /** + * + * + *
+   * Optional. Optional name of the field to output the result of the vector
+   * distance calculation. Must conform to [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultProperty. + */ + @java.lang.Override + public java.lang.String getDistanceResultProperty() { + java.lang.Object ref = distanceResultProperty_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + distanceResultProperty_ = s; + return s; + } + } + /** + * + * + *
+   * Optional. Optional name of the field to output the result of the vector
+   * distance calculation. Must conform to [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultProperty. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDistanceResultPropertyBytes() { + java.lang.Object ref = distanceResultProperty_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + distanceResultProperty_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DISTANCE_THRESHOLD_FIELD_NUMBER = 6; + private com.google.protobuf.DoubleValue distanceThreshold_; + /** + * + * + *
+   * Optional. Option to specify a threshold for which no less similar documents
+   * will be returned. The behavior of the specified `distance_measure` will
+   * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+   * increase when the vectors are more similar, the comparison is inverted.
+   *
+   * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+   * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+   * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the distanceThreshold field is set. + */ + @java.lang.Override + public boolean hasDistanceThreshold() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+   * Optional. Option to specify a threshold for which no less similar documents
+   * will be returned. The behavior of the specified `distance_measure` will
+   * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+   * increase when the vectors are more similar, the comparison is inverted.
+   *
+   * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+   * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+   * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The distanceThreshold. + */ + @java.lang.Override + public com.google.protobuf.DoubleValue getDistanceThreshold() { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } + /** + * + * + *
+   * Optional. Option to specify a threshold for which no less similar documents
+   * will be returned. The behavior of the specified `distance_measure` will
+   * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+   * increase when the vectors are more similar, the comparison is inverted.
+   *
+   * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+   * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+   * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.protobuf.DoubleValueOrBuilder getDistanceThresholdOrBuilder() { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getVectorProperty()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.datastore.v1.FindNearest.DistanceMeasure.DISTANCE_MEASURE_UNSPECIFIED + .getNumber()) { + output.writeEnum(3, distanceMeasure_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getLimit()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(distanceResultProperty_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, distanceResultProperty_); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(6, getDistanceThreshold()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getVectorProperty()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.datastore.v1.FindNearest.DistanceMeasure.DISTANCE_MEASURE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, distanceMeasure_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getLimit()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(distanceResultProperty_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, distanceResultProperty_); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getDistanceThreshold()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.datastore.v1.FindNearest)) { + return super.equals(obj); + } + com.google.datastore.v1.FindNearest other = (com.google.datastore.v1.FindNearest) obj; + + if (hasVectorProperty() != other.hasVectorProperty()) return false; + if (hasVectorProperty()) { + if (!getVectorProperty().equals(other.getVectorProperty())) return false; + } + if (hasQueryVector() != other.hasQueryVector()) return false; + if (hasQueryVector()) { + if (!getQueryVector().equals(other.getQueryVector())) return false; + } + if (distanceMeasure_ != other.distanceMeasure_) return false; + if (hasLimit() != other.hasLimit()) return false; + if (hasLimit()) { + if (!getLimit().equals(other.getLimit())) return false; + } + if (!getDistanceResultProperty().equals(other.getDistanceResultProperty())) return false; + if (hasDistanceThreshold() != other.hasDistanceThreshold()) return false; + if (hasDistanceThreshold()) { + if (!getDistanceThreshold().equals(other.getDistanceThreshold())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasVectorProperty()) { + hash = (37 * hash) + VECTOR_PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getVectorProperty().hashCode(); + } + if (hasQueryVector()) { + hash = (37 * hash) + QUERY_VECTOR_FIELD_NUMBER; + hash = (53 * hash) + getQueryVector().hashCode(); + } + hash = (37 * hash) + DISTANCE_MEASURE_FIELD_NUMBER; + hash = (53 * hash) + distanceMeasure_; + if (hasLimit()) { + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + getLimit().hashCode(); + } + hash = (37 * hash) + DISTANCE_RESULT_PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getDistanceResultProperty().hashCode(); + if (hasDistanceThreshold()) { + hash = (37 * hash) + DISTANCE_THRESHOLD_FIELD_NUMBER; + hash = (53 * hash) + getDistanceThreshold().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.FindNearest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.FindNearest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.datastore.v1.FindNearest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Nearest Neighbors search config. The ordering provided by FindNearest
+   * supersedes the order_by stage. If multiple documents have the same vector
+   * distance, the returned document order is not guaranteed to be stable between
+   * queries.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.FindNearest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.FindNearest) + com.google.datastore.v1.FindNearestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.FindNearest.class, + com.google.datastore.v1.FindNearest.Builder.class); + } + + // Construct using com.google.datastore.v1.FindNearest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getVectorPropertyFieldBuilder(); + getQueryVectorFieldBuilder(); + getLimitFieldBuilder(); + getDistanceThresholdFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + vectorProperty_ = null; + if (vectorPropertyBuilder_ != null) { + vectorPropertyBuilder_.dispose(); + vectorPropertyBuilder_ = null; + } + queryVector_ = null; + if (queryVectorBuilder_ != null) { + queryVectorBuilder_.dispose(); + queryVectorBuilder_ = null; + } + distanceMeasure_ = 0; + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + distanceResultProperty_ = ""; + distanceThreshold_ = null; + if (distanceThresholdBuilder_ != null) { + distanceThresholdBuilder_.dispose(); + distanceThresholdBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.FindNearest getDefaultInstanceForType() { + return com.google.datastore.v1.FindNearest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.FindNearest build() { + com.google.datastore.v1.FindNearest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.FindNearest buildPartial() { + com.google.datastore.v1.FindNearest result = new com.google.datastore.v1.FindNearest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.FindNearest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.vectorProperty_ = + vectorPropertyBuilder_ == null ? vectorProperty_ : vectorPropertyBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.queryVector_ = + queryVectorBuilder_ == null ? queryVector_ : queryVectorBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.distanceMeasure_ = distanceMeasure_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.limit_ = limitBuilder_ == null ? limit_ : limitBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.distanceResultProperty_ = distanceResultProperty_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.distanceThreshold_ = + distanceThresholdBuilder_ == null + ? distanceThreshold_ + : distanceThresholdBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.FindNearest) { + return mergeFrom((com.google.datastore.v1.FindNearest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.FindNearest other) { + if (other == com.google.datastore.v1.FindNearest.getDefaultInstance()) return this; + if (other.hasVectorProperty()) { + mergeVectorProperty(other.getVectorProperty()); + } + if (other.hasQueryVector()) { + mergeQueryVector(other.getQueryVector()); + } + if (other.distanceMeasure_ != 0) { + setDistanceMeasureValue(other.getDistanceMeasureValue()); + } + if (other.hasLimit()) { + mergeLimit(other.getLimit()); + } + if (!other.getDistanceResultProperty().isEmpty()) { + distanceResultProperty_ = other.distanceResultProperty_; + bitField0_ |= 0x00000010; + onChanged(); + } + if (other.hasDistanceThreshold()) { + mergeDistanceThreshold(other.getDistanceThreshold()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(getVectorPropertyFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getQueryVectorFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + distanceMeasure_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + input.readMessage(getLimitFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + distanceResultProperty_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + input.readMessage( + getDistanceThresholdFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.datastore.v1.PropertyReference vectorProperty_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + vectorPropertyBuilder_; + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorProperty field is set. + */ + public boolean hasVectorProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorProperty. + */ + public com.google.datastore.v1.PropertyReference getVectorProperty() { + if (vectorPropertyBuilder_ == null) { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } else { + return vectorPropertyBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorProperty(com.google.datastore.v1.PropertyReference value) { + if (vectorPropertyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + vectorProperty_ = value; + } else { + vectorPropertyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorProperty( + com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (vectorPropertyBuilder_ == null) { + vectorProperty_ = builderForValue.build(); + } else { + vectorPropertyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeVectorProperty(com.google.datastore.v1.PropertyReference value) { + if (vectorPropertyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && vectorProperty_ != null + && vectorProperty_ != com.google.datastore.v1.PropertyReference.getDefaultInstance()) { + getVectorPropertyBuilder().mergeFrom(value); + } else { + vectorProperty_ = value; + } + } else { + vectorPropertyBuilder_.mergeFrom(value); + } + if (vectorProperty_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearVectorProperty() { + bitField0_ = (bitField0_ & ~0x00000001); + vectorProperty_ = null; + if (vectorPropertyBuilder_ != null) { + vectorPropertyBuilder_.dispose(); + vectorPropertyBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.PropertyReference.Builder getVectorPropertyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getVectorPropertyFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getVectorPropertyOrBuilder() { + if (vectorPropertyBuilder_ != null) { + return vectorPropertyBuilder_.getMessageOrBuilder(); + } else { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } + } + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getVectorPropertyFieldBuilder() { + if (vectorPropertyBuilder_ == null) { + vectorPropertyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + getVectorProperty(), getParentForChildren(), isClean()); + vectorProperty_ = null; + } + return vectorPropertyBuilder_; + } + + private com.google.datastore.v1.Value queryVector_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + queryVectorBuilder_; + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + public boolean hasQueryVector() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + public com.google.datastore.v1.Value getQueryVector() { + if (queryVectorBuilder_ == null) { + return queryVector_ == null + ? com.google.datastore.v1.Value.getDefaultInstance() + : queryVector_; + } else { + return queryVectorBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.datastore.v1.Value value) { + if (queryVectorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryVector_ = value; + } else { + queryVectorBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.datastore.v1.Value.Builder builderForValue) { + if (queryVectorBuilder_ == null) { + queryVector_ = builderForValue.build(); + } else { + queryVectorBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeQueryVector(com.google.datastore.v1.Value value) { + if (queryVectorBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && queryVector_ != null + && queryVector_ != com.google.datastore.v1.Value.getDefaultInstance()) { + getQueryVectorBuilder().mergeFrom(value); + } else { + queryVector_ = value; + } + } else { + queryVectorBuilder_.mergeFrom(value); + } + if (queryVector_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearQueryVector() { + bitField0_ = (bitField0_ & ~0x00000002); + queryVector_ = null; + if (queryVectorBuilder_ != null) { + queryVectorBuilder_.dispose(); + queryVectorBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Value.Builder getQueryVectorBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getQueryVectorFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + if (queryVectorBuilder_ != null) { + return queryVectorBuilder_.getMessageOrBuilder(); + } else { + return queryVector_ == null + ? com.google.datastore.v1.Value.getDefaultInstance() + : queryVector_; + } + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getQueryVectorFieldBuilder() { + if (queryVectorBuilder_ == null) { + queryVectorBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + getQueryVector(), getParentForChildren(), isClean()); + queryVector_ = null; + } + return queryVectorBuilder_; + } + + private int distanceMeasure_ = 0; + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + @java.lang.Override + public int getDistanceMeasureValue() { + return distanceMeasure_; + } + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The enum numeric value on the wire for distanceMeasure to set. + * @return This builder for chaining. + */ + public Builder setDistanceMeasureValue(int value) { + distanceMeasure_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.datastore.v1.FindNearest.DistanceMeasure getDistanceMeasure() { + com.google.datastore.v1.FindNearest.DistanceMeasure result = + com.google.datastore.v1.FindNearest.DistanceMeasure.forNumber(distanceMeasure_); + return result == null + ? com.google.datastore.v1.FindNearest.DistanceMeasure.UNRECOGNIZED + : result; + } + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The distanceMeasure to set. + * @return This builder for chaining. + */ + public Builder setDistanceMeasure(com.google.datastore.v1.FindNearest.DistanceMeasure value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + distanceMeasure_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return This builder for chaining. + */ + public Builder clearDistanceMeasure() { + bitField0_ = (bitField0_ & ~0x00000004); + distanceMeasure_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Int32Value limit_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + limitBuilder_; + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the limit field is set. + */ + public boolean hasLimit() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The limit. + */ + public com.google.protobuf.Int32Value getLimit() { + if (limitBuilder_ == null) { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } else { + return limitBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + public Builder setLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + limit_ = value; + } else { + limitBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + public Builder setLimit(com.google.protobuf.Int32Value.Builder builderForValue) { + if (limitBuilder_ == null) { + limit_ = builderForValue.build(); + } else { + limitBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + public Builder mergeLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && limit_ != null + && limit_ != com.google.protobuf.Int32Value.getDefaultInstance()) { + getLimitBuilder().mergeFrom(value); + } else { + limit_ = value; + } + } else { + limitBuilder_.mergeFrom(value); + } + if (limit_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + public Builder clearLimit() { + bitField0_ = (bitField0_ & ~0x00000008); + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + public com.google.protobuf.Int32Value.Builder getLimitBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getLimitFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + if (limitBuilder_ != null) { + return limitBuilder_.getMessageOrBuilder(); + } else { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + getLimitFieldBuilder() { + if (limitBuilder_ == null) { + limitBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder>( + getLimit(), getParentForChildren(), isClean()); + limit_ = null; + } + return limitBuilder_; + } + + private java.lang.Object distanceResultProperty_ = ""; + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultProperty. + */ + public java.lang.String getDistanceResultProperty() { + java.lang.Object ref = distanceResultProperty_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + distanceResultProperty_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultProperty. + */ + public com.google.protobuf.ByteString getDistanceResultPropertyBytes() { + java.lang.Object ref = distanceResultProperty_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + distanceResultProperty_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The distanceResultProperty to set. + * @return This builder for chaining. + */ + public Builder setDistanceResultProperty(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + distanceResultProperty_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearDistanceResultProperty() { + distanceResultProperty_ = getDefaultInstance().getDistanceResultProperty(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for distanceResultProperty to set. + * @return This builder for chaining. + */ + public Builder setDistanceResultPropertyBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + distanceResultProperty_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private com.google.protobuf.DoubleValue distanceThreshold_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder> + distanceThresholdBuilder_; + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the distanceThreshold field is set. + */ + public boolean hasDistanceThreshold() { + return ((bitField0_ & 0x00000020) != 0); + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The distanceThreshold. + */ + public com.google.protobuf.DoubleValue getDistanceThreshold() { + if (distanceThresholdBuilder_ == null) { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } else { + return distanceThresholdBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setDistanceThreshold(com.google.protobuf.DoubleValue value) { + if (distanceThresholdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + distanceThreshold_ = value; + } else { + distanceThresholdBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setDistanceThreshold(com.google.protobuf.DoubleValue.Builder builderForValue) { + if (distanceThresholdBuilder_ == null) { + distanceThreshold_ = builderForValue.build(); + } else { + distanceThresholdBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeDistanceThreshold(com.google.protobuf.DoubleValue value) { + if (distanceThresholdBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && distanceThreshold_ != null + && distanceThreshold_ != com.google.protobuf.DoubleValue.getDefaultInstance()) { + getDistanceThresholdBuilder().mergeFrom(value); + } else { + distanceThreshold_ = value; + } + } else { + distanceThresholdBuilder_.mergeFrom(value); + } + if (distanceThreshold_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearDistanceThreshold() { + bitField0_ = (bitField0_ & ~0x00000020); + distanceThreshold_ = null; + if (distanceThresholdBuilder_ != null) { + distanceThresholdBuilder_.dispose(); + distanceThresholdBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.DoubleValue.Builder getDistanceThresholdBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return getDistanceThresholdFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.DoubleValueOrBuilder getDistanceThresholdOrBuilder() { + if (distanceThresholdBuilder_ != null) { + return distanceThresholdBuilder_.getMessageOrBuilder(); + } else { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } + } + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar documents
+     * will be returned. The behavior of the specified `distance_measure` will
+     * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+     * increase when the vectors are more similar, the comparison is inverted.
+     *
+     * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+     * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder> + getDistanceThresholdFieldBuilder() { + if (distanceThresholdBuilder_ == null) { + distanceThresholdBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder>( + getDistanceThreshold(), getParentForChildren(), isClean()); + distanceThreshold_ = null; + } + return distanceThresholdBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.FindNearest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.FindNearest) + private static final com.google.datastore.v1.FindNearest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.FindNearest(); + } + + public static com.google.datastore.v1.FindNearest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FindNearest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.datastore.v1.FindNearest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearestOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearestOrBuilder.java new file mode 100644 index 000000000..ac7b994a6 --- /dev/null +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearestOrBuilder.java @@ -0,0 +1,269 @@ +/* + * Copyright 2024 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.5 +package com.google.datastore.v1; + +public interface FindNearestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.FindNearest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorProperty field is set. + */ + boolean hasVectorProperty(); + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorProperty. + */ + com.google.datastore.v1.PropertyReference getVectorProperty(); + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getVectorPropertyOrBuilder(); + + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + boolean hasQueryVector(); + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + com.google.datastore.v1.Value getQueryVector(); + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.ValueOrBuilder getQueryVectorOrBuilder(); + + /** + * + * + *
+   * Required. The Distance Measure to use, required.
+   * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + int getDistanceMeasureValue(); + /** + * + * + *
+   * Required. The Distance Measure to use, required.
+   * 
+ * + * + * .google.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + com.google.datastore.v1.FindNearest.DistanceMeasure getDistanceMeasure(); + + /** + * + * + *
+   * Required. The number of nearest neighbors to return. Must be a positive
+   * integer of no more than 100.
+   * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the limit field is set. + */ + boolean hasLimit(); + /** + * + * + *
+   * Required. The number of nearest neighbors to return. Must be a positive
+   * integer of no more than 100.
+   * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The limit. + */ + com.google.protobuf.Int32Value getLimit(); + /** + * + * + *
+   * Required. The number of nearest neighbors to return. Must be a positive
+   * integer of no more than 100.
+   * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder(); + + /** + * + * + *
+   * Optional. Optional name of the field to output the result of the vector
+   * distance calculation. Must conform to [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultProperty. + */ + java.lang.String getDistanceResultProperty(); + /** + * + * + *
+   * Optional. Optional name of the field to output the result of the vector
+   * distance calculation. Must conform to [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultProperty. + */ + com.google.protobuf.ByteString getDistanceResultPropertyBytes(); + + /** + * + * + *
+   * Optional. Option to specify a threshold for which no less similar documents
+   * will be returned. The behavior of the specified `distance_measure` will
+   * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+   * increase when the vectors are more similar, the comparison is inverted.
+   *
+   * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+   * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+   * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the distanceThreshold field is set. + */ + boolean hasDistanceThreshold(); + /** + * + * + *
+   * Optional. Option to specify a threshold for which no less similar documents
+   * will be returned. The behavior of the specified `distance_measure` will
+   * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+   * increase when the vectors are more similar, the comparison is inverted.
+   *
+   * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+   * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+   * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The distanceThreshold. + */ + com.google.protobuf.DoubleValue getDistanceThreshold(); + /** + * + * + *
+   * Optional. Option to specify a threshold for which no less similar documents
+   * will be returned. The behavior of the specified `distance_measure` will
+   * affect the meaning of the distance threshold. Since DOT_PRODUCT distances
+   * increase when the vectors are more similar, the comparison is inverted.
+   *
+   * For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold
+   * For DOT_PRODUCT:       WHERE distance >= distance_threshold
+   * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.protobuf.DoubleValueOrBuilder getDistanceThresholdOrBuilder(); +} diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQuery.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQuery.java index 0c7eb2a61..49a298590 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQuery.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQuery.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryOrBuilder.java index 7cedc2fd3..48a1a92de 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface GqlQueryOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameter.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameter.java index 866409cff..d22732f68 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameter.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameter.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameterOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameterOrBuilder.java index c4faa7547..dfa3547b8 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameterOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameterOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface GqlQueryParameterOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Key.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Key.java index 693c867fb..90c1fe1fc 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Key.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Key.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/entity.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KeyOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KeyOrBuilder.java index b88c3493e..ca5be689d 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KeyOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KeyOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/entity.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface KeyOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpression.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpression.java index fde068625..8d4782909 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpression.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpression.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpressionOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpressionOrBuilder.java index b3c48590c..08dc4b3d2 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpressionOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpressionOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface KindExpressionOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequest.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequest.java index cd95d3a06..4a9d52439 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequest.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** @@ -299,6 +299,71 @@ public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { return keys_.get(index); } + public static final int PROPERTY_MASK_FIELD_NUMBER = 5; + private com.google.datastore.v1.PropertyMask propertyMask_; + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return Whether the propertyMask field is set. + */ + @java.lang.Override + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return The propertyMask. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMask getPropertyMask() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -319,6 +384,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io for (int i = 0; i < keys_.size(); i++) { output.writeMessage(3, keys_.get(i)); } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(5, getPropertyMask()); + } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); } @@ -340,6 +408,9 @@ public int getSerializedSize() { for (int i = 0; i < keys_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, keys_.get(i)); } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getPropertyMask()); + } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); } @@ -368,6 +439,10 @@ public boolean equals(final java.lang.Object obj) { if (!getReadOptions().equals(other.getReadOptions())) return false; } if (!getKeysList().equals(other.getKeysList())) return false; + if (hasPropertyMask() != other.hasPropertyMask()) return false; + if (hasPropertyMask()) { + if (!getPropertyMask().equals(other.getPropertyMask())) return false; + } if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -391,6 +466,10 @@ public int hashCode() { hash = (37 * hash) + KEYS_FIELD_NUMBER; hash = (53 * hash) + getKeysList().hashCode(); } + if (hasPropertyMask()) { + hash = (37 * hash) + PROPERTY_MASK_FIELD_NUMBER; + hash = (53 * hash) + getPropertyMask().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -532,6 +611,7 @@ private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { getReadOptionsFieldBuilder(); getKeysFieldBuilder(); + getPropertyMaskFieldBuilder(); } } @@ -553,6 +633,11 @@ public Builder clear() { keysBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000008); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } return this; } @@ -614,6 +699,11 @@ private void buildPartial0(com.google.datastore.v1.LookupRequest result) { readOptionsBuilder_ == null ? readOptions_ : readOptionsBuilder_.build(); to_bitField0_ |= 0x00000001; } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.propertyMask_ = + propertyMaskBuilder_ == null ? propertyMask_ : propertyMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } result.bitField0_ |= to_bitField0_; } @@ -702,6 +792,9 @@ public Builder mergeFrom(com.google.datastore.v1.LookupRequest other) { } } } + if (other.hasPropertyMask()) { + mergePropertyMask(other.getPropertyMask()); + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -746,6 +839,12 @@ public Builder mergeFrom( } break; } // case 26 + case 42: + { + input.readMessage(getPropertyMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 case 66: { projectId_ = input.readStringRequireUtf8(); @@ -1549,6 +1648,236 @@ public java.util.List getKeysBuilderList() return keysBuilder_; } + private com.google.datastore.v1.PropertyMask propertyMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + propertyMaskBuilder_; + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return Whether the propertyMask field is set. + */ + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000010) != 0); + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return The propertyMask. + */ + public com.google.datastore.v1.PropertyMask getPropertyMask() { + if (propertyMaskBuilder_ == null) { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } else { + return propertyMaskBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + propertyMask_ = value; + } else { + propertyMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask.Builder builderForValue) { + if (propertyMaskBuilder_ == null) { + propertyMask_ = builderForValue.build(); + } else { + propertyMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder mergePropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && propertyMask_ != null + && propertyMask_ != com.google.datastore.v1.PropertyMask.getDefaultInstance()) { + getPropertyMaskBuilder().mergeFrom(value); + } else { + propertyMask_ = value; + } + } else { + propertyMaskBuilder_.mergeFrom(value); + } + if (propertyMask_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder clearPropertyMask() { + bitField0_ = (bitField0_ & ~0x00000010); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public com.google.datastore.v1.PropertyMask.Builder getPropertyMaskBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getPropertyMaskFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + if (propertyMaskBuilder_ != null) { + return propertyMaskBuilder_.getMessageOrBuilder(); + } else { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + } + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + getPropertyMaskFieldBuilder() { + if (propertyMaskBuilder_ == null) { + propertyMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder>( + getPropertyMask(), getParentForChildren(), isClean()); + propertyMask_ = null; + } + return propertyMaskBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequestOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequestOrBuilder.java index 82fe24661..e417f3306 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequestOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface LookupRequestOrBuilder @@ -170,4 +170,54 @@ public interface LookupRequestOrBuilder * */ com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index); + + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return Whether the propertyMask field is set. + */ + boolean hasPropertyMask(); + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return The propertyMask. + */ + com.google.datastore.v1.PropertyMask getPropertyMask(); + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder(); } diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponse.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponse.java index 6b56e1025..f624e5d4d 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponse.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponse.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponseOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponseOrBuilder.java index 2935a1b62..9dfacb3d6 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponseOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponseOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface LookupResponseOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Mutation.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Mutation.java index 91895d180..ff6a54f5b 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Mutation.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Mutation.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** @@ -38,7 +38,10 @@ private Mutation(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } - private Mutation() {} + private Mutation() { + conflictResolutionStrategy_ = 0; + propertyTransforms_ = java.util.Collections.emptyList(); + } @java.lang.Override @SuppressWarnings({"unused"}) @@ -60,6 +63,167 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.datastore.v1.Mutation.class, com.google.datastore.v1.Mutation.Builder.class); } + /** + * + * + *
+   * The possible ways to resolve a conflict detected in a mutation.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.Mutation.ConflictResolutionStrategy} + */ + public enum ConflictResolutionStrategy implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. Defaults to `SERVER_VALUE`.
+     * 
+ * + * STRATEGY_UNSPECIFIED = 0; + */ + STRATEGY_UNSPECIFIED(0), + /** + * + * + *
+     * The server entity is kept.
+     * 
+ * + * SERVER_VALUE = 1; + */ + SERVER_VALUE(1), + /** + * + * + *
+     * The whole commit request fails.
+     * 
+ * + * FAIL = 3; + */ + FAIL(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. Defaults to `SERVER_VALUE`.
+     * 
+ * + * STRATEGY_UNSPECIFIED = 0; + */ + public static final int STRATEGY_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * The server entity is kept.
+     * 
+ * + * SERVER_VALUE = 1; + */ + public static final int SERVER_VALUE_VALUE = 1; + /** + * + * + *
+     * The whole commit request fails.
+     * 
+ * + * FAIL = 3; + */ + public static final int FAIL_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConflictResolutionStrategy valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ConflictResolutionStrategy forNumber(int value) { + switch (value) { + case 0: + return STRATEGY_UNSPECIFIED; + case 1: + return SERVER_VALUE; + case 3: + return FAIL; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ConflictResolutionStrategy findValueByNumber(int number) { + return ConflictResolutionStrategy.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.Mutation.getDescriptor().getEnumTypes().get(0); + } + + private static final ConflictResolutionStrategy[] VALUES = values(); + + public static ConflictResolutionStrategy valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ConflictResolutionStrategy(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.Mutation.ConflictResolutionStrategy) + } + + private int bitField0_; private int operationCase_ = 0; @SuppressWarnings("serial") @@ -476,6 +640,226 @@ public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { return com.google.protobuf.Timestamp.getDefaultInstance(); } + public static final int CONFLICT_RESOLUTION_STRATEGY_FIELD_NUMBER = 10; + private int conflictResolutionStrategy_ = 0; + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The enum numeric value on the wire for conflictResolutionStrategy. + */ + @java.lang.Override + public int getConflictResolutionStrategyValue() { + return conflictResolutionStrategy_; + } + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The conflictResolutionStrategy. + */ + @java.lang.Override + public com.google.datastore.v1.Mutation.ConflictResolutionStrategy + getConflictResolutionStrategy() { + com.google.datastore.v1.Mutation.ConflictResolutionStrategy result = + com.google.datastore.v1.Mutation.ConflictResolutionStrategy.forNumber( + conflictResolutionStrategy_); + return result == null + ? com.google.datastore.v1.Mutation.ConflictResolutionStrategy.UNRECOGNIZED + : result; + } + + public static final int PROPERTY_MASK_FIELD_NUMBER = 9; + private com.google.datastore.v1.PropertyMask propertyMask_; + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return Whether the propertyMask field is set. + */ + @java.lang.Override + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return The propertyMask. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMask getPropertyMask() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + + public static final int PROPERTY_TRANSFORMS_FIELD_NUMBER = 12; + + @SuppressWarnings("serial") + private java.util.List propertyTransforms_; + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List getPropertyTransformsList() { + return propertyTransforms_; + } + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List + getPropertyTransformsOrBuilderList() { + return propertyTransforms_; + } + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public int getPropertyTransformsCount() { + return propertyTransforms_.size(); + } + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.PropertyTransform getPropertyTransforms(int index) { + return propertyTransforms_.get(index); + } + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.PropertyTransformOrBuilder getPropertyTransformsOrBuilder( + int index) { + return propertyTransforms_.get(index); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -505,9 +889,20 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (conflictDetectionStrategyCase_ == 8) { output.writeInt64(8, (long) ((java.lang.Long) conflictDetectionStrategy_)); } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(9, getPropertyMask()); + } + if (conflictResolutionStrategy_ + != com.google.datastore.v1.Mutation.ConflictResolutionStrategy.STRATEGY_UNSPECIFIED + .getNumber()) { + output.writeEnum(10, conflictResolutionStrategy_); + } if (conflictDetectionStrategyCase_ == 11) { output.writeMessage(11, (com.google.protobuf.Timestamp) conflictDetectionStrategy_); } + for (int i = 0; i < propertyTransforms_.size(); i++) { + output.writeMessage(12, propertyTransforms_.get(i)); + } getUnknownFields().writeTo(output); } @@ -542,11 +937,24 @@ public int getSerializedSize() { com.google.protobuf.CodedOutputStream.computeInt64Size( 8, (long) ((java.lang.Long) conflictDetectionStrategy_)); } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getPropertyMask()); + } + if (conflictResolutionStrategy_ + != com.google.datastore.v1.Mutation.ConflictResolutionStrategy.STRATEGY_UNSPECIFIED + .getNumber()) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize(10, conflictResolutionStrategy_); + } if (conflictDetectionStrategyCase_ == 11) { size += com.google.protobuf.CodedOutputStream.computeMessageSize( 11, (com.google.protobuf.Timestamp) conflictDetectionStrategy_); } + for (int i = 0; i < propertyTransforms_.size(); i++) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(12, propertyTransforms_.get(i)); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -562,6 +970,12 @@ public boolean equals(final java.lang.Object obj) { } com.google.datastore.v1.Mutation other = (com.google.datastore.v1.Mutation) obj; + if (conflictResolutionStrategy_ != other.conflictResolutionStrategy_) return false; + if (hasPropertyMask() != other.hasPropertyMask()) return false; + if (hasPropertyMask()) { + if (!getPropertyMask().equals(other.getPropertyMask())) return false; + } + if (!getPropertyTransformsList().equals(other.getPropertyTransformsList())) return false; if (!getOperationCase().equals(other.getOperationCase())) return false; switch (operationCase_) { case 4: @@ -602,6 +1016,16 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CONFLICT_RESOLUTION_STRATEGY_FIELD_NUMBER; + hash = (53 * hash) + conflictResolutionStrategy_; + if (hasPropertyMask()) { + hash = (37 * hash) + PROPERTY_MASK_FIELD_NUMBER; + hash = (53 * hash) + getPropertyMask().hashCode(); + } + if (getPropertyTransformsCount() > 0) { + hash = (37 * hash) + PROPERTY_TRANSFORMS_FIELD_NUMBER; + hash = (53 * hash) + getPropertyTransformsList().hashCode(); + } switch (operationCase_) { case 4: hash = (37 * hash) + INSERT_FIELD_NUMBER; @@ -762,10 +1186,20 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { } // Construct using com.google.datastore.v1.Mutation.newBuilder() - private Builder() {} + private Builder() { + maybeForceBuilderInitialization(); + } private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPropertyMaskFieldBuilder(); + getPropertyTransformsFieldBuilder(); + } } @java.lang.Override @@ -787,6 +1221,19 @@ public Builder clear() { if (updateTimeBuilder_ != null) { updateTimeBuilder_.clear(); } + conflictResolutionStrategy_ = 0; + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + if (propertyTransformsBuilder_ == null) { + propertyTransforms_ = java.util.Collections.emptyList(); + } else { + propertyTransforms_ = null; + propertyTransformsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000100); operationCase_ = 0; operation_ = null; conflictDetectionStrategyCase_ = 0; @@ -817,6 +1264,7 @@ public com.google.datastore.v1.Mutation build() { @java.lang.Override public com.google.datastore.v1.Mutation buildPartial() { com.google.datastore.v1.Mutation result = new com.google.datastore.v1.Mutation(this); + buildPartialRepeatedFields(result); if (bitField0_ != 0) { buildPartial0(result); } @@ -825,8 +1273,30 @@ public com.google.datastore.v1.Mutation buildPartial() { return result; } + private void buildPartialRepeatedFields(com.google.datastore.v1.Mutation result) { + if (propertyTransformsBuilder_ == null) { + if (((bitField0_ & 0x00000100) != 0)) { + propertyTransforms_ = java.util.Collections.unmodifiableList(propertyTransforms_); + bitField0_ = (bitField0_ & ~0x00000100); + } + result.propertyTransforms_ = propertyTransforms_; + } else { + result.propertyTransforms_ = propertyTransformsBuilder_.build(); + } + } + private void buildPartial0(com.google.datastore.v1.Mutation result) { int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000040) != 0)) { + result.conflictResolutionStrategy_ = conflictResolutionStrategy_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000080) != 0)) { + result.propertyMask_ = + propertyMaskBuilder_ == null ? propertyMask_ : propertyMaskBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; } private void buildPartialOneofs(com.google.datastore.v1.Mutation result) { @@ -896,6 +1366,39 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(com.google.datastore.v1.Mutation other) { if (other == com.google.datastore.v1.Mutation.getDefaultInstance()) return this; + if (other.conflictResolutionStrategy_ != 0) { + setConflictResolutionStrategyValue(other.getConflictResolutionStrategyValue()); + } + if (other.hasPropertyMask()) { + mergePropertyMask(other.getPropertyMask()); + } + if (propertyTransformsBuilder_ == null) { + if (!other.propertyTransforms_.isEmpty()) { + if (propertyTransforms_.isEmpty()) { + propertyTransforms_ = other.propertyTransforms_; + bitField0_ = (bitField0_ & ~0x00000100); + } else { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.addAll(other.propertyTransforms_); + } + onChanged(); + } + } else { + if (!other.propertyTransforms_.isEmpty()) { + if (propertyTransformsBuilder_.isEmpty()) { + propertyTransformsBuilder_.dispose(); + propertyTransformsBuilder_ = null; + propertyTransforms_ = other.propertyTransforms_; + bitField0_ = (bitField0_ & ~0x00000100); + propertyTransformsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPropertyTransformsFieldBuilder() + : null; + } else { + propertyTransformsBuilder_.addAllMessages(other.propertyTransforms_); + } + } + } switch (other.getOperationCase()) { case INSERT: { @@ -994,12 +1497,37 @@ public Builder mergeFrom( conflictDetectionStrategyCase_ = 8; break; } // case 64 + case 74: + { + input.readMessage(getPropertyMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000080; + break; + } // case 74 + case 80: + { + conflictResolutionStrategy_ = input.readEnum(); + bitField0_ |= 0x00000040; + break; + } // case 80 case 90: { input.readMessage(getUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); conflictDetectionStrategyCase_ = 11; break; } // case 90 + case 98: + { + com.google.datastore.v1.PropertyTransform m = + input.readMessage( + com.google.datastore.v1.PropertyTransform.parser(), extensionRegistry); + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(m); + } else { + propertyTransformsBuilder_.addMessage(m); + } + break; + } // case 98 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -2206,6 +2734,836 @@ public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { return updateTimeBuilder_; } + private int conflictResolutionStrategy_ = 0; + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The enum numeric value on the wire for conflictResolutionStrategy. + */ + @java.lang.Override + public int getConflictResolutionStrategyValue() { + return conflictResolutionStrategy_; + } + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @param value The enum numeric value on the wire for conflictResolutionStrategy to set. + * @return This builder for chaining. + */ + public Builder setConflictResolutionStrategyValue(int value) { + conflictResolutionStrategy_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The conflictResolutionStrategy. + */ + @java.lang.Override + public com.google.datastore.v1.Mutation.ConflictResolutionStrategy + getConflictResolutionStrategy() { + com.google.datastore.v1.Mutation.ConflictResolutionStrategy result = + com.google.datastore.v1.Mutation.ConflictResolutionStrategy.forNumber( + conflictResolutionStrategy_); + return result == null + ? com.google.datastore.v1.Mutation.ConflictResolutionStrategy.UNRECOGNIZED + : result; + } + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @param value The conflictResolutionStrategy to set. + * @return This builder for chaining. + */ + public Builder setConflictResolutionStrategy( + com.google.datastore.v1.Mutation.ConflictResolutionStrategy value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + conflictResolutionStrategy_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return This builder for chaining. + */ + public Builder clearConflictResolutionStrategy() { + bitField0_ = (bitField0_ & ~0x00000040); + conflictResolutionStrategy_ = 0; + onChanged(); + return this; + } + + private com.google.datastore.v1.PropertyMask propertyMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + propertyMaskBuilder_; + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return Whether the propertyMask field is set. + */ + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000080) != 0); + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return The propertyMask. + */ + public com.google.datastore.v1.PropertyMask getPropertyMask() { + if (propertyMaskBuilder_ == null) { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } else { + return propertyMaskBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + propertyMask_ = value; + } else { + propertyMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask.Builder builderForValue) { + if (propertyMaskBuilder_ == null) { + propertyMask_ = builderForValue.build(); + } else { + propertyMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder mergePropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) + && propertyMask_ != null + && propertyMask_ != com.google.datastore.v1.PropertyMask.getDefaultInstance()) { + getPropertyMaskBuilder().mergeFrom(value); + } else { + propertyMask_ = value; + } + } else { + propertyMaskBuilder_.mergeFrom(value); + } + if (propertyMask_ != null) { + bitField0_ |= 0x00000080; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder clearPropertyMask() { + bitField0_ = (bitField0_ & ~0x00000080); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public com.google.datastore.v1.PropertyMask.Builder getPropertyMaskBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return getPropertyMaskFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + if (propertyMaskBuilder_ != null) { + return propertyMaskBuilder_.getMessageOrBuilder(); + } else { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + } + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + getPropertyMaskFieldBuilder() { + if (propertyMaskBuilder_ == null) { + propertyMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder>( + getPropertyMask(), getParentForChildren(), isClean()); + propertyMask_ = null; + } + return propertyMaskBuilder_; + } + + private java.util.List propertyTransforms_ = + java.util.Collections.emptyList(); + + private void ensurePropertyTransformsIsMutable() { + if (!((bitField0_ & 0x00000100) != 0)) { + propertyTransforms_ = + new java.util.ArrayList(propertyTransforms_); + bitField0_ |= 0x00000100; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyTransform, + com.google.datastore.v1.PropertyTransform.Builder, + com.google.datastore.v1.PropertyTransformOrBuilder> + propertyTransformsBuilder_; + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List getPropertyTransformsList() { + if (propertyTransformsBuilder_ == null) { + return java.util.Collections.unmodifiableList(propertyTransforms_); + } else { + return propertyTransformsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public int getPropertyTransformsCount() { + if (propertyTransformsBuilder_ == null) { + return propertyTransforms_.size(); + } else { + return propertyTransformsBuilder_.getCount(); + } + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform getPropertyTransforms(int index) { + if (propertyTransformsBuilder_ == null) { + return propertyTransforms_.get(index); + } else { + return propertyTransformsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform value) { + if (propertyTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertyTransformsIsMutable(); + propertyTransforms_.set(index, value); + onChanged(); + } else { + propertyTransformsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform.Builder builderForValue) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.set(index, builderForValue.build()); + onChanged(); + } else { + propertyTransformsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms(com.google.datastore.v1.PropertyTransform value) { + if (propertyTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(value); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform value) { + if (propertyTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(index, value); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms( + com.google.datastore.v1.PropertyTransform.Builder builderForValue) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(builderForValue.build()); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform.Builder builderForValue) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(index, builderForValue.build()); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAllPropertyTransforms( + java.lang.Iterable values) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, propertyTransforms_); + onChanged(); + } else { + propertyTransformsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearPropertyTransforms() { + if (propertyTransformsBuilder_ == null) { + propertyTransforms_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000100); + onChanged(); + } else { + propertyTransformsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removePropertyTransforms(int index) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.remove(index); + onChanged(); + } else { + propertyTransformsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform.Builder getPropertyTransformsBuilder( + int index) { + return getPropertyTransformsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransformOrBuilder getPropertyTransformsOrBuilder( + int index) { + if (propertyTransformsBuilder_ == null) { + return propertyTransforms_.get(index); + } else { + return propertyTransformsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getPropertyTransformsOrBuilderList() { + if (propertyTransformsBuilder_ != null) { + return propertyTransformsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(propertyTransforms_); + } + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform.Builder addPropertyTransformsBuilder() { + return getPropertyTransformsFieldBuilder() + .addBuilder(com.google.datastore.v1.PropertyTransform.getDefaultInstance()); + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform.Builder addPropertyTransformsBuilder( + int index) { + return getPropertyTransformsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.PropertyTransform.getDefaultInstance()); + } + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getPropertyTransformsBuilderList() { + return getPropertyTransformsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyTransform, + com.google.datastore.v1.PropertyTransform.Builder, + com.google.datastore.v1.PropertyTransformOrBuilder> + getPropertyTransformsFieldBuilder() { + if (propertyTransformsBuilder_ == null) { + propertyTransformsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyTransform, + com.google.datastore.v1.PropertyTransform.Builder, + com.google.datastore.v1.PropertyTransformOrBuilder>( + propertyTransforms_, + ((bitField0_ & 0x00000100) != 0), + getParentForChildren(), + isClean()); + propertyTransforms_ = null; + } + return propertyTransformsBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationOrBuilder.java index e833ed942..131454c79 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface MutationOrBuilder @@ -246,6 +246,177 @@ public interface MutationOrBuilder */ com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The enum numeric value on the wire for conflictResolutionStrategy. + */ + int getConflictResolutionStrategyValue(); + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The conflictResolutionStrategy. + */ + com.google.datastore.v1.Mutation.ConflictResolutionStrategy getConflictResolutionStrategy(); + + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return Whether the propertyMask field is set. + */ + boolean hasPropertyMask(); + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return The propertyMask. + */ + com.google.datastore.v1.PropertyMask getPropertyMask(); + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder(); + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List getPropertyTransformsList(); + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.PropertyTransform getPropertyTransforms(int index); + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getPropertyTransformsCount(); + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List + getPropertyTransformsOrBuilderList(); + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.PropertyTransformOrBuilder getPropertyTransformsOrBuilder(int index); + com.google.datastore.v1.Mutation.OperationCase getOperationCase(); com.google.datastore.v1.Mutation.ConflictDetectionStrategyCase getConflictDetectionStrategyCase(); diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResult.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResult.java index 2e7abf0bd..aa05f03da 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResult.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResult.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** @@ -38,7 +38,9 @@ private MutationResult(com.google.protobuf.GeneratedMessageV3.Builder builder super(builder); } - private MutationResult() {} + private MutationResult() { + transformResults_ = java.util.Collections.emptyList(); + } @java.lang.Override @SuppressWarnings({"unused"}) @@ -253,6 +255,87 @@ public boolean getConflictDetected() { return conflictDetected_; } + public static final int TRANSFORM_RESULTS_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private java.util.List transformResults_; + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public java.util.List getTransformResultsList() { + return transformResults_; + } + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public java.util.List + getTransformResultsOrBuilderList() { + return transformResults_; + } + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public int getTransformResultsCount() { + return transformResults_.size(); + } + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public com.google.datastore.v1.Value getTransformResults(int index) { + return transformResults_.get(index); + } + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index) { + return transformResults_.get(index); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -282,6 +365,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (((bitField0_ & 0x00000002) != 0)) { output.writeMessage(7, getCreateTime()); } + for (int i = 0; i < transformResults_.size(); i++) { + output.writeMessage(8, transformResults_.get(i)); + } getUnknownFields().writeTo(output); } @@ -306,6 +392,9 @@ public int getSerializedSize() { if (((bitField0_ & 0x00000002) != 0)) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getCreateTime()); } + for (int i = 0; i < transformResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, transformResults_.get(i)); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -335,6 +424,7 @@ public boolean equals(final java.lang.Object obj) { if (!getUpdateTime().equals(other.getUpdateTime())) return false; } if (getConflictDetected() != other.getConflictDetected()) return false; + if (!getTransformResultsList().equals(other.getTransformResultsList())) return false; if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -362,6 +452,10 @@ public int hashCode() { } hash = (37 * hash) + CONFLICT_DETECTED_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getConflictDetected()); + if (getTransformResultsCount() > 0) { + hash = (37 * hash) + TRANSFORM_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getTransformResultsList().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -505,6 +599,7 @@ private void maybeForceBuilderInitialization() { getKeyFieldBuilder(); getCreateTimeFieldBuilder(); getUpdateTimeFieldBuilder(); + getTransformResultsFieldBuilder(); } } @@ -529,6 +624,13 @@ public Builder clear() { updateTimeBuilder_ = null; } conflictDetected_ = false; + if (transformResultsBuilder_ == null) { + transformResults_ = java.util.Collections.emptyList(); + } else { + transformResults_ = null; + transformResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000020); return this; } @@ -556,6 +658,7 @@ public com.google.datastore.v1.MutationResult build() { public com.google.datastore.v1.MutationResult buildPartial() { com.google.datastore.v1.MutationResult result = new com.google.datastore.v1.MutationResult(this); + buildPartialRepeatedFields(result); if (bitField0_ != 0) { buildPartial0(result); } @@ -563,6 +666,18 @@ public com.google.datastore.v1.MutationResult buildPartial() { return result; } + private void buildPartialRepeatedFields(com.google.datastore.v1.MutationResult result) { + if (transformResultsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0)) { + transformResults_ = java.util.Collections.unmodifiableList(transformResults_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.transformResults_ = transformResults_; + } else { + result.transformResults_ = transformResultsBuilder_.build(); + } + } + private void buildPartial0(com.google.datastore.v1.MutationResult result) { int from_bitField0_ = bitField0_; int to_bitField0_ = 0; @@ -647,6 +762,33 @@ public Builder mergeFrom(com.google.datastore.v1.MutationResult other) { if (other.getConflictDetected() != false) { setConflictDetected(other.getConflictDetected()); } + if (transformResultsBuilder_ == null) { + if (!other.transformResults_.isEmpty()) { + if (transformResults_.isEmpty()) { + transformResults_ = other.transformResults_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureTransformResultsIsMutable(); + transformResults_.addAll(other.transformResults_); + } + onChanged(); + } + } else { + if (!other.transformResults_.isEmpty()) { + if (transformResultsBuilder_.isEmpty()) { + transformResultsBuilder_.dispose(); + transformResultsBuilder_ = null; + transformResults_ = other.transformResults_; + bitField0_ = (bitField0_ & ~0x00000020); + transformResultsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getTransformResultsFieldBuilder() + : null; + } else { + transformResultsBuilder_.addAllMessages(other.transformResults_); + } + } + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -703,6 +845,18 @@ public Builder mergeFrom( bitField0_ |= 0x00000004; break; } // case 58 + case 66: + { + com.google.datastore.v1.Value m = + input.readMessage(com.google.datastore.v1.Value.parser(), extensionRegistry); + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.add(m); + } else { + transformResultsBuilder_.addMessage(m); + } + break; + } // case 66 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -1429,6 +1583,394 @@ public Builder clearConflictDetected() { return this; } + private java.util.List transformResults_ = + java.util.Collections.emptyList(); + + private void ensureTransformResultsIsMutable() { + if (!((bitField0_ & 0x00000020) != 0)) { + transformResults_ = + new java.util.ArrayList(transformResults_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + transformResultsBuilder_; + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public java.util.List getTransformResultsList() { + if (transformResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(transformResults_); + } else { + return transformResultsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public int getTransformResultsCount() { + if (transformResultsBuilder_ == null) { + return transformResults_.size(); + } else { + return transformResultsBuilder_.getCount(); + } + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value getTransformResults(int index) { + if (transformResultsBuilder_ == null) { + return transformResults_.get(index); + } else { + return transformResultsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder setTransformResults(int index, com.google.datastore.v1.Value value) { + if (transformResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransformResultsIsMutable(); + transformResults_.set(index, value); + onChanged(); + } else { + transformResultsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder setTransformResults( + int index, com.google.datastore.v1.Value.Builder builderForValue) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.set(index, builderForValue.build()); + onChanged(); + } else { + transformResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults(com.google.datastore.v1.Value value) { + if (transformResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransformResultsIsMutable(); + transformResults_.add(value); + onChanged(); + } else { + transformResultsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults(int index, com.google.datastore.v1.Value value) { + if (transformResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransformResultsIsMutable(); + transformResults_.add(index, value); + onChanged(); + } else { + transformResultsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults(com.google.datastore.v1.Value.Builder builderForValue) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.add(builderForValue.build()); + onChanged(); + } else { + transformResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults( + int index, com.google.datastore.v1.Value.Builder builderForValue) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.add(index, builderForValue.build()); + onChanged(); + } else { + transformResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addAllTransformResults( + java.lang.Iterable values) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, transformResults_); + onChanged(); + } else { + transformResultsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder clearTransformResults() { + if (transformResultsBuilder_ == null) { + transformResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + transformResultsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder removeTransformResults(int index) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.remove(index); + onChanged(); + } else { + transformResultsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value.Builder getTransformResultsBuilder(int index) { + return getTransformResultsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index) { + if (transformResultsBuilder_ == null) { + return transformResults_.get(index); + } else { + return transformResultsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public java.util.List + getTransformResultsOrBuilderList() { + if (transformResultsBuilder_ != null) { + return transformResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transformResults_); + } + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value.Builder addTransformResultsBuilder() { + return getTransformResultsFieldBuilder() + .addBuilder(com.google.datastore.v1.Value.getDefaultInstance()); + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value.Builder addTransformResultsBuilder(int index) { + return getTransformResultsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Value.getDefaultInstance()); + } + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public java.util.List getTransformResultsBuilderList() { + return getTransformResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getTransformResultsFieldBuilder() { + if (transformResultsBuilder_ == null) { + transformResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + transformResults_, + ((bitField0_ & 0x00000020) != 0), + getParentForChildren(), + isClean()); + transformResults_ = null; + } + return transformResultsBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResultOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResultOrBuilder.java index bec5014e2..e4f8c7561 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResultOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResultOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface MutationResultOrBuilder @@ -171,4 +171,66 @@ public interface MutationResultOrBuilder * @return The conflictDetected. */ boolean getConflictDetected(); + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + java.util.List getTransformResultsList(); + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + com.google.datastore.v1.Value getTransformResults(int index); + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + int getTransformResultsCount(); + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + java.util.List + getTransformResultsOrBuilderList(); + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + com.google.datastore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index); } diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionId.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionId.java index 9116410f5..09ea652c9 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionId.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionId.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/entity.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionIdOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionIdOrBuilder.java index d9dc8c271..7c418fe37 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionIdOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionIdOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/entity.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface PartitionIdOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummary.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummary.java index b68c700c3..365b11d31 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummary.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummary.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query_profile.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummaryOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummaryOrBuilder.java index 634faded7..8088a8c24 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummaryOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummaryOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query_profile.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface PlanSummaryOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Projection.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Projection.java index 412dc13dd..cfd0dc705 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Projection.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Projection.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ProjectionOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ProjectionOrBuilder.java index c1a094d81..71920236c 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ProjectionOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ProjectionOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface ProjectionOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilter.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilter.java index 3eb9c2c1d..814bfe7fa 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilter.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilter.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilterOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilterOrBuilder.java index c7c9d0577..fd74ed8e9 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilterOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilterOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface PropertyFilterOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMask.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMask.java new file mode 100644 index 000000000..432846ebc --- /dev/null +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMask.java @@ -0,0 +1,848 @@ +/* + * Copyright 2024 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.5 +package com.google.datastore.v1; + +/** + * + * + *
+ * The set of arbitrarily nested property paths used to restrict an operation to
+ * only a subset of properties in an entity.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyMask} + */ +public final class PropertyMask extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PropertyMask) + PropertyMaskOrBuilder { + private static final long serialVersionUID = 0L; + // Use PropertyMask.newBuilder() to construct. + private PropertyMask(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PropertyMask() { + paths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PropertyMask(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyMask.class, + com.google.datastore.v1.PropertyMask.Builder.class); + } + + public static final int PATHS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList paths_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return A list containing the paths. + */ + public com.google.protobuf.ProtocolStringList getPathsList() { + return paths_; + } + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return The count of paths. + */ + public int getPathsCount() { + return paths_.size(); + } + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the element to return. + * @return The paths at the given index. + */ + public java.lang.String getPaths(int index) { + return paths_.get(index); + } + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the paths at the given index. + */ + public com.google.protobuf.ByteString getPathsBytes(int index) { + return paths_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < paths_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, paths_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < paths_.size(); i++) { + dataSize += computeStringSizeNoTag(paths_.getRaw(i)); + } + size += dataSize; + size += 1 * getPathsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.datastore.v1.PropertyMask)) { + return super.equals(obj); + } + com.google.datastore.v1.PropertyMask other = (com.google.datastore.v1.PropertyMask) obj; + + if (!getPathsList().equals(other.getPathsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getPathsCount() > 0) { + hash = (37 * hash) + PATHS_FIELD_NUMBER; + hash = (53 * hash) + getPathsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.PropertyMask parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyMask parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.datastore.v1.PropertyMask prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The set of arbitrarily nested property paths used to restrict an operation to
+   * only a subset of properties in an entity.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyMask} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PropertyMask) + com.google.datastore.v1.PropertyMaskOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyMask.class, + com.google.datastore.v1.PropertyMask.Builder.class); + } + + // Construct using com.google.datastore.v1.PropertyMask.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + paths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyMask getDefaultInstanceForType() { + return com.google.datastore.v1.PropertyMask.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PropertyMask build() { + com.google.datastore.v1.PropertyMask result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyMask buildPartial() { + com.google.datastore.v1.PropertyMask result = new com.google.datastore.v1.PropertyMask(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PropertyMask result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + paths_.makeImmutable(); + result.paths_ = paths_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PropertyMask) { + return mergeFrom((com.google.datastore.v1.PropertyMask) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PropertyMask other) { + if (other == com.google.datastore.v1.PropertyMask.getDefaultInstance()) return this; + if (!other.paths_.isEmpty()) { + if (paths_.isEmpty()) { + paths_ = other.paths_; + bitField0_ |= 0x00000001; + } else { + ensurePathsIsMutable(); + paths_.addAll(other.paths_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + ensurePathsIsMutable(); + paths_.add(s); + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.LazyStringArrayList paths_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensurePathsIsMutable() { + if (!paths_.isModifiable()) { + paths_ = new com.google.protobuf.LazyStringArrayList(paths_); + } + bitField0_ |= 0x00000001; + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @return A list containing the paths. + */ + public com.google.protobuf.ProtocolStringList getPathsList() { + paths_.makeImmutable(); + return paths_; + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @return The count of paths. + */ + public int getPathsCount() { + return paths_.size(); + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param index The index of the element to return. + * @return The paths at the given index. + */ + public java.lang.String getPaths(int index) { + return paths_.get(index); + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the paths at the given index. + */ + public com.google.protobuf.ByteString getPathsBytes(int index) { + return paths_.getByteString(index); + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param index The index to set the value at. + * @param value The paths to set. + * @return This builder for chaining. + */ + public Builder setPaths(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathsIsMutable(); + paths_.set(index, value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param value The paths to add. + * @return This builder for chaining. + */ + public Builder addPaths(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathsIsMutable(); + paths_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param values The paths to add. + * @return This builder for chaining. + */ + public Builder addAllPaths(java.lang.Iterable values) { + ensurePathsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, paths_); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @return This builder for chaining. + */ + public Builder clearPaths() { + paths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + ; + onChanged(); + return this; + } + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param value The bytes of the paths to add. + * @return This builder for chaining. + */ + public Builder addPathsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensurePathsIsMutable(); + paths_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PropertyMask) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PropertyMask) + private static final com.google.datastore.v1.PropertyMask DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PropertyMask(); + } + + public static com.google.datastore.v1.PropertyMask getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PropertyMask parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyMask getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMaskOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMaskOrBuilder.java new file mode 100644 index 000000000..e36a55be5 --- /dev/null +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMaskOrBuilder.java @@ -0,0 +1,117 @@ +/* + * Copyright 2024 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.5 +package com.google.datastore.v1; + +public interface PropertyMaskOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PropertyMask) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return A list containing the paths. + */ + java.util.List getPathsList(); + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return The count of paths. + */ + int getPathsCount(); + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the element to return. + * @return The paths at the given index. + */ + java.lang.String getPaths(int index); + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the paths at the given index. + */ + com.google.protobuf.ByteString getPathsBytes(int index); +} diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrder.java index b42405c97..c12f8741b 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrderOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrderOrBuilder.java index 3522ab951..4e4e8b986 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrderOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrderOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface PropertyOrderOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReference.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReference.java index a7a4c304e..d1ce5477e 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReference.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReference.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReferenceOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReferenceOrBuilder.java index 7761b1421..0d80ea0ea 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReferenceOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReferenceOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface PropertyReferenceOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransform.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransform.java new file mode 100644 index 000000000..520ccb0f2 --- /dev/null +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransform.java @@ -0,0 +1,3197 @@ +/* + * Copyright 2024 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.5 +package com.google.datastore.v1; + +/** + * + * + *
+ * A transformation of an entity property.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyTransform} + */ +public final class PropertyTransform extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PropertyTransform) + PropertyTransformOrBuilder { + private static final long serialVersionUID = 0L; + // Use PropertyTransform.newBuilder() to construct. + private PropertyTransform(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PropertyTransform() { + property_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PropertyTransform(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyTransform.class, + com.google.datastore.v1.PropertyTransform.Builder.class); + } + + /** + * + * + *
+   * A value that is calculated by the server.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.PropertyTransform.ServerValue} + */ + public enum ServerValue implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * SERVER_VALUE_UNSPECIFIED = 0; + */ + SERVER_VALUE_UNSPECIFIED(0), + /** + * + * + *
+     * The time at which the server processed the request, with millisecond
+     * precision. If used on multiple properties (same or different entities)
+     * in a transaction, all the properties will get the same server timestamp.
+     * 
+ * + * REQUEST_TIME = 1; + */ + REQUEST_TIME(1), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * SERVER_VALUE_UNSPECIFIED = 0; + */ + public static final int SERVER_VALUE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * The time at which the server processed the request, with millisecond
+     * precision. If used on multiple properties (same or different entities)
+     * in a transaction, all the properties will get the same server timestamp.
+     * 
+ * + * REQUEST_TIME = 1; + */ + public static final int REQUEST_TIME_VALUE = 1; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ServerValue valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ServerValue forNumber(int value) { + switch (value) { + case 0: + return SERVER_VALUE_UNSPECIFIED; + case 1: + return REQUEST_TIME; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ServerValue findValueByNumber(int number) { + return ServerValue.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.PropertyTransform.getDescriptor().getEnumTypes().get(0); + } + + private static final ServerValue[] VALUES = values(); + + public static ServerValue valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ServerValue(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.PropertyTransform.ServerValue) + } + + private int transformTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object transformType_; + + public enum TransformTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + SET_TO_SERVER_VALUE(2), + INCREMENT(3), + MAXIMUM(4), + MINIMUM(5), + APPEND_MISSING_ELEMENTS(6), + REMOVE_ALL_FROM_ARRAY(7), + TRANSFORMTYPE_NOT_SET(0); + private final int value; + + private TransformTypeCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TransformTypeCase valueOf(int value) { + return forNumber(value); + } + + public static TransformTypeCase forNumber(int value) { + switch (value) { + case 2: + return SET_TO_SERVER_VALUE; + case 3: + return INCREMENT; + case 4: + return MAXIMUM; + case 5: + return MINIMUM; + case 6: + return APPEND_MISSING_ELEMENTS; + case 7: + return REMOVE_ALL_FROM_ARRAY; + case 0: + return TRANSFORMTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public TransformTypeCase getTransformTypeCase() { + return TransformTypeCase.forNumber(transformTypeCase_); + } + + public static final int PROPERTY_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object property_ = ""; + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The property. + */ + @java.lang.Override + public java.lang.String getProperty() { + java.lang.Object ref = property_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + property_ = s; + return s; + } + } + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for property. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPropertyBytes() { + java.lang.Object ref = property_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + property_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SET_TO_SERVER_VALUE_FIELD_NUMBER = 2; + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return Whether the setToServerValue field is set. + */ + public boolean hasSetToServerValue() { + return transformTypeCase_ == 2; + } + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The enum numeric value on the wire for setToServerValue. + */ + public int getSetToServerValueValue() { + if (transformTypeCase_ == 2) { + return (java.lang.Integer) transformType_; + } + return 0; + } + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The setToServerValue. + */ + public com.google.datastore.v1.PropertyTransform.ServerValue getSetToServerValue() { + if (transformTypeCase_ == 2) { + com.google.datastore.v1.PropertyTransform.ServerValue result = + com.google.datastore.v1.PropertyTransform.ServerValue.forNumber( + (java.lang.Integer) transformType_); + return result == null + ? com.google.datastore.v1.PropertyTransform.ServerValue.UNRECOGNIZED + : result; + } + return com.google.datastore.v1.PropertyTransform.ServerValue.SERVER_VALUE_UNSPECIFIED; + } + + public static final int INCREMENT_FIELD_NUMBER = 3; + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return Whether the increment field is set. + */ + @java.lang.Override + public boolean hasIncrement() { + return transformTypeCase_ == 3; + } + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return The increment. + */ + @java.lang.Override + public com.google.datastore.v1.Value getIncrement() { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getIncrementOrBuilder() { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + public static final int MAXIMUM_FIELD_NUMBER = 4; + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property does not change.
+   * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+   * zero input value is always the stored value.
+   * The maximum of any numeric value x and NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + @java.lang.Override + public boolean hasMaximum() { + return transformTypeCase_ == 4; + } + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property does not change.
+   * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+   * zero input value is always the stored value.
+   * The maximum of any numeric value x and NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value maximum = 4; + * + * @return The maximum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMaximum() { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property does not change.
+   * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+   * zero input value is always the stored value.
+   * The maximum of any numeric value x and NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMaximumOrBuilder() { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + public static final int MINIMUM_FIELD_NUMBER = 5; + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+   * and -0.0 are all zero. The minimum of a zero stored value and zero input
+   * value is always the stored value. The minimum of any numeric value x and
+   * NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + @java.lang.Override + public boolean hasMinimum() { + return transformTypeCase_ == 5; + } + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+   * and -0.0 are all zero. The minimum of a zero stored value and zero input
+   * value is always the stored value. The minimum of any numeric value x and
+   * NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value minimum = 5; + * + * @return The minimum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMinimum() { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+   * and -0.0 are all zero. The minimum of a zero stored value and zero input
+   * value is always the stored value. The minimum of any numeric value x and
+   * NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMinimumOrBuilder() { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + public static final int APPEND_MISSING_ELEMENTS_FIELD_NUMBER = 6; + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is first set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when checking if a value is missing.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + @java.lang.Override + public boolean hasAppendMissingElements() { + return transformTypeCase_ == 6; + } + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is first set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when checking if a value is missing.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getAppendMissingElements() { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is first set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when checking if a value is missing.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder() { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + public static final int REMOVE_ALL_FROM_ARRAY_FIELD_NUMBER = 7; + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when deciding whether an element should be removed.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + @java.lang.Override + public boolean hasRemoveAllFromArray() { + return transformTypeCase_ == 7; + } + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when deciding whether an element should be removed.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getRemoveAllFromArray() { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when deciding whether an element should be removed.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder() { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(property_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, property_); + } + if (transformTypeCase_ == 2) { + output.writeEnum(2, ((java.lang.Integer) transformType_)); + } + if (transformTypeCase_ == 3) { + output.writeMessage(3, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 4) { + output.writeMessage(4, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 5) { + output.writeMessage(5, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 6) { + output.writeMessage(6, (com.google.datastore.v1.ArrayValue) transformType_); + } + if (transformTypeCase_ == 7) { + output.writeMessage(7, (com.google.datastore.v1.ArrayValue) transformType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(property_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, property_); + } + if (transformTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize( + 2, ((java.lang.Integer) transformType_)); + } + if (transformTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.datastore.v1.ArrayValue) transformType_); + } + if (transformTypeCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.datastore.v1.ArrayValue) transformType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.datastore.v1.PropertyTransform)) { + return super.equals(obj); + } + com.google.datastore.v1.PropertyTransform other = + (com.google.datastore.v1.PropertyTransform) obj; + + if (!getProperty().equals(other.getProperty())) return false; + if (!getTransformTypeCase().equals(other.getTransformTypeCase())) return false; + switch (transformTypeCase_) { + case 2: + if (getSetToServerValueValue() != other.getSetToServerValueValue()) return false; + break; + case 3: + if (!getIncrement().equals(other.getIncrement())) return false; + break; + case 4: + if (!getMaximum().equals(other.getMaximum())) return false; + break; + case 5: + if (!getMinimum().equals(other.getMinimum())) return false; + break; + case 6: + if (!getAppendMissingElements().equals(other.getAppendMissingElements())) return false; + break; + case 7: + if (!getRemoveAllFromArray().equals(other.getRemoveAllFromArray())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().hashCode(); + switch (transformTypeCase_) { + case 2: + hash = (37 * hash) + SET_TO_SERVER_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getSetToServerValueValue(); + break; + case 3: + hash = (37 * hash) + INCREMENT_FIELD_NUMBER; + hash = (53 * hash) + getIncrement().hashCode(); + break; + case 4: + hash = (37 * hash) + MAXIMUM_FIELD_NUMBER; + hash = (53 * hash) + getMaximum().hashCode(); + break; + case 5: + hash = (37 * hash) + MINIMUM_FIELD_NUMBER; + hash = (53 * hash) + getMinimum().hashCode(); + break; + case 6: + hash = (37 * hash) + APPEND_MISSING_ELEMENTS_FIELD_NUMBER; + hash = (53 * hash) + getAppendMissingElements().hashCode(); + break; + case 7: + hash = (37 * hash) + REMOVE_ALL_FROM_ARRAY_FIELD_NUMBER; + hash = (53 * hash) + getRemoveAllFromArray().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.PropertyTransform parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyTransform parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.datastore.v1.PropertyTransform prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A transformation of an entity property.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyTransform} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PropertyTransform) + com.google.datastore.v1.PropertyTransformOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyTransform.class, + com.google.datastore.v1.PropertyTransform.Builder.class); + } + + // Construct using com.google.datastore.v1.PropertyTransform.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + property_ = ""; + if (incrementBuilder_ != null) { + incrementBuilder_.clear(); + } + if (maximumBuilder_ != null) { + maximumBuilder_.clear(); + } + if (minimumBuilder_ != null) { + minimumBuilder_.clear(); + } + if (appendMissingElementsBuilder_ != null) { + appendMissingElementsBuilder_.clear(); + } + if (removeAllFromArrayBuilder_ != null) { + removeAllFromArrayBuilder_.clear(); + } + transformTypeCase_ = 0; + transformType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyTransform getDefaultInstanceForType() { + return com.google.datastore.v1.PropertyTransform.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PropertyTransform build() { + com.google.datastore.v1.PropertyTransform result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyTransform buildPartial() { + com.google.datastore.v1.PropertyTransform result = + new com.google.datastore.v1.PropertyTransform(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PropertyTransform result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.property_ = property_; + } + } + + private void buildPartialOneofs(com.google.datastore.v1.PropertyTransform result) { + result.transformTypeCase_ = transformTypeCase_; + result.transformType_ = this.transformType_; + if (transformTypeCase_ == 3 && incrementBuilder_ != null) { + result.transformType_ = incrementBuilder_.build(); + } + if (transformTypeCase_ == 4 && maximumBuilder_ != null) { + result.transformType_ = maximumBuilder_.build(); + } + if (transformTypeCase_ == 5 && minimumBuilder_ != null) { + result.transformType_ = minimumBuilder_.build(); + } + if (transformTypeCase_ == 6 && appendMissingElementsBuilder_ != null) { + result.transformType_ = appendMissingElementsBuilder_.build(); + } + if (transformTypeCase_ == 7 && removeAllFromArrayBuilder_ != null) { + result.transformType_ = removeAllFromArrayBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PropertyTransform) { + return mergeFrom((com.google.datastore.v1.PropertyTransform) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PropertyTransform other) { + if (other == com.google.datastore.v1.PropertyTransform.getDefaultInstance()) return this; + if (!other.getProperty().isEmpty()) { + property_ = other.property_; + bitField0_ |= 0x00000001; + onChanged(); + } + switch (other.getTransformTypeCase()) { + case SET_TO_SERVER_VALUE: + { + setSetToServerValueValue(other.getSetToServerValueValue()); + break; + } + case INCREMENT: + { + mergeIncrement(other.getIncrement()); + break; + } + case MAXIMUM: + { + mergeMaximum(other.getMaximum()); + break; + } + case MINIMUM: + { + mergeMinimum(other.getMinimum()); + break; + } + case APPEND_MISSING_ELEMENTS: + { + mergeAppendMissingElements(other.getAppendMissingElements()); + break; + } + case REMOVE_ALL_FROM_ARRAY: + { + mergeRemoveAllFromArray(other.getRemoveAllFromArray()); + break; + } + case TRANSFORMTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + property_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + int rawValue = input.readEnum(); + transformTypeCase_ = 2; + transformType_ = rawValue; + break; + } // case 16 + case 26: + { + input.readMessage(getIncrementFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 3; + break; + } // case 26 + case 34: + { + input.readMessage(getMaximumFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 4; + break; + } // case 34 + case 42: + { + input.readMessage(getMinimumFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage( + getAppendMissingElementsFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 6; + break; + } // case 50 + case 58: + { + input.readMessage( + getRemoveAllFromArrayFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 7; + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int transformTypeCase_ = 0; + private java.lang.Object transformType_; + + public TransformTypeCase getTransformTypeCase() { + return TransformTypeCase.forNumber(transformTypeCase_); + } + + public Builder clearTransformType() { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object property_ = ""; + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The property. + */ + public java.lang.String getProperty() { + java.lang.Object ref = property_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + property_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for property. + */ + public com.google.protobuf.ByteString getPropertyBytes() { + java.lang.Object ref = property_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + property_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The property to set. + * @return This builder for chaining. + */ + public Builder setProperty(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + property_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearProperty() { + property_ = getDefaultInstance().getProperty(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for property to set. + * @return This builder for chaining. + */ + public Builder setPropertyBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + property_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return Whether the setToServerValue field is set. + */ + @java.lang.Override + public boolean hasSetToServerValue() { + return transformTypeCase_ == 2; + } + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The enum numeric value on the wire for setToServerValue. + */ + @java.lang.Override + public int getSetToServerValueValue() { + if (transformTypeCase_ == 2) { + return ((java.lang.Integer) transformType_).intValue(); + } + return 0; + } + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @param value The enum numeric value on the wire for setToServerValue to set. + * @return This builder for chaining. + */ + public Builder setSetToServerValueValue(int value) { + transformTypeCase_ = 2; + transformType_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The setToServerValue. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyTransform.ServerValue getSetToServerValue() { + if (transformTypeCase_ == 2) { + com.google.datastore.v1.PropertyTransform.ServerValue result = + com.google.datastore.v1.PropertyTransform.ServerValue.forNumber( + (java.lang.Integer) transformType_); + return result == null + ? com.google.datastore.v1.PropertyTransform.ServerValue.UNRECOGNIZED + : result; + } + return com.google.datastore.v1.PropertyTransform.ServerValue.SERVER_VALUE_UNSPECIFIED; + } + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @param value The setToServerValue to set. + * @return This builder for chaining. + */ + public Builder setSetToServerValue( + com.google.datastore.v1.PropertyTransform.ServerValue value) { + if (value == null) { + throw new NullPointerException(); + } + transformTypeCase_ = 2; + transformType_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return This builder for chaining. + */ + public Builder clearSetToServerValue() { + if (transformTypeCase_ == 2) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + incrementBuilder_; + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return Whether the increment field is set. + */ + @java.lang.Override + public boolean hasIncrement() { + return transformTypeCase_ == 3; + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return The increment. + */ + @java.lang.Override + public com.google.datastore.v1.Value getIncrement() { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 3) { + return incrementBuilder_.getMessage(); + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public Builder setIncrement(com.google.datastore.v1.Value value) { + if (incrementBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + incrementBuilder_.setMessage(value); + } + transformTypeCase_ = 3; + return this; + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public Builder setIncrement(com.google.datastore.v1.Value.Builder builderForValue) { + if (incrementBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + incrementBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 3; + return this; + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public Builder mergeIncrement(com.google.datastore.v1.Value value) { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3 + && transformType_ != com.google.datastore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.Value.newBuilder( + (com.google.datastore.v1.Value) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 3) { + incrementBuilder_.mergeFrom(value); + } else { + incrementBuilder_.setMessage(value); + } + } + transformTypeCase_ = 3; + return this; + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public Builder clearIncrement() { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 3) { + transformTypeCase_ = 0; + transformType_ = null; + } + incrementBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public com.google.datastore.v1.Value.Builder getIncrementBuilder() { + return getIncrementFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getIncrementOrBuilder() { + if ((transformTypeCase_ == 3) && (incrementBuilder_ != null)) { + return incrementBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getIncrementFieldBuilder() { + if (incrementBuilder_ == null) { + if (!(transformTypeCase_ == 3)) { + transformType_ = com.google.datastore.v1.Value.getDefaultInstance(); + } + incrementBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + (com.google.datastore.v1.Value) transformType_, getParentForChildren(), isClean()); + transformType_ = null; + } + transformTypeCase_ = 3; + onChanged(); + return incrementBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + maximumBuilder_; + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + @java.lang.Override + public boolean hasMaximum() { + return transformTypeCase_ == 4; + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + * + * @return The maximum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMaximum() { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 4) { + return maximumBuilder_.getMessage(); + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + public Builder setMaximum(com.google.datastore.v1.Value value) { + if (maximumBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + maximumBuilder_.setMessage(value); + } + transformTypeCase_ = 4; + return this; + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + public Builder setMaximum(com.google.datastore.v1.Value.Builder builderForValue) { + if (maximumBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + maximumBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 4; + return this; + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + public Builder mergeMaximum(com.google.datastore.v1.Value value) { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4 + && transformType_ != com.google.datastore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.Value.newBuilder( + (com.google.datastore.v1.Value) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 4) { + maximumBuilder_.mergeFrom(value); + } else { + maximumBuilder_.setMessage(value); + } + } + transformTypeCase_ = 4; + return this; + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + public Builder clearMaximum() { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 4) { + transformTypeCase_ = 0; + transformType_ = null; + } + maximumBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + public com.google.datastore.v1.Value.Builder getMaximumBuilder() { + return getMaximumFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMaximumOrBuilder() { + if ((transformTypeCase_ == 4) && (maximumBuilder_ != null)) { + return maximumBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getMaximumFieldBuilder() { + if (maximumBuilder_ == null) { + if (!(transformTypeCase_ == 4)) { + transformType_ = com.google.datastore.v1.Value.getDefaultInstance(); + } + maximumBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + (com.google.datastore.v1.Value) transformType_, getParentForChildren(), isClean()); + transformType_ = null; + } + transformTypeCase_ = 4; + onChanged(); + return maximumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + minimumBuilder_; + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + @java.lang.Override + public boolean hasMinimum() { + return transformTypeCase_ == 5; + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + * + * @return The minimum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMinimum() { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 5) { + return minimumBuilder_.getMessage(); + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + public Builder setMinimum(com.google.datastore.v1.Value value) { + if (minimumBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + minimumBuilder_.setMessage(value); + } + transformTypeCase_ = 5; + return this; + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + public Builder setMinimum(com.google.datastore.v1.Value.Builder builderForValue) { + if (minimumBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + minimumBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 5; + return this; + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + public Builder mergeMinimum(com.google.datastore.v1.Value value) { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5 + && transformType_ != com.google.datastore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.Value.newBuilder( + (com.google.datastore.v1.Value) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 5) { + minimumBuilder_.mergeFrom(value); + } else { + minimumBuilder_.setMessage(value); + } + } + transformTypeCase_ = 5; + return this; + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + public Builder clearMinimum() { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 5) { + transformTypeCase_ = 0; + transformType_ = null; + } + minimumBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + public com.google.datastore.v1.Value.Builder getMinimumBuilder() { + return getMinimumFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMinimumOrBuilder() { + if ((transformTypeCase_ == 5) && (minimumBuilder_ != null)) { + return minimumBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+     * and -0.0 are all zero. The minimum of a zero stored value and zero input
+     * value is always the stored value. The minimum of any numeric value x and
+     * NaN is NaN.
+     * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getMinimumFieldBuilder() { + if (minimumBuilder_ == null) { + if (!(transformTypeCase_ == 5)) { + transformType_ = com.google.datastore.v1.Value.getDefaultInstance(); + } + minimumBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + (com.google.datastore.v1.Value) transformType_, getParentForChildren(), isClean()); + transformType_ = null; + } + transformTypeCase_ = 5; + onChanged(); + return minimumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + appendMissingElementsBuilder_; + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + @java.lang.Override + public boolean hasAppendMissingElements() { + return transformTypeCase_ == 6; + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getAppendMissingElements() { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } else { + if (transformTypeCase_ == 6) { + return appendMissingElementsBuilder_.getMessage(); + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder setAppendMissingElements(com.google.datastore.v1.ArrayValue value) { + if (appendMissingElementsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + appendMissingElementsBuilder_.setMessage(value); + } + transformTypeCase_ = 6; + return this; + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder setAppendMissingElements( + com.google.datastore.v1.ArrayValue.Builder builderForValue) { + if (appendMissingElementsBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + appendMissingElementsBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 6; + return this; + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder mergeAppendMissingElements(com.google.datastore.v1.ArrayValue value) { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6 + && transformType_ != com.google.datastore.v1.ArrayValue.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.ArrayValue.newBuilder( + (com.google.datastore.v1.ArrayValue) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 6) { + appendMissingElementsBuilder_.mergeFrom(value); + } else { + appendMissingElementsBuilder_.setMessage(value); + } + } + transformTypeCase_ = 6; + return this; + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder clearAppendMissingElements() { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 6) { + transformTypeCase_ = 0; + transformType_ = null; + } + appendMissingElementsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public com.google.datastore.v1.ArrayValue.Builder getAppendMissingElementsBuilder() { + return getAppendMissingElementsFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder() { + if ((transformTypeCase_ == 6) && (appendMissingElementsBuilder_ != null)) { + return appendMissingElementsBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + getAppendMissingElementsFieldBuilder() { + if (appendMissingElementsBuilder_ == null) { + if (!(transformTypeCase_ == 6)) { + transformType_ = com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + appendMissingElementsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder>( + (com.google.datastore.v1.ArrayValue) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 6; + onChanged(); + return appendMissingElementsBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + removeAllFromArrayBuilder_; + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + @java.lang.Override + public boolean hasRemoveAllFromArray() { + return transformTypeCase_ == 7; + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getRemoveAllFromArray() { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } else { + if (transformTypeCase_ == 7) { + return removeAllFromArrayBuilder_.getMessage(); + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder setRemoveAllFromArray(com.google.datastore.v1.ArrayValue value) { + if (removeAllFromArrayBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + removeAllFromArrayBuilder_.setMessage(value); + } + transformTypeCase_ = 7; + return this; + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder setRemoveAllFromArray( + com.google.datastore.v1.ArrayValue.Builder builderForValue) { + if (removeAllFromArrayBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + removeAllFromArrayBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 7; + return this; + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder mergeRemoveAllFromArray(com.google.datastore.v1.ArrayValue value) { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7 + && transformType_ != com.google.datastore.v1.ArrayValue.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.ArrayValue.newBuilder( + (com.google.datastore.v1.ArrayValue) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 7) { + removeAllFromArrayBuilder_.mergeFrom(value); + } else { + removeAllFromArrayBuilder_.setMessage(value); + } + } + transformTypeCase_ = 7; + return this; + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder clearRemoveAllFromArray() { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 7) { + transformTypeCase_ = 0; + transformType_ = null; + } + removeAllFromArrayBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public com.google.datastore.v1.ArrayValue.Builder getRemoveAllFromArrayBuilder() { + return getRemoveAllFromArrayFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder() { + if ((transformTypeCase_ == 7) && (removeAllFromArrayBuilder_ != null)) { + return removeAllFromArrayBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + getRemoveAllFromArrayFieldBuilder() { + if (removeAllFromArrayBuilder_ == null) { + if (!(transformTypeCase_ == 7)) { + transformType_ = com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + removeAllFromArrayBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder>( + (com.google.datastore.v1.ArrayValue) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 7; + onChanged(); + return removeAllFromArrayBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PropertyTransform) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PropertyTransform) + private static final com.google.datastore.v1.PropertyTransform DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PropertyTransform(); + } + + public static com.google.datastore.v1.PropertyTransform getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PropertyTransform parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyTransform getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransformOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransformOrBuilder.java new file mode 100644 index 000000000..34782a859 --- /dev/null +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransformOrBuilder.java @@ -0,0 +1,438 @@ +/* + * Copyright 2024 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.5 +package com.google.datastore.v1; + +public interface PropertyTransformOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PropertyTransform) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The property. + */ + java.lang.String getProperty(); + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for property. + */ + com.google.protobuf.ByteString getPropertyBytes(); + + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return Whether the setToServerValue field is set. + */ + boolean hasSetToServerValue(); + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The enum numeric value on the wire for setToServerValue. + */ + int getSetToServerValueValue(); + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The setToServerValue. + */ + com.google.datastore.v1.PropertyTransform.ServerValue getSetToServerValue(); + + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return Whether the increment field is set. + */ + boolean hasIncrement(); + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return The increment. + */ + com.google.datastore.v1.Value getIncrement(); + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + com.google.datastore.v1.ValueOrBuilder getIncrementOrBuilder(); + + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property does not change.
+   * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+   * zero input value is always the stored value.
+   * The maximum of any numeric value x and NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + boolean hasMaximum(); + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property does not change.
+   * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+   * zero input value is always the stored value.
+   * The maximum of any numeric value x and NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value maximum = 4; + * + * @return The maximum. + */ + com.google.datastore.v1.Value getMaximum(); + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property does not change.
+   * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+   * zero input value is always the stored value.
+   * The maximum of any numeric value x and NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value maximum = 4; + */ + com.google.datastore.v1.ValueOrBuilder getMaximumOrBuilder(); + + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+   * and -0.0 are all zero. The minimum of a zero stored value and zero input
+   * value is always the stored value. The minimum of any numeric value x and
+   * NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + boolean hasMinimum(); + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+   * and -0.0 are all zero. The minimum of a zero stored value and zero input
+   * value is always the stored value. The minimum of any numeric value x and
+   * NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value minimum = 5; + * + * @return The minimum. + */ + com.google.datastore.v1.Value getMinimum(); + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
+   * and -0.0 are all zero. The minimum of a zero stored value and zero input
+   * value is always the stored value. The minimum of any numeric value x and
+   * NaN is NaN.
+   * 
+ * + * .google.datastore.v1.Value minimum = 5; + */ + com.google.datastore.v1.ValueOrBuilder getMinimumOrBuilder(); + + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is first set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when checking if a value is missing.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + boolean hasAppendMissingElements(); + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is first set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when checking if a value is missing.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + com.google.datastore.v1.ArrayValue getAppendMissingElements(); + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is first set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when checking if a value is missing.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + com.google.datastore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder(); + + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when deciding whether an element should be removed.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + boolean hasRemoveAllFromArray(); + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when deciding whether an element should be removed.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + com.google.datastore.v1.ArrayValue getRemoveAllFromArray(); + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of different types (e.g. 3L and 3.0) are
+   * considered equal when deciding whether an element should be removed.
+   * NaN is equal to NaN, and the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + com.google.datastore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder(); + + com.google.datastore.v1.PropertyTransform.TransformTypeCase getTransformTypeCase(); +} diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java index a91fd271e..25fba4c89 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** @@ -24,6 +24,15 @@ * *
  * A query for entities.
+ *
+ * The query stages are executed in the following order:
+ * 1. kind
+ * 2. filter
+ * 3. projection
+ * 4. order + start_cursor + end_cursor
+ * 5. offset
+ * 6. limit
+ * 7. find_nearest
  * 
* * Protobuf type {@code google.datastore.v1.Query} @@ -553,6 +562,74 @@ public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; } + public static final int FIND_NEAREST_FIELD_NUMBER = 13; + private com.google.datastore.v1.FindNearest findNearest_; + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + @java.lang.Override + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + @java.lang.Override + public com.google.datastore.v1.FindNearest getFindNearest() { + return findNearest_ == null + ? com.google.datastore.v1.FindNearest.getDefaultInstance() + : findNearest_; + } + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.FindNearestOrBuilder getFindNearestOrBuilder() { + return findNearest_ == null + ? com.google.datastore.v1.FindNearest.getDefaultInstance() + : findNearest_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -594,6 +671,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (((bitField0_ & 0x00000002) != 0)) { output.writeMessage(12, getLimit()); } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(13, getFindNearest()); + } getUnknownFields().writeTo(output); } @@ -630,6 +710,9 @@ public int getSerializedSize() { if (((bitField0_ & 0x00000002) != 0)) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, getLimit()); } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(13, getFindNearest()); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -660,6 +743,10 @@ public boolean equals(final java.lang.Object obj) { if (hasLimit()) { if (!getLimit().equals(other.getLimit())) return false; } + if (hasFindNearest() != other.hasFindNearest()) return false; + if (hasFindNearest()) { + if (!getFindNearest().equals(other.getFindNearest())) return false; + } if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -701,6 +788,10 @@ public int hashCode() { hash = (37 * hash) + LIMIT_FIELD_NUMBER; hash = (53 * hash) + getLimit().hashCode(); } + if (hasFindNearest()) { + hash = (37 * hash) + FIND_NEAREST_FIELD_NUMBER; + hash = (53 * hash) + getFindNearest().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -805,6 +896,15 @@ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.Build * *
    * A query for entities.
+   *
+   * The query stages are executed in the following order:
+   * 1. kind
+   * 2. filter
+   * 3. projection
+   * 4. order + start_cursor + end_cursor
+   * 5. offset
+   * 6. limit
+   * 7. find_nearest
    * 
* * Protobuf type {@code google.datastore.v1.Query} @@ -845,6 +945,7 @@ private void maybeForceBuilderInitialization() { getOrderFieldBuilder(); getDistinctOnFieldBuilder(); getLimitFieldBuilder(); + getFindNearestFieldBuilder(); } } @@ -893,6 +994,11 @@ public Builder clear() { limitBuilder_.dispose(); limitBuilder_ = null; } + findNearest_ = null; + if (findNearestBuilder_ != null) { + findNearestBuilder_.dispose(); + findNearestBuilder_ = null; + } return this; } @@ -986,6 +1092,11 @@ private void buildPartial0(com.google.datastore.v1.Query result) { result.limit_ = limitBuilder_ == null ? limit_ : limitBuilder_.build(); to_bitField0_ |= 0x00000002; } + if (((from_bitField0_ & 0x00000200) != 0)) { + result.findNearest_ = + findNearestBuilder_ == null ? findNearest_ : findNearestBuilder_.build(); + to_bitField0_ |= 0x00000004; + } result.bitField0_ |= to_bitField0_; } @@ -1157,6 +1268,9 @@ public Builder mergeFrom(com.google.datastore.v1.Query other) { if (other.hasLimit()) { mergeLimit(other.getLimit()); } + if (other.hasFindNearest()) { + mergeFindNearest(other.getFindNearest()); + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -1265,6 +1379,12 @@ public Builder mergeFrom( bitField0_ |= 0x00000100; break; } // case 98 + case 106: + { + input.readMessage(getFindNearestFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000200; + break; + } // case 106 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -3396,6 +3516,245 @@ public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { return limitBuilder_; } + private com.google.datastore.v1.FindNearest findNearest_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.FindNearest, + com.google.datastore.v1.FindNearest.Builder, + com.google.datastore.v1.FindNearestOrBuilder> + findNearestBuilder_; + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000200) != 0); + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + public com.google.datastore.v1.FindNearest getFindNearest() { + if (findNearestBuilder_ == null) { + return findNearest_ == null + ? com.google.datastore.v1.FindNearest.getDefaultInstance() + : findNearest_; + } else { + return findNearestBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest(com.google.datastore.v1.FindNearest value) { + if (findNearestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + findNearest_ = value; + } else { + findNearestBuilder_.setMessage(value); + } + bitField0_ |= 0x00000200; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest(com.google.datastore.v1.FindNearest.Builder builderForValue) { + if (findNearestBuilder_ == null) { + findNearest_ = builderForValue.build(); + } else { + findNearestBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000200; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeFindNearest(com.google.datastore.v1.FindNearest value) { + if (findNearestBuilder_ == null) { + if (((bitField0_ & 0x00000200) != 0) + && findNearest_ != null + && findNearest_ != com.google.datastore.v1.FindNearest.getDefaultInstance()) { + getFindNearestBuilder().mergeFrom(value); + } else { + findNearest_ = value; + } + } else { + findNearestBuilder_.mergeFrom(value); + } + if (findNearest_ != null) { + bitField0_ |= 0x00000200; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearFindNearest() { + bitField0_ = (bitField0_ & ~0x00000200); + findNearest_ = null; + if (findNearestBuilder_ != null) { + findNearestBuilder_.dispose(); + findNearestBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.FindNearest.Builder getFindNearestBuilder() { + bitField0_ |= 0x00000200; + onChanged(); + return getFindNearestFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.FindNearestOrBuilder getFindNearestOrBuilder() { + if (findNearestBuilder_ != null) { + return findNearestBuilder_.getMessageOrBuilder(); + } else { + return findNearest_ == null + ? com.google.datastore.v1.FindNearest.getDefaultInstance() + : findNearest_; + } + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.FindNearest, + com.google.datastore.v1.FindNearest.Builder, + com.google.datastore.v1.FindNearestOrBuilder> + getFindNearestFieldBuilder() { + if (findNearestBuilder_ == null) { + findNearestBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.FindNearest, + com.google.datastore.v1.FindNearest.Builder, + com.google.datastore.v1.FindNearestOrBuilder>( + getFindNearest(), getParentForChildren(), isClean()); + findNearest_ = null; + } + return findNearestBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryOrBuilder.java index 5783fb2ea..86e6d218f 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface QueryOrBuilder @@ -394,4 +394,57 @@ public interface QueryOrBuilder * .google.protobuf.Int32Value limit = 12; */ com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder(); + + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + boolean hasFindNearest(); + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + com.google.datastore.v1.FindNearest getFindNearest(); + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.FindNearestOrBuilder getFindNearestOrBuilder(); } diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProfileProto.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProfileProto.java index 1e34aa95a..83e5d1763 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProfileProto.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProfileProto.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query_profile.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public final class QueryProfileProto { @@ -67,12 +67,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "\003\0225\n\022execution_duration\030\003 \001(\0132\031.google.p" + "rotobuf.Duration\022\027\n\017read_operations\030\004 \001(" + "\003\022,\n\013debug_stats\030\005 \001(\0132\027.google.protobuf" - + ".StructB\303\001\n\027com.google.datastore.v1B\021Que" - + "ryProfileProtoP\001Z" - + "\n\017property_filter\030\002 \001(\0132#.google.datasto" - + "re.v1.PropertyFilterH\000B\r\n\013filter_type\"\261\001" - + "\n\017CompositeFilter\0229\n\002op\030\001 \001(\0162-.google.d" - + "atastore.v1.CompositeFilter.Operator\022,\n\007" - + "filters\030\002 \003(\0132\033.google.datastore.v1.Filt" - + "er\"5\n\010Operator\022\030\n\024OPERATOR_UNSPECIFIED\020\000" - + "\022\007\n\003AND\020\001\022\006\n\002OR\020\002\"\352\002\n\016PropertyFilter\0228\n\010" - + "property\030\001 \001(\0132&.google.datastore.v1.Pro" - + "pertyReference\0228\n\002op\030\002 \001(\0162,.google.data" - + "store.v1.PropertyFilter.Operator\022)\n\005valu" - + "e\030\003 \001(\0132\032.google.datastore.v1.Value\"\270\001\n\010" - + "Operator\022\030\n\024OPERATOR_UNSPECIFIED\020\000\022\r\n\tLE" - + "SS_THAN\020\001\022\026\n\022LESS_THAN_OR_EQUAL\020\002\022\020\n\014GRE" - + "ATER_THAN\020\003\022\031\n\025GREATER_THAN_OR_EQUAL\020\004\022\t" - + "\n\005EQUAL\020\005\022\006\n\002IN\020\006\022\r\n\tNOT_EQUAL\020\t\022\020\n\014HAS_" - + "ANCESTOR\020\013\022\n\n\006NOT_IN\020\r\"\245\002\n\010GqlQuery\022\024\n\014q" - + "uery_string\030\001 \001(\t\022\026\n\016allow_literals\030\002 \001(" - + "\010\022H\n\016named_bindings\030\005 \003(\01320.google.datas" - + "tore.v1.GqlQuery.NamedBindingsEntry\022C\n\023p" - + "ositional_bindings\030\004 \003(\0132&.google.datast" - + "ore.v1.GqlQueryParameter\032\\\n\022NamedBinding" - + "sEntry\022\013\n\003key\030\001 \001(\t\0225\n\005value\030\002 \001(\0132&.goo" - + "gle.datastore.v1.GqlQueryParameter:\0028\001\"d" - + "\n\021GqlQueryParameter\022+\n\005value\030\002 \001(\0132\032.goo" - + "gle.datastore.v1.ValueH\000\022\020\n\006cursor\030\003 \001(\014" - + "H\000B\020\n\016parameter_type\"\215\004\n\020QueryResultBatc" - + "h\022\027\n\017skipped_results\030\006 \001(\005\022\026\n\016skipped_cu" - + "rsor\030\003 \001(\014\022H\n\022entity_result_type\030\001 \001(\0162," - + ".google.datastore.v1.EntityResult.Result" - + "Type\0229\n\016entity_results\030\002 \003(\0132!.google.da" - + "tastore.v1.EntityResult\022\022\n\nend_cursor\030\004 " - + "\001(\014\022K\n\014more_results\030\005 \001(\01625.google.datas" - + "tore.v1.QueryResultBatch.MoreResultsType" - + "\022\030\n\020snapshot_version\030\007 \001(\003\022-\n\tread_time\030" - + "\010 \001(\0132\032.google.protobuf.Timestamp\"\230\001\n\017Mo" - + "reResultsType\022!\n\035MORE_RESULTS_TYPE_UNSPE" - + "CIFIED\020\000\022\020\n\014NOT_FINISHED\020\001\022\034\n\030MORE_RESUL" - + "TS_AFTER_LIMIT\020\002\022\035\n\031MORE_RESULTS_AFTER_C" - + "URSOR\020\004\022\023\n\017NO_MORE_RESULTS\020\003B\274\001\n\027com.goo" - + "gle.datastore.v1B\nQueryProtoP\001Z\n\017property_filter\030\002" + + " \001(\0132#.google.datastore.v1.PropertyFilte" + + "rH\000B\r\n\013filter_type\"\261\001\n\017CompositeFilter\0229" + + "\n\002op\030\001 \001(\0162-.google.datastore.v1.Composi" + + "teFilter.Operator\022,\n\007filters\030\002 \003(\0132\033.goo" + + "gle.datastore.v1.Filter\"5\n\010Operator\022\030\n\024O" + + "PERATOR_UNSPECIFIED\020\000\022\007\n\003AND\020\001\022\006\n\002OR\020\002\"\352" + + "\002\n\016PropertyFilter\0228\n\010property\030\001 \001(\0132&.go" + + "ogle.datastore.v1.PropertyReference\0228\n\002o" + + "p\030\002 \001(\0162,.google.datastore.v1.PropertyFi" + + "lter.Operator\022)\n\005value\030\003 \001(\0132\032.google.da" + + "tastore.v1.Value\"\270\001\n\010Operator\022\030\n\024OPERATO" + + "R_UNSPECIFIED\020\000\022\r\n\tLESS_THAN\020\001\022\026\n\022LESS_T" + + "HAN_OR_EQUAL\020\002\022\020\n\014GREATER_THAN\020\003\022\031\n\025GREA" + + "TER_THAN_OR_EQUAL\020\004\022\t\n\005EQUAL\020\005\022\006\n\002IN\020\006\022\r" + + "\n\tNOT_EQUAL\020\t\022\020\n\014HAS_ANCESTOR\020\013\022\n\n\006NOT_I" + + "N\020\r\"\323\003\n\013FindNearest\022D\n\017vector_property\030\001" + + " \001(\0132&.google.datastore.v1.PropertyRefer" + + "enceB\003\340A\002\0225\n\014query_vector\030\002 \001(\0132\032.google" + + ".datastore.v1.ValueB\003\340A\002\022O\n\020distance_mea" + + "sure\030\003 \001(\01620.google.datastore.v1.FindNea" + + "rest.DistanceMeasureB\003\340A\002\022/\n\005limit\030\004 \001(\013" + + "2\033.google.protobuf.Int32ValueB\003\340A\002\022%\n\030di" + + "stance_result_property\030\005 \001(\tB\003\340A\001\022=\n\022dis" + + "tance_threshold\030\006 \001(\0132\034.google.protobuf." + + "DoubleValueB\003\340A\001\"_\n\017DistanceMeasure\022 \n\034D" + + "ISTANCE_MEASURE_UNSPECIFIED\020\000\022\r\n\tEUCLIDE" + + "AN\020\001\022\n\n\006COSINE\020\002\022\017\n\013DOT_PRODUCT\020\003\"\245\002\n\010Gq" + + "lQuery\022\024\n\014query_string\030\001 \001(\t\022\026\n\016allow_li" + + "terals\030\002 \001(\010\022H\n\016named_bindings\030\005 \003(\01320.g" + + "oogle.datastore.v1.GqlQuery.NamedBinding" + + "sEntry\022C\n\023positional_bindings\030\004 \003(\0132&.go" + + "ogle.datastore.v1.GqlQueryParameter\032\\\n\022N" + + "amedBindingsEntry\022\013\n\003key\030\001 \001(\t\0225\n\005value\030" + + "\002 \001(\0132&.google.datastore.v1.GqlQueryPara" + + "meter:\0028\001\"d\n\021GqlQueryParameter\022+\n\005value\030" + + "\002 \001(\0132\032.google.datastore.v1.ValueH\000\022\020\n\006c" + + "ursor\030\003 \001(\014H\000B\020\n\016parameter_type\"\215\004\n\020Quer" + + "yResultBatch\022\027\n\017skipped_results\030\006 \001(\005\022\026\n" + + "\016skipped_cursor\030\003 \001(\014\022H\n\022entity_result_t" + + "ype\030\001 \001(\0162,.google.datastore.v1.EntityRe" + + "sult.ResultType\0229\n\016entity_results\030\002 \003(\0132" + + "!.google.datastore.v1.EntityResult\022\022\n\nen" + + "d_cursor\030\004 \001(\014\022K\n\014more_results\030\005 \001(\01625.g" + + "oogle.datastore.v1.QueryResultBatch.More" + + "ResultsType\022\030\n\020snapshot_version\030\007 \001(\003\022-\n" + + "\tread_time\030\010 \001(\0132\032.google.protobuf.Times" + + "tamp\"\230\001\n\017MoreResultsType\022!\n\035MORE_RESULTS" + + "_TYPE_UNSPECIFIED\020\000\022\020\n\014NOT_FINISHED\020\001\022\034\n" + + "\030MORE_RESULTS_AFTER_LIMIT\020\002\022\035\n\031MORE_RESU" + + "LTS_AFTER_CURSOR\020\004\022\023\n\017NO_MORE_RESULTS\020\003B" + + "\273\001\n\027com.google.datastore.v1B\nQueryProtoP" + + "\001Z;cloud.google.com/go/datastore/apiv1/d" + + "atastorepb;datastorepb\252\002\031Google.Cloud.Da" + + "tastore.V1\312\002\031Google\\Cloud\\Datastore\\V1\352\002" + + "\034Google::Cloud::Datastore::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -232,6 +249,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "EndCursor", "Offset", "Limit", + "FindNearest", }); internal_static_google_datastore_v1_AggregationQuery_descriptor = getDescriptor().getMessageTypes().get(2); @@ -335,8 +353,21 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Property", "Op", "Value", }); - internal_static_google_datastore_v1_GqlQuery_descriptor = + internal_static_google_datastore_v1_FindNearest_descriptor = getDescriptor().getMessageTypes().get(10); + internal_static_google_datastore_v1_FindNearest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_FindNearest_descriptor, + new java.lang.String[] { + "VectorProperty", + "QueryVector", + "DistanceMeasure", + "Limit", + "DistanceResultProperty", + "DistanceThreshold", + }); + internal_static_google_datastore_v1_GqlQuery_descriptor = + getDescriptor().getMessageTypes().get(11); internal_static_google_datastore_v1_GqlQuery_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_datastore_v1_GqlQuery_descriptor, @@ -352,7 +383,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Key", "Value", }); internal_static_google_datastore_v1_GqlQueryParameter_descriptor = - getDescriptor().getMessageTypes().get(11); + getDescriptor().getMessageTypes().get(12); internal_static_google_datastore_v1_GqlQueryParameter_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_datastore_v1_GqlQueryParameter_descriptor, @@ -360,7 +391,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Value", "Cursor", "ParameterType", }); internal_static_google_datastore_v1_QueryResultBatch_descriptor = - getDescriptor().getMessageTypes().get(12); + getDescriptor().getMessageTypes().get(13); internal_static_google_datastore_v1_QueryResultBatch_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_datastore_v1_QueryResultBatch_descriptor, diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatch.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatch.java index a8ee6cc57..49bb3799f 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatch.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatch.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatchOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatchOrBuilder.java index b17dc17ae..57ae675f6 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatchOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatchOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/query.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface QueryResultBatchOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptions.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptions.java index a64c56d36..dd545344e 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptions.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptions.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptionsOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptionsOrBuilder.java index dd02b663f..64500abd9 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptionsOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptionsOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface ReadOptionsOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequest.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequest.java index f33ed677e..d37792b79 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequest.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequestOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequestOrBuilder.java index f430680f6..74644db43 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequestOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface ReserveIdsRequestOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponse.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponse.java index 6fd381126..9cf9adff3 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponse.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponse.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponseOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponseOrBuilder.java index f58f797f2..8858bddf2 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponseOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponseOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface ReserveIdsResponseOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequest.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequest.java index ddc3bbdd6..1e3b5e93d 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequest.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequestOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequestOrBuilder.java index 1396a426c..5c4ac4664 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequestOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface RollbackRequestOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponse.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponse.java index 8aed6de56..a8de2a48b 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponse.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponse.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponseOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponseOrBuilder.java index 13fbedee9..3b89b7ed5 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponseOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponseOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface RollbackResponseOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequest.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequest.java index aff95e007..85021f6fa 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequest.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequestOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequestOrBuilder.java index cde16b816..6137bb693 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequestOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface RunAggregationQueryRequestOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponse.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponse.java index 9165ba575..f122b0943 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponse.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponse.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponseOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponseOrBuilder.java index dc90c61e6..cacfa52e8 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponseOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponseOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface RunAggregationQueryResponseOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequest.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequest.java index 4420d5779..7886ca3c7 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequest.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequest.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** @@ -433,6 +433,68 @@ public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { return com.google.datastore.v1.GqlQuery.getDefaultInstance(); } + public static final int PROPERTY_MASK_FIELD_NUMBER = 10; + private com.google.datastore.v1.PropertyMask propertyMask_; + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return Whether the propertyMask field is set. + */ + @java.lang.Override + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return The propertyMask. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMask getPropertyMask() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + public static final int EXPLAIN_OPTIONS_FIELD_NUMBER = 12; private com.google.datastore.v1.ExplainOptions explainOptions_; /** @@ -451,7 +513,7 @@ public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { */ @java.lang.Override public boolean hasExplainOptions() { - return ((bitField0_ & 0x00000004) != 0); + return ((bitField0_ & 0x00000008) != 0); } /** * @@ -525,6 +587,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); } if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(10, getPropertyMask()); + } + if (((bitField0_ & 0x00000008) != 0)) { output.writeMessage(12, getExplainOptions()); } getUnknownFields().writeTo(output); @@ -559,6 +624,9 @@ public int getSerializedSize() { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, databaseId_); } if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getPropertyMask()); + } + if (((bitField0_ & 0x00000008) != 0)) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, getExplainOptions()); } size += getUnknownFields().getSerializedSize(); @@ -586,6 +654,10 @@ public boolean equals(final java.lang.Object obj) { if (hasReadOptions()) { if (!getReadOptions().equals(other.getReadOptions())) return false; } + if (hasPropertyMask() != other.hasPropertyMask()) return false; + if (hasPropertyMask()) { + if (!getPropertyMask().equals(other.getPropertyMask())) return false; + } if (hasExplainOptions() != other.hasExplainOptions()) return false; if (hasExplainOptions()) { if (!getExplainOptions().equals(other.getExplainOptions())) return false; @@ -624,6 +696,10 @@ public int hashCode() { hash = (37 * hash) + READ_OPTIONS_FIELD_NUMBER; hash = (53 * hash) + getReadOptions().hashCode(); } + if (hasPropertyMask()) { + hash = (37 * hash) + PROPERTY_MASK_FIELD_NUMBER; + hash = (53 * hash) + getPropertyMask().hashCode(); + } if (hasExplainOptions()) { hash = (37 * hash) + EXPLAIN_OPTIONS_FIELD_NUMBER; hash = (53 * hash) + getExplainOptions().hashCode(); @@ -782,6 +858,7 @@ private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { getPartitionIdFieldBuilder(); getReadOptionsFieldBuilder(); + getPropertyMaskFieldBuilder(); getExplainOptionsFieldBuilder(); } } @@ -808,6 +885,11 @@ public Builder clear() { if (gqlQueryBuilder_ != null) { gqlQueryBuilder_.clear(); } + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } explainOptions_ = null; if (explainOptionsBuilder_ != null) { explainOptionsBuilder_.dispose(); @@ -870,9 +952,14 @@ private void buildPartial0(com.google.datastore.v1.RunQueryRequest result) { to_bitField0_ |= 0x00000002; } if (((from_bitField0_ & 0x00000040) != 0)) { + result.propertyMask_ = + propertyMaskBuilder_ == null ? propertyMask_ : propertyMaskBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000080) != 0)) { result.explainOptions_ = explainOptionsBuilder_ == null ? explainOptions_ : explainOptionsBuilder_.build(); - to_bitField0_ |= 0x00000004; + to_bitField0_ |= 0x00000008; } result.bitField0_ |= to_bitField0_; } @@ -949,6 +1036,9 @@ public Builder mergeFrom(com.google.datastore.v1.RunQueryRequest other) { if (other.hasReadOptions()) { mergeReadOptions(other.getReadOptions()); } + if (other.hasPropertyMask()) { + mergePropertyMask(other.getPropertyMask()); + } if (other.hasExplainOptions()) { mergeExplainOptions(other.getExplainOptions()); } @@ -1030,10 +1120,16 @@ public Builder mergeFrom( bitField0_ |= 0x00000002; break; } // case 74 + case 82: + { + input.readMessage(getPropertyMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000040; + break; + } // case 82 case 98: { input.readMessage(getExplainOptionsFieldBuilder().getBuilder(), extensionRegistry); - bitField0_ |= 0x00000040; + bitField0_ |= 0x00000080; break; } // case 98 default: @@ -2104,6 +2200,227 @@ public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { return gqlQueryBuilder_; } + private com.google.datastore.v1.PropertyMask propertyMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + propertyMaskBuilder_; + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return Whether the propertyMask field is set. + */ + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000040) != 0); + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return The propertyMask. + */ + public com.google.datastore.v1.PropertyMask getPropertyMask() { + if (propertyMaskBuilder_ == null) { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } else { + return propertyMaskBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + propertyMask_ = value; + } else { + propertyMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask.Builder builderForValue) { + if (propertyMaskBuilder_ == null) { + propertyMask_ = builderForValue.build(); + } else { + propertyMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder mergePropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) + && propertyMask_ != null + && propertyMask_ != com.google.datastore.v1.PropertyMask.getDefaultInstance()) { + getPropertyMaskBuilder().mergeFrom(value); + } else { + propertyMask_ = value; + } + } else { + propertyMaskBuilder_.mergeFrom(value); + } + if (propertyMask_ != null) { + bitField0_ |= 0x00000040; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder clearPropertyMask() { + bitField0_ = (bitField0_ & ~0x00000040); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public com.google.datastore.v1.PropertyMask.Builder getPropertyMaskBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return getPropertyMaskFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + if (propertyMaskBuilder_ != null) { + return propertyMaskBuilder_.getMessageOrBuilder(); + } else { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + } + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + getPropertyMaskFieldBuilder() { + if (propertyMaskBuilder_ == null) { + propertyMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder>( + getPropertyMask(), getParentForChildren(), isClean()); + propertyMask_ = null; + } + return propertyMaskBuilder_; + } + private com.google.datastore.v1.ExplainOptions explainOptions_; private com.google.protobuf.SingleFieldBuilderV3< com.google.datastore.v1.ExplainOptions, @@ -2125,7 +2442,7 @@ public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { * @return Whether the explainOptions field is set. */ public boolean hasExplainOptions() { - return ((bitField0_ & 0x00000040) != 0); + return ((bitField0_ & 0x00000080) != 0); } /** * @@ -2171,7 +2488,7 @@ public Builder setExplainOptions(com.google.datastore.v1.ExplainOptions value) { } else { explainOptionsBuilder_.setMessage(value); } - bitField0_ |= 0x00000040; + bitField0_ |= 0x00000080; onChanged(); return this; } @@ -2194,7 +2511,7 @@ public Builder setExplainOptions( } else { explainOptionsBuilder_.setMessage(builderForValue.build()); } - bitField0_ |= 0x00000040; + bitField0_ |= 0x00000080; onChanged(); return this; } @@ -2212,7 +2529,7 @@ public Builder setExplainOptions( */ public Builder mergeExplainOptions(com.google.datastore.v1.ExplainOptions value) { if (explainOptionsBuilder_ == null) { - if (((bitField0_ & 0x00000040) != 0) + if (((bitField0_ & 0x00000080) != 0) && explainOptions_ != null && explainOptions_ != com.google.datastore.v1.ExplainOptions.getDefaultInstance()) { getExplainOptionsBuilder().mergeFrom(value); @@ -2223,7 +2540,7 @@ public Builder mergeExplainOptions(com.google.datastore.v1.ExplainOptions value) explainOptionsBuilder_.mergeFrom(value); } if (explainOptions_ != null) { - bitField0_ |= 0x00000040; + bitField0_ |= 0x00000080; onChanged(); } return this; @@ -2241,7 +2558,7 @@ public Builder mergeExplainOptions(com.google.datastore.v1.ExplainOptions value) * */ public Builder clearExplainOptions() { - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = (bitField0_ & ~0x00000080); explainOptions_ = null; if (explainOptionsBuilder_ != null) { explainOptionsBuilder_.dispose(); @@ -2263,7 +2580,7 @@ public Builder clearExplainOptions() { * */ public com.google.datastore.v1.ExplainOptions.Builder getExplainOptionsBuilder() { - bitField0_ |= 0x00000040; + bitField0_ |= 0x00000080; onChanged(); return getExplainOptionsFieldBuilder().getBuilder(); } diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequestOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequestOrBuilder.java index 9e7a6f0b9..858455723 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequestOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequestOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface RunQueryRequestOrBuilder @@ -229,6 +229,53 @@ public interface RunQueryRequestOrBuilder */ com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder(); + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return Whether the propertyMask field is set. + */ + boolean hasPropertyMask(); + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return The propertyMask. + */ + com.google.datastore.v1.PropertyMask getPropertyMask(); + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder(); + /** * * diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponse.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponse.java index 03d5b4b8f..714256e65 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponse.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponse.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponseOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponseOrBuilder.java index e3c0dbf8d..c7fceec74 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponseOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponseOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface RunQueryResponseOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptions.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptions.java index 52c53d486..7e73f6826 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptions.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptions.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptionsOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptionsOrBuilder.java index 5abaa12a4..551969802 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptionsOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptionsOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/datastore.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface TransactionOptionsOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Value.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Value.java index 1d63815b9..56b6fae30 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Value.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Value.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/entity.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; /** diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ValueOrBuilder.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ValueOrBuilder.java index 8e4021a58..a375525d9 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ValueOrBuilder.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ValueOrBuilder.java @@ -16,7 +16,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/datastore/v1/entity.proto -// Protobuf Java Version: 3.25.3 +// Protobuf Java Version: 3.25.5 package com.google.datastore.v1; public interface ValueOrBuilder diff --git a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/aggregation_result.proto b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/aggregation_result.proto index 91c521716..e31052c0d 100644 --- a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/aggregation_result.proto +++ b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/aggregation_result.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import "google/datastore/v1/query.proto"; import "google/protobuf/timestamp.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; option java_multiple_files = true; option java_outer_classname = "AggregationResultProto"; option java_package = "com.google.datastore.v1"; diff --git a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/datastore.proto b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/datastore.proto index 1a3fbdd11..c0683b9ba 100644 --- a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/datastore.proto +++ b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/datastore.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import "google/datastore/v1/query_profile.proto"; import "google/protobuf/timestamp.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; option java_multiple_files = true; option java_outer_classname = "DatastoreProto"; option java_package = "com.google.datastore.v1"; @@ -173,6 +173,14 @@ message LookupRequest { // Required. Keys of entities to look up. repeated Key keys = 3 [(google.api.field_behavior) = REQUIRED]; + + // The properties to return. Defaults to returning all properties. + // + // If this field is set and an entity has a property not referenced in the + // mask, it will be absent from [LookupResponse.found.entity.properties][]. + // + // The entity's key is always returned. + PropertyMask property_mask = 5; } // The response for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup]. @@ -234,6 +242,13 @@ message RunQueryRequest { GqlQuery gql_query = 7; } + // The properties to return. + // This field must not be set for a projection query. + // + // See + // [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. + PropertyMask property_mask = 10; + // Optional. Explain options for the query. If set, additional query // statistics will be returned. If not, only query results will be returned. ExplainOptions explain_options = 12 [(google.api.field_behavior) = OPTIONAL]; @@ -486,6 +501,18 @@ message ReserveIdsResponse {} // A mutation to apply to an entity. message Mutation { + // The possible ways to resolve a conflict detected in a mutation. + enum ConflictResolutionStrategy { + // Unspecified. Defaults to `SERVER_VALUE`. + STRATEGY_UNSPECIFIED = 0; + + // The server entity is kept. + SERVER_VALUE = 1; + + // The whole commit request fails. + FAIL = 3; + } + // The mutation operation. // // For `insert`, `update`, and `upsert`: @@ -526,6 +553,127 @@ message Mutation { // mutation conflicts. google.protobuf.Timestamp update_time = 11; } + + // The strategy to use when a conflict is detected. Defaults to + // `SERVER_VALUE`. + // If this is set, then `conflict_detection_strategy` must also be set. + ConflictResolutionStrategy conflict_resolution_strategy = 10; + + // The properties to write in this mutation. + // None of the properties in the mask may have a reserved name, except for + // `__key__`. + // This field is ignored for `delete`. + // + // If the entity already exists, only properties referenced in the mask are + // updated, others are left untouched. + // Properties referenced in the mask but not in the entity are deleted. + PropertyMask property_mask = 9; + + // Optional. The transforms to perform on the entity. + // + // This field can be set only when the operation is `insert`, `update`, + // or `upsert`. If present, the transforms are be applied to the entity + // regardless of the property mask, in order, after the operation. + repeated PropertyTransform property_transforms = 12 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A transformation of an entity property. +message PropertyTransform { + // A value that is calculated by the server. + enum ServerValue { + // Unspecified. This value must not be used. + SERVER_VALUE_UNSPECIFIED = 0; + + // The time at which the server processed the request, with millisecond + // precision. If used on multiple properties (same or different entities) + // in a transaction, all the properties will get the same server timestamp. + REQUEST_TIME = 1; + } + + // Optional. The name of the property. + // + // Property paths (a list of property names separated by dots (`.`)) may be + // used to refer to properties inside entity values. For example `foo.bar` + // means the property `bar` inside the entity property `foo`. + // + // If a property name contains a dot `.` or a backlslash `\`, then that name + // must be escaped. + string property = 1 [(google.api.field_behavior) = OPTIONAL]; + + // The transformation to apply to the property. + oneof transform_type { + // Sets the property to the given server value. + ServerValue set_to_server_value = 2; + + // Adds the given value to the property's current value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the given value. + // If either of the given value or the current property value are doubles, + // both values will be interpreted as doubles. Double arithmetic and + // representation of double values follows IEEE 754 semantics. + // If there is positive/negative integer overflow, the property is resolved + // to the largest magnitude positive/negative integer. + Value increment = 3; + + // Sets the property to the maximum of its current value and the given + // value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the given value. + // If a maximum operation is applied where the property and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the property takes on the type of the larger operand. If the operands are + // equivalent (e.g. 3 and 3.0), the property does not change. + // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and + // zero input value is always the stored value. + // The maximum of any numeric value x and NaN is NaN. + Value maximum = 4; + + // Sets the property to the minimum of its current value and the given + // value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the input value. + // If a minimum operation is applied where the property and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the property takes on the type of the smaller operand. If the operands + // are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0, + // and -0.0 are all zero. The minimum of a zero stored value and zero input + // value is always the stored value. The minimum of any numeric value x and + // NaN is NaN. + Value minimum = 5; + + // Appends the given elements in order if they are not already present in + // the current property value. + // If the property is not an array, or if the property does not yet exist, + // it is first set to the empty array. + // + // Equivalent numbers of different types (e.g. 3L and 3.0) are + // considered equal when checking if a value is missing. + // NaN is equal to NaN, and the null value is equal to the null value. + // If the input contains multiple equivalent values, only the first will + // be considered. + // + // The corresponding transform result will be the null value. + ArrayValue append_missing_elements = 6; + + // Removes all of the given elements from the array in the property. + // If the property is not an array, or if the property does not yet exist, + // it is set to the empty array. + // + // Equivalent numbers of different types (e.g. 3L and 3.0) are + // considered equal when deciding whether an element should be removed. + // NaN is equal to NaN, and the null value is equal to the null value. + // This will remove all equivalent values if there are duplicates. + // + // The corresponding transform result will be the null value. + ArrayValue remove_all_from_array = 7; + } } // The result of applying a mutation. @@ -553,6 +701,28 @@ message MutationResult { // Whether a conflict was detected for this mutation. Always false when a // conflict detection strategy field is not set in the mutation. bool conflict_detected = 5; + + // The results of applying each + // [PropertyTransform][google.datastore.v1.PropertyTransform], in the same + // order of the request. + repeated Value transform_results = 8; +} + +// The set of arbitrarily nested property paths used to restrict an operation to +// only a subset of properties in an entity. +message PropertyMask { + // The paths to the properties covered by this mask. + // + // A path is a list of property names separated by dots (`.`), for example + // `foo.bar` means the property `bar` inside the entity property `foo` inside + // the entity associated with this path. + // + // If a property name contains a dot `.` or a backslash `\`, then that + // name must be escaped. + // + // A path must not be empty, and may not reference a value inside an + // [array value][google.datastore.v1.Value.array_value]. + repeated string paths = 1; } // The options shared by read requests. @@ -569,16 +739,13 @@ message ReadOptions { EVENTUAL = 2; } - // For Cloud Datastore, if read_consistency is not specified, then lookups and - // ancestor queries default to `read_consistency`=`STRONG`, global queries - // default to `read_consistency`=`EVENTUAL`. - // - // For Cloud Firestore in Datastore mode, if read_consistency is not specified - // then lookups and all queries default to `read_consistency`=`STRONG`. + // For Cloud Firestore in Datastore mode, if you don't specify + // read_consistency then all lookups and queries default to + // `read_consistency`=`STRONG`. Note that, in Cloud Datastore, global queries + // defaulted to `read_consistency`=`EVENTUAL`. // // Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually - // consistent lookups & queries in both Cloud Datastore & Cloud Firestore in - // Datastore mode. + // consistent lookups and queries. oneof consistency_type { // The non-transactional read consistency to use. ReadConsistency read_consistency = 1; diff --git a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/entity.proto b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/entity.proto index d80dd9093..d9742d68d 100644 --- a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/entity.proto +++ b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/entity.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import "google/protobuf/timestamp.proto"; import "google/type/latlng.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; option java_multiple_files = true; option java_outer_classname = "EntityProto"; option java_package = "com.google.datastore.v1"; diff --git a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto index d1f0f8d07..3c2e8ae66 100644 --- a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto +++ b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; option java_multiple_files = true; option java_outer_classname = "QueryProto"; option java_package = "com.google.datastore.v1"; @@ -82,6 +82,15 @@ message EntityResult { } // A query for entities. +// +// The query stages are executed in the following order: +// 1. kind +// 2. filter +// 3. projection +// 4. order + start_cursor + end_cursor +// 5. offset +// 6. limit +// 7. find_nearest message Query { // The projection to return. Defaults to returning all properties. repeated Projection projection = 2; @@ -127,6 +136,13 @@ message Query { // Unspecified is interpreted as no limit. // Must be >= 0 if specified. google.protobuf.Int32Value limit = 12; + + // Optional. A potential Nearest Neighbors Search. + // + // Applies after all other filters and ordering. + // + // Finds the closest vector embeddings to the given query vector. + FindNearest find_nearest = 13 [(google.api.field_behavior) = OPTIONAL]; } // Datastore query for running an aggregation over a @@ -436,6 +452,70 @@ message PropertyFilter { Value value = 3; } +// Nearest Neighbors search config. The ordering provided by FindNearest +// supersedes the order_by stage. If multiple documents have the same vector +// distance, the returned document order is not guaranteed to be stable between +// queries. +message FindNearest { + // The distance measure to use when comparing vectors. + enum DistanceMeasure { + // Should not be set. + DISTANCE_MEASURE_UNSPECIFIED = 0; + + // Measures the EUCLIDEAN distance between the vectors. See + // [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn + // more. The resulting distance decreases the more similar two vectors are. + EUCLIDEAN = 1; + + // COSINE distance compares vectors based on the angle between them, which + // allows you to measure similarity that isn't based on the vectors + // magnitude. We recommend using DOT_PRODUCT with unit normalized vectors + // instead of COSINE distance, which is mathematically equivalent with + // better performance. See [Cosine + // Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn + // more about COSINE similarity and COSINE distance. The resulting COSINE + // distance decreases the more similar two vectors are. + COSINE = 2; + + // Similar to cosine but is affected by the magnitude of the vectors. See + // [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more. + // The resulting distance increases the more similar two vectors are. + DOT_PRODUCT = 3; + } + + // Required. An indexed vector property to search upon. Only documents which + // contain vectors whose dimensionality match the query_vector can be + // returned. + PropertyReference vector_property = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The query vector that we are searching on. Must be a vector of no + // more than 2048 dimensions. + Value query_vector = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Distance Measure to use, required. + DistanceMeasure distance_measure = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. The number of nearest neighbors to return. Must be a positive + // integer of no more than 100. + google.protobuf.Int32Value limit = 4 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Optional name of the field to output the result of the vector + // distance calculation. Must conform to [entity + // property][google.datastore.v1.Entity.properties] limitations. + string distance_result_property = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Option to specify a threshold for which no less similar documents + // will be returned. The behavior of the specified `distance_measure` will + // affect the meaning of the distance threshold. Since DOT_PRODUCT distances + // increase when the vectors are more similar, the comparison is inverted. + // + // For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold + // For DOT_PRODUCT: WHERE distance >= distance_threshold + google.protobuf.DoubleValue distance_threshold = 6 + [(google.api.field_behavior) = OPTIONAL]; +} + // A [GQL // query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). message GqlQuery { diff --git a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query_profile.proto b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query_profile.proto index 01c9fc254..e00a28e3c 100644 --- a/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query_profile.proto +++ b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query_profile.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import "google/protobuf/duration.proto"; import "google/protobuf/struct.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; option java_multiple_files = true; option java_outer_classname = "QueryProfileProto"; option java_package = "com.google.datastore.v1"; diff --git a/renovate.json b/renovate.json index 7b2939806..586208852 100644 --- a/renovate.json +++ b/renovate.json @@ -1,4 +1,6 @@ + { + "extends": [ ":separateMajorReleases", ":combinePatchMinorReleases", @@ -23,7 +25,9 @@ "fileMatch": [ "^.kokoro/presubmit/graalvm-native.*.cfg$" ], - "matchStrings": ["value: \"gcr.io/cloud-devrel-public-resources/graalvm.*:(?.*?)\""], + "matchStrings": [ + "value: \"gcr.io/cloud-devrel-public-resources/graalvm.*:(?.*?)\"" + ], "depNameTemplate": "com.google.cloud:sdk-platform-java-config", "datasourceTemplate": "maven" }, @@ -32,7 +36,9 @@ "fileMatch": [ "^.github/workflows/unmanaged_dependency_check.yaml$" ], - "matchStrings": ["uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v(?.+?)\\n"], + "matchStrings": [ + "uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v(?.+?)\\n" + ], "depNameTemplate": "com.google.cloud:sdk-platform-java-config", "datasourceTemplate": "maven" } @@ -99,4 +105,4 @@ ], "semanticCommits": true, "dependencyDashboard": true -} +} \ No newline at end of file diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index d36722381..f60a4bb5a 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-datastore - 2.19.1 + 2.25.0 @@ -42,7 +42,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test
@@ -53,7 +53,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.5.0 + 3.6.0 add-snippets-source diff --git a/samples/native-image-sample/README.md b/samples/native-image-sample/README.md deleted file mode 100644 index 5f2cfbd27..000000000 --- a/samples/native-image-sample/README.md +++ /dev/null @@ -1,96 +0,0 @@ -# Datastore Sample Application with Native Image - -This application uses the [Google Cloud Datastore client library](https://cloud.google.com/datastore/docs/reference/libraries) and is compatible with Native Image compilation. - -This sample runs through some basic operations of creating/deleting entities, running queries, and running transaction code. - -## Setup Instructions - -You will need to follow these prerequisite steps in order to run the samples: - -1. If you have not already, [create a Google Cloud Platform Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project). - -2. Install the [Google Cloud SDK](https://cloud.google.com/sdk/) which will allow you to run the sample with your project's credentials. - - Once installed, log in with Application Default Credentials using the following command: - - ``` - gcloud auth application-default login - ``` - - **Note:** Authenticating with Application Default Credentials is convenient to use during development, but we recommend [alternate methods of authentication](https://cloud.google.com/docs/authentication/production) during production use. - -3. Install the native image compiler. - - You can follow the [installation instructions](https://www.graalvm.org/docs/getting-started/#install-graalvm). - After following the instructions, ensure that you install the native image extension installed by running: - - ``` - gu install native-image - ``` - - Once you finish following the instructions, verify that the default version of Java is set to the correct version by running `java -version` in a terminal. - - You will see something similar to the below output: - - ``` - $ java -version - - openjdk version "17.0.3" 2022-04-19 - OpenJDK Runtime Environment GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06) - OpenJDK 64-Bit Server VM GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06, mixed mode, sharing) - ``` -## Sample -1. **(Optional)** If you wish to run the application against the [Datastore emulator](https://cloud.google.com/sdk/gcloud/reference/beta/emulators/datastore), ensure that you have the [Google Cloud SDK](https://cloud.google.com/sdk) installed. - - In a new terminal window, start the emulator via `gcloud`: - - ``` - gcloud beta emulators datastore start --host-port=localhost:9010 - ``` - - Leave the emulator running in this terminal for now. - In the next section, we will run the sample application against the Datastore emulator instance. - -2. Navigate to this directory and compile the application with the native image compiler. - - ``` - mvn package -P native -DskipTests - ``` - -3. **(Optional)** If you're using the emulator, export the `DATASTORE_EMULATOR_HOST` as an environment variable in your terminal. - - ``` - export DATASTORE_EMULATOR_HOST=localhost:9010 - ``` - - The Datastore Client Libraries will detect this environment variable and automatically connect to the emulator instance if this variable is set. - -4. Run the application. - - ``` - ./target/native-image-sample - ``` - -5. The application will run through some basic Datastore operations and log some output statements. - - ``` - Successfully added entity. - Reading entity: 1cf34cc1-2b8a-4945-9fc4-058f03dcd08e - Successfully deleted entity: 1cf34cc1-2b8a-4945-9fc4-058f03dcd08e - Run fake transaction code. - Found entity: - name=de4f36f4-3936-4252-98d3-e0d56d485254 - kind=test-kind - namespace=nativeimage-test-namespace - properties={description=StringValue{valueType=STRING, excludeFromIndexes=false, meaning=0, value=hello world}} - Ran transaction callable. - ``` - -### Sample Integration test with Native Image Support - -In order to run the sample integration test as a native image, call the following command: - - ``` - mvn test -Pnative - ``` diff --git a/samples/native-image-sample/pom.xml b/samples/native-image-sample/pom.xml index d1d30028d..e69de29bb 100644 --- a/samples/native-image-sample/pom.xml +++ b/samples/native-image-sample/pom.xml @@ -1,141 +0,0 @@ - - - 4.0.0 - com.example.datastore - native-image-sample - Native Image Sample - https://github.com/googleapis/java-datastore - - - - com.google.cloud.samples - shared-configuration - 1.2.0 - - - - - 1.8 - 1.8 - UTF-8 - - - - - - com.google.cloud - libraries-bom - 26.38.0 - pom - import - - - - - - - com.google.cloud - google-cloud-datastore - - - - junit - junit - 4.13.2 - test - - - com.google.truth - truth - 1.4.2 - test - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - com.example.datastore.NativeImageDatastoreSample - - - - - - - - - - - native - - - - org.junit.vintage - junit-vintage-engine - 5.10.2 - test - - - org.graalvm.buildtools - junit-platform-native - 0.10.1 - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - 3.2.5 - - - **/IT* - - - - - org.graalvm.buildtools - native-maven-plugin - 0.10.1 - true - - com.example.datastore.NativeImageDatastoreSample - - --no-fallback - --no-server - - - - - build-native - - build - test - - package - - - test-native - - test - - test - - - - - - - - \ No newline at end of file diff --git a/samples/native-image-sample/src/main/java/com/example/datastore/NativeImageDatastoreSample.java b/samples/native-image-sample/src/main/java/com/example/datastore/NativeImageDatastoreSample.java deleted file mode 100644 index 7ce5c900a..000000000 --- a/samples/native-image-sample/src/main/java/com/example/datastore/NativeImageDatastoreSample.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2020-2021 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.example.datastore; - -import com.google.cloud.datastore.Datastore; -import com.google.cloud.datastore.DatastoreOptions; -import com.google.cloud.datastore.Entity; -import com.google.cloud.datastore.Key; -import com.google.cloud.datastore.Query; -import com.google.cloud.datastore.QueryResults; -import com.google.cloud.datastore.StructuredQuery; -import com.google.cloud.datastore.Transaction; -import java.time.Duration; -import java.time.Instant; -import java.util.UUID; - -/** Sample Datastore Application. */ -public class NativeImageDatastoreSample { - - /* Datastore namespace where entities will be created. */ - private static final String TEST_NAMESPACE = "nativeimage-test-namespace"; - - /* Datastore kind used. */ - private static final String TEST_KIND = "test-kind"; - - /** Entrypoint to the Datastore sample application. */ - public static void main(String[] args) { - Instant startTime = Instant.now(); - Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); - - String testId = UUID.randomUUID().toString(); - - addEntity(datastore, testId); - getEntity(datastore, testId); - deleteEntity(datastore, testId); - - runTransaction(datastore); - - String id = UUID.randomUUID().toString(); - Key key = createKey(datastore, id); - runTransactionCallable(datastore, key); - Instant endTime = Instant.now(); - Duration duration = Duration.between(startTime, endTime); - System.out.println("Duration: " + duration.toString()); - } - - static void addEntity(Datastore datastore, String id) { - Key key = createKey(datastore, id); - Entity entity = Entity.newBuilder(key).set("description", "hello world").build(); - datastore.add(entity); - System.out.println("Successfully added entity."); - } - - static void getEntity(Datastore datastore, String id) { - Key key = createKey(datastore, id); - Entity entity = datastore.get(key); - System.out.println("Reading entity: " + entity.getKey().getName()); - } - - static void deleteEntity(Datastore datastore, String id) { - Key key = createKey(datastore, id); - datastore.delete(key); - - Entity entity = datastore.get(key); - if (entity == null) { - System.out.println("Successfully deleted entity: " + id); - } else { - throw new RuntimeException("Failed to delete entity: " + id); - } - } - - static void runTransactionCallable(Datastore datastore, Key entityKey) { - datastore.runInTransaction( - client -> { - Entity entity = Entity.newBuilder(entityKey).set("description", "hello world").build(); - datastore.add(entity); - - StructuredQuery query = - Query.newEntityQueryBuilder().setNamespace(TEST_NAMESPACE).setKind(TEST_KIND).build(); - - QueryResults results = datastore.run(query); - while (results.hasNext()) { - Entity result = results.next(); - String name = result.getKey().getName(); - String kind = result.getKey().getKind(); - String namespace = result.getKey().getNamespace(); - System.out.println( - "Found entity:" - + "\n\t\tname=" - + name - + "\n\t\tkind=" - + kind - + "\n\t\tnamespace=" - + namespace - + "\n\t\tproperties=" - + result.getProperties().toString()); - } - - datastore.delete(entityKey); - return null; - }); - - System.out.println("Ran transaction callable."); - } - - private static void runTransaction(Datastore datastore) { - Transaction transaction = datastore.newTransaction(); - transaction.commit(); - transaction = datastore.newTransaction(); - transaction.rollback(); - System.out.println("Run fake transaction code."); - } - - static Key createKey(Datastore datastore, String id) { - return datastore.newKeyFactory().setNamespace(TEST_NAMESPACE).setKind(TEST_KIND).newKey(id); - } -} diff --git a/samples/native-image-sample/src/test/java/com/example/datastore/ITNativeImageDatastoreSample.java b/samples/native-image-sample/src/test/java/com/example/datastore/ITNativeImageDatastoreSample.java deleted file mode 100644 index 710f18367..000000000 --- a/samples/native-image-sample/src/test/java/com/example/datastore/ITNativeImageDatastoreSample.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 - * - * 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.example.datastore; - -import static com.google.common.truth.Truth.assertThat; - -import com.google.cloud.datastore.Datastore; -import com.google.cloud.datastore.DatastoreOptions; -import com.google.cloud.datastore.Key; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.UUID; -import org.junit.Before; -import org.junit.Test; - -/** Tests for {@link com.example.datastore.NativeImageDatastoreSample} */ -public class ITNativeImageDatastoreSample { - - private Datastore datastore; - private ByteArrayOutputStream bout; - private PrintStream out; - - @Before - public void setUp() { - datastore = DatastoreOptions.getDefaultInstance().getService(); - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - } - - @Test - public void testAddAndGetEntity() { - bout.reset(); - String testId = "test-id-" + UUID.randomUUID(); - NativeImageDatastoreSample.addEntity(datastore, testId); - NativeImageDatastoreSample.getEntity(datastore, testId); - assertThat(bout.toString()).contains("Reading entity: " + testId); - - NativeImageDatastoreSample.deleteEntity(datastore, testId); - } - - @Test - public void testRunTransactionalCallable() { - bout.reset(); - String testId = "test-id-" + UUID.randomUUID(); - Key key = NativeImageDatastoreSample.createKey(datastore, testId); - NativeImageDatastoreSample.runTransactionCallable(datastore, key); - assertThat(bout.toString()) - .contains( - "Found entity:" - + "\n\t\tname=" - + testId - + "\n\t\tkind=test-kind" - + "\n\t\tnamespace=nativeimage-test-namespace" - + "\n\t\tproperties={description=StringValue{valueType=STRING, excludeFromIndexes=false," - + " meaning=0, value=hello world}}\n" - + "Ran transaction callable."); - - NativeImageDatastoreSample.deleteEntity(datastore, "test-id"); - } -} diff --git a/samples/pom.xml b/samples/pom.xml index a24801164..56fd2ae2c 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -31,7 +31,6 @@ install-without-bom snapshot snippets - native-image-sample @@ -39,7 +38,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.3 true @@ -47,7 +46,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 true diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 45331e46b..174ac036d 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-datastore - 2.19.2-SNAPSHOT + 2.25.1 @@ -41,7 +41,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test @@ -52,7 +52,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.5.0 + 3.6.0 add-snippets-source diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 82f0945a7..95c5f4db4 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 26.38.0 + 26.51.0 pom import @@ -53,7 +53,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test diff --git a/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java b/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java new file mode 100644 index 000000000..90a94014c --- /dev/null +++ b/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java @@ -0,0 +1,64 @@ +/* + * Copyright 2024 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.example.datastore.filters; + +// sample-metadata: +// title: Queries with indexing considerations +// description: The following query produces a result set +// that is ordered according to the index definition. + +// [START datastore_query_indexing_considerations] + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + +public class IndexingConsiderationQuery { + public static void invoke() throws Exception { + + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build a query with multi inequal filters and optimized index order of index properties. + Query query = + Query.newEntityQueryBuilder() + .setKind("employees") + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("salary", 100000), PropertyFilter.gt("experience", 0))) + .setOrderBy(OrderBy.asc("salary"), OrderBy.asc("experience")) + .build(); + + // Get the results back from Datastore + QueryResults results = datastore.run(query); + + if (!results.hasNext()) { + throw new Exception("query yielded no results"); + } + + while (results.hasNext()) { + Entity entity = results.next(); + System.out.printf("Entity: %s%n", entity); + } + } +} +// [END datastore_query_indexing_considerations] diff --git a/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java b/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java new file mode 100644 index 000000000..24fc7901c --- /dev/null +++ b/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java @@ -0,0 +1,62 @@ +/* + * Copyright 2024 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.example.datastore.filters; + +// sample-metadata: +// title: Queries with order fileds +// description: The following query order properties +// in the decreasing order of query constraint selectivity. + +// [START datastore_query_order_fields] + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + +public class OrderFieldsQuery { + public static void invoke() throws Exception { + + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build a query with order properties in the decreasing order of query constraint selectivity. + Query query = + Query.newEntityQueryBuilder() + .setKind("employees") + .setFilter(PropertyFilter.gt("salary", 100000)) + .setOrderBy(OrderBy.asc("salary")) + .build(); + + // Get the results back from Datastore + QueryResults results = datastore.run(query); + // Order results by `experience` + + if (!results.hasNext()) { + throw new Exception("query yielded no results"); + } + + while (results.hasNext()) { + Entity entity = results.next(); + System.out.printf("Entity: %s%n", entity); + } + } +} +// [END datastore_query_order_fields] diff --git a/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.java b/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.java new file mode 100644 index 000000000..8e3fa4c10 --- /dev/null +++ b/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.java @@ -0,0 +1,98 @@ +/* + * Copyright 2024 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.example.datastore.filters; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.rule.SystemsOutRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class MultiIneqQuerySampleIT { + + private final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + private Key employeeKey1; + private Key employeeKey2; + private Key employeeKey3; + + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + + @Before + public void setUp() { + employeeKey1 = datastore.newKeyFactory().setKind("employees").newKey("employee1"); + Entity employee1 = + Entity.newBuilder(employeeKey1) + .set("name", "Alice") + .set("salary", 100001) + .set("experience", 10) + .build(); + + employeeKey2 = datastore.newKeyFactory().setKind("employees").newKey("employee2"); + Entity employee2 = + Entity.newBuilder(employeeKey2) + .set("name", "Bob") + .set("salary", 90000) + .set("experience", 5) + .build(); + + employeeKey3 = datastore.newKeyFactory().setKind("employees").newKey("employee3"); + Entity employee3 = + Entity.newBuilder(employeeKey3) + .set("name", "Jay") + .set("salary", 120000) + .set("experience", 15) + .build(); + + datastore.put(employee1); + datastore.put(employee2); + datastore.put(employee3); + } + + @After + public void tearDown() { + datastore.delete(employeeKey1); + datastore.delete(employeeKey2); + datastore.delete(employeeKey3); + } + + @Test + public void testIndexingConsiderationQuery() throws Exception { + // Act + IndexingConsiderationQuery.invoke(); + + // Assert + systemsOutRule.assertContains("Entity"); + } + + @Test + public void testOrderFieldsQuery() throws Exception { + // Act + OrderFieldsQuery.invoke(); + + // Assert + systemsOutRule.assertContains("Entity"); + } +} diff --git a/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java b/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java index 1397728ba..33aa63ab4 100644 --- a/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java +++ b/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java @@ -77,7 +77,6 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; /** Contains Cloud Datastore snippets demonstrating concepts for documentation. */ @RunWith(JUnit4.class) @@ -147,7 +146,7 @@ public void tearDown() throws Exception { */ @AfterClass public static void afterClass() throws IOException, InterruptedException, TimeoutException { - HELPER.stop(Duration.ofMinutes(1)); + HELPER.stopDuration(java.time.Duration.ofMinutes(1)); } private void assertValidKey(Key taskKey) { @@ -297,8 +296,17 @@ public void testLookup() { public void testUpdate() { datastore.put(testEntity); // [START datastore_update] - Entity task = Entity.newBuilder(datastore.get(taskKey)).set("priority", 5).build(); - datastore.update(task); + Entity task; + Transaction txn = datastore.newTransaction(); + try { + task = Entity.newBuilder(txn.get(taskKey)).set("priority", 5).build(); + txn.put(task); + txn.commit(); + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } // [END datastore_update] assertEquals(task, datastore.get(taskKey)); } diff --git a/samples/snippets/src/test/resources/index.yaml b/samples/snippets/src/test/resources/index.yaml index 8652a0ee0..5f2f0c74a 100644 --- a/samples/snippets/src/test/resources/index.yaml +++ b/samples/snippets/src/test/resources/index.yaml @@ -23,3 +23,7 @@ indexes: properties: - name: tag - name: tag +- kind: employees + properties: + - name: salary + - name: experience \ No newline at end of file diff --git a/versions.txt b/versions.txt index 3d01cfb1c..783c47b1f 100644 --- a/versions.txt +++ b/versions.txt @@ -1,9 +1,9 @@ # Format: # module:released-version:current-version -google-cloud-datastore:2.19.1:2.19.2-SNAPSHOT -google-cloud-datastore-bom:2.19.1:2.19.2-SNAPSHOT -proto-google-cloud-datastore-v1:0.110.1:0.110.2-SNAPSHOT -datastore-v1-proto-client:2.19.1:2.19.2-SNAPSHOT -proto-google-cloud-datastore-admin-v1:2.19.1:2.19.2-SNAPSHOT -grpc-google-cloud-datastore-admin-v1:2.19.1:2.19.2-SNAPSHOT +google-cloud-datastore:2.25.1:2.25.1 +google-cloud-datastore-bom:2.25.1:2.25.1 +proto-google-cloud-datastore-v1:0.116.1:0.116.1 +datastore-v1-proto-client:2.25.1:2.25.1 +proto-google-cloud-datastore-admin-v1:2.25.1:2.25.1 +grpc-google-cloud-datastore-admin-v1:2.25.1:2.25.1