diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 13e732dd2..fce568dc2 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -186,40 +186,6 @@ branchProtectionRules: - 'Kokoro - Test: Java GraalVM Native Image' - 'Kokoro - Test: Java 17 GraalVM Native Image' - javadoc - - pattern: grpc-experimental - isAdminEnforced: true - requiredApprovingReviewCount: 1 - requiresCodeOwnerReviews: true - requiresStrictStatusChecks: false - requiredStatusCheckContexts: - - dependencies (17) - - lint - - clirr - - units (8) - - 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: grpc-experimental - isAdminEnforced: true - requiredApprovingReviewCount: 1 - requiresCodeOwnerReviews: true - requiresStrictStatusChecks: false - requiredStatusCheckContexts: - - dependencies (17) - - lint - - clirr - - units (8) - - units (11) - - 'Kokoro - Test: Integration' - - cla/google - - OwlBot Post Processor - - 'Kokoro - Test: Java GraalVM Native Image' - - 'Kokoro - Test: Java 17 GraalVM Native Image' - - javadoc permissionRules: - team: yoshi-admins permission: admin diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml index 4caa5567a..46b80edc1 100644 --- a/.github/workflows/hermetic_library_generation.yaml +++ b/.github/workflows/hermetic_library_generation.yaml @@ -37,7 +37,7 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} - - uses: googleapis/sdk-platform-java/.github/scripts@v2.46.0 + - uses: googleapis/sdk-platform-java/.github/scripts@v2.49.0 if: env.SHOULD_RUN == 'true' with: base_ref: ${{ github.base_ref }} diff --git a/.github/workflows/unmanaged_dependency_check.yaml b/.github/workflows/unmanaged_dependency_check.yaml index aabf59292..f1796d286 100644 --- a/.github/workflows/unmanaged_dependency_check.yaml +++ b/.github/workflows/unmanaged_dependency_check.yaml @@ -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.36.1 + uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.39.0 with: bom-path: google-cloud-datastore-bom/pom.xml diff --git a/.kokoro/presubmit/graalvm-native-17.cfg b/.kokoro/presubmit/graalvm-native-17.cfg index b39cf017d..e8c154f48 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.36.1" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.39.0" } env_vars: { diff --git a/.kokoro/presubmit/graalvm-native.cfg b/.kokoro/presubmit/graalvm-native.cfg index c59887969..046dc8df4 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.36.1" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.39.0" } env_vars: { diff --git a/.readme-partials.yaml b/.readme-partials.yaml index c999cf6b5..965a0bdd0 100644 --- a/.readme-partials.yaml +++ b/.readme-partials.yaml @@ -185,6 +185,103 @@ custom_content: | To customize the number of channels your client uses, you can update the channel provider in the 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. + 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(); + ``` + + 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. + + #### Download Instructions + Instructions: + 1. Clone the grpc-experimental branch from GitHub: + ```python + git clone -b grpc-experimental https://github.com/googleapis/java-datastore.git + ``` + 2. Run the following commands to build the library: + ```python + # Go to the directory the code was downloaded to + cd java-datastore/ + + # Build the library + mvn clean install -DskipTests=true + ``` + 3. Add the following dependency to your project: + ```xml + + com.google.cloud + google-cloud-datastore + 2.20.0-grpc-experimental-1-SNAPSHOT + + ``` + + #### 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. + + ##### Channel Pooling + To customize the number of channels your client uses, you can update the channel provider in the 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. + Example: ```java InstantiatingGrpcChannelProvider channelProvider = diff --git a/CHANGELOG.md b/CHANGELOG.md index 56a38be55..36d4e90cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,57 @@ # Changelog +## [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) @@ -99,42 +151,6 @@ * **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.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)) diff --git a/README.md b/README.md index 265f21131..8620a5533 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.47.0 + 26.50.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.22.0 + 2.24.1 ``` @@ -50,7 +49,7 @@ 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.48.0') +implementation platform('com.google.cloud:libraries-bom:26.50.0') implementation 'com.google.cloud:google-cloud-datastore' ``` @@ -65,7 +64,6 @@ If you are using SBT, add this to your dependencies: ```Scala libraryDependencies += "com.google.cloud" % "google-cloud-datastore" % "2.22.0" ``` - ## Authentication @@ -285,6 +283,103 @@ There are new gRPC specific features available to use in this update. To customize the number of channels your client uses, you can update the channel provider in the 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. +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(); +``` + +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. + +#### Download Instructions +Instructions: +1. Clone the grpc-experimental branch from GitHub: +```python +git clone -b grpc-experimental https://github.com/googleapis/java-datastore.git +``` +2. Run the following commands to build the library: +```python +# Go to the directory the code was downloaded to +cd java-datastore/ + +# Build the library +mvn clean install -DskipTests=true +``` +3. Add the following dependency to your project: +```xml + + com.google.cloud + google-cloud-datastore + 2.20.0-grpc-experimental-1-SNAPSHOT + +``` + +#### 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. + +##### Channel Pooling +To customize the number of channels your client uses, you can update the channel provider in the 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. + Example: ```java InstantiatingGrpcChannelProvider channelProvider = @@ -481,7 +576,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.22.0 [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 diff --git a/generation_config.yaml b/generation_config.yaml index 44eb5d8aa..273697bc6 100644 --- a/generation_config.yaml +++ b/generation_config.yaml @@ -1,6 +1,6 @@ -gapic_generator_version: 2.47.0 -googleapis_commitish: 8692273ae7e0ef95d264e1bb8bcb900fa950674f -libraries_bom_version: 26.48.0 +gapic_generator_version: 2.49.0 +googleapis_commitish: 5257378f52352e70b8995713f0d4484bdab7e71d +libraries_bom_version: 26.50.0 libraries: - api_shortname: datastore name_pretty: Cloud Datastore diff --git a/google-cloud-datastore-bom/pom.xml b/google-cloud-datastore-bom/pom.xml index 3977edc78..6d426af87 100644 --- a/google-cloud-datastore-bom/pom.xml +++ b/google-cloud-datastore-bom/pom.xml @@ -8,7 +8,7 @@ com.google.cloud sdk-platform-java-config - 3.36.1 + 3.39.0 Google Cloud datastore BOM 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 c9a01673d..bb162af33 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 @@ -55,9 +55,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); @@ -69,6 +73,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); @@ -76,10 +84,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 791446de5..0e769a109 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 @@ -53,9 +53,16 @@ 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; } + /** * Invokes the callback's {@link Datastore.TransactionCallable#run} method with a {@link * DatastoreReaderWriter} that is associated with a new transaction. The transaction will be 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 a71ebb16f..e89fc9c21 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 @@ -198,7 +198,6 @@ public boolean isClosed() { } static class ReadWriteTransactionCallable implements Callable { - private final Datastore datastore; private final TransactionCallable callable; private volatile TransactionOptions options; diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreClient.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreClient.java index ad988b32d..e88ad91b6 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreClient.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreClient.java @@ -1,5 +1,5 @@ /* - * 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. @@ -73,19 +73,151 @@ *

Note: close() needs to be called on the DatastoreClient object to clean up resources such as * threads. In the example above, try-with-resources is used, which automatically calls close(). * - *

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. A "request object" method. This type of method only takes one parameter, a request object, - * which must be constructed before the call. Not every API method will have a request object - * method. - *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API - * callable object, which can be used to initiate calls to the service. - *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Methods
MethodDescriptionMethod Variants

Lookup

Looks up entities by key.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • lookup(LookupRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • lookup(String projectId, ReadOptions readOptions, List<Key> keys) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • lookupCallable() + *

+ *

RunQuery

Queries for entities.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • runQuery(RunQueryRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • runQueryCallable() + *

+ *

RunAggregationQuery

Runs an aggregation query.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • runAggregationQuery(RunAggregationQueryRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • runAggregationQueryCallable() + *

+ *

BeginTransaction

Begins a new transaction.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • beginTransaction(BeginTransactionRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • beginTransaction(String projectId) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • beginTransactionCallable() + *

+ *

Commit

Commits a transaction, optionally creating, deleting or modifying some entities.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • commit(CommitRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • commit(String projectId, CommitRequest.Mode mode, List<Mutation> mutations) + *

  • commit(String projectId, CommitRequest.Mode mode, ByteString transaction, List<Mutation> mutations) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • commitCallable() + *

+ *

Rollback

Rolls back a transaction.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • rollback(RollbackRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • rollback(String projectId, ByteString transaction) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • rollbackCallable() + *

+ *

AllocateIds

Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • allocateIds(AllocateIdsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • allocateIds(String projectId, List<Key> keys) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • allocateIdsCallable() + *

+ *

ReserveIds

Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • reserveIds(ReserveIdsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • reserveIds(String projectId, List<Key> keys) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • reserveIdsCallable() + *

+ *
* *

See the individual methods for example code. * @@ -241,6 +373,7 @@ public final LookupResponse lookup(String projectId, ReadOptions readOptions, Li * .setDatabaseId("databaseId1688905718") * .setReadOptions(ReadOptions.newBuilder().build()) * .addAllKeys(new ArrayList()) + * .setPropertyMask(PropertyMask.newBuilder().build()) * .build(); * LookupResponse response = datastoreClient.lookup(request); * } @@ -272,6 +405,7 @@ public final LookupResponse lookup(LookupRequest request) { * .setDatabaseId("databaseId1688905718") * .setReadOptions(ReadOptions.newBuilder().build()) * .addAllKeys(new ArrayList()) + * .setPropertyMask(PropertyMask.newBuilder().build()) * .build(); * ApiFuture future = datastoreClient.lookupCallable().futureCall(request); * // Do something. @@ -302,6 +436,8 @@ public final UnaryCallable lookupCallable() { * .setDatabaseId("databaseId1688905718") * .setPartitionId(PartitionId.newBuilder().build()) * .setReadOptions(ReadOptions.newBuilder().build()) + * .setPropertyMask(PropertyMask.newBuilder().build()) + * .setExplainOptions(ExplainOptions.newBuilder().build()) * .build(); * RunQueryResponse response = datastoreClient.runQuery(request); * } @@ -333,6 +469,8 @@ public final RunQueryResponse runQuery(RunQueryRequest request) { * .setDatabaseId("databaseId1688905718") * .setPartitionId(PartitionId.newBuilder().build()) * .setReadOptions(ReadOptions.newBuilder().build()) + * .setPropertyMask(PropertyMask.newBuilder().build()) + * .setExplainOptions(ExplainOptions.newBuilder().build()) * .build(); * ApiFuture future = datastoreClient.runQueryCallable().futureCall(request); * // Do something. @@ -363,6 +501,7 @@ public final UnaryCallable runQueryCallable() * .setDatabaseId("databaseId1688905718") * .setPartitionId(PartitionId.newBuilder().build()) * .setReadOptions(ReadOptions.newBuilder().build()) + * .setExplainOptions(ExplainOptions.newBuilder().build()) * .build(); * RunAggregationQueryResponse response = datastoreClient.runAggregationQuery(request); * } @@ -394,6 +533,7 @@ public final RunAggregationQueryResponse runAggregationQuery(RunAggregationQuery * .setDatabaseId("databaseId1688905718") * .setPartitionId(PartitionId.newBuilder().build()) * .setReadOptions(ReadOptions.newBuilder().build()) + * .setExplainOptions(ExplainOptions.newBuilder().build()) * .build(); * ApiFuture future = * datastoreClient.runAggregationQueryCallable().futureCall(request); diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java index 22feacdce..a92b88450 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java @@ -1,5 +1,5 @@ /* - * 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. @@ -63,7 +63,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 lookup 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 lookup: * *

{@code
  * // This snippet has been automatically generated and should be regarded as a code template only.
@@ -79,10 +81,21 @@
  *             .lookupSettings()
  *             .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());
  * DatastoreSettings datastoreSettings = datastoreSettingsBuilder.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. */ @Generated("by gapic-generator-java") public class DatastoreSettings extends ClientSettings { @@ -169,7 +182,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() { return DatastoreStubSettings.defaultTransportChannelProvider(); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { return DatastoreStubSettings.defaultApiClientHeaderProviderBuilder(); } @@ -180,7 +192,6 @@ public static Builder newBuilder() { } /** Returns a new REST builder for this class. */ - @BetaApi public static Builder newHttpJsonBuilder() { return Builder.createHttpJsonDefault(); } @@ -222,7 +233,6 @@ private static Builder createDefault() { return new Builder(DatastoreStubSettings.newBuilder()); } - @BetaApi private static Builder createHttpJsonDefault() { return new Builder(DatastoreStubSettings.newHttpJsonBuilder()); } diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java index 2227971ca..6513a68de 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java @@ -1,5 +1,5 @@ /* - * 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/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java index 3b2b170bd..b3b802986 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java @@ -1,5 +1,5 @@ /* - * 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/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java index bfc622726..53158ec52 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java @@ -1,5 +1,5 @@ /* - * 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. @@ -18,6 +18,7 @@ import com.google.api.core.ApiFunction; 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; @@ -74,7 +75,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 lookup 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 lookup: * *

{@code
  * // This snippet has been automatically generated and should be regarded as a code template only.
@@ -90,10 +93,21 @@
  *             .lookupSettings()
  *             .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());
  * DatastoreStubSettings datastoreSettings = datastoreSettingsBuilder.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. */ @Generated("by gapic-generator-java") public class DatastoreStubSettings extends StubSettings { @@ -173,12 +187,19 @@ public DatastoreStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } + /** Returns the default service name. */ + @Override + public String getServiceName() { + return "datastore"; + } + /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "datastore.googleapis.com:443"; } @@ -217,7 +238,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DatastoreStubSettings.class)) @@ -225,7 +245,6 @@ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProvider GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DatastoreStubSettings.class)) @@ -388,7 +407,6 @@ private static Builder createDefault() { builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); builder.setSwitchToMtlsEndpointAllowed(true); @@ -401,7 +419,6 @@ private static Builder createHttpJsonDefault() { builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); builder.setSwitchToMtlsEndpointAllowed(true); diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java index 4e640ead2..0945ac1bc 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java @@ -1,5 +1,5 @@ /* - * 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/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java index f68e8996b..fd75892ae 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java @@ -1,5 +1,5 @@ /* - * 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/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java index 8639433a7..323a00282 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java @@ -1,5 +1,5 @@ /* - * 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. @@ -16,7 +16,6 @@ package com.google.cloud.datastore.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.httpjson.HttpJsonCallSettings; import com.google.api.gax.httpjson.HttpJsonCallableFactory; import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; @@ -41,7 +40,6 @@ *

This class is for advanced usage. */ @Generated("by gapic-generator-java") -@BetaApi public class HttpJsonDatastoreCallableFactory implements HttpJsonStubCallableFactory { @@ -73,8 +71,6 @@ public UnaryCallable createBatchingCa httpJsonCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java index c0f1c7766..2d6634828 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java @@ -1,5 +1,5 @@ /* - * 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. @@ -16,7 +16,6 @@ package com.google.cloud.datastore.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; @@ -62,7 +61,6 @@ *

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") -@BetaApi public class HttpJsonDatastoreStub extends DatastoreStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); 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 e4ca7ae5f..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 @@ -395,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/main/resources/META-INF/native-image/com.google.cloud.datastore.v1/reflect-config.json b/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.v1/reflect-config.json index b0a64366e..475f7690c 100644 --- a/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.v1/reflect-config.json +++ b/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.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, @@ -413,6 +431,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.v1.AggregationQuery", "queryAllDeclaredConstructors": true, @@ -746,6 +782,60 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.datastore.v1.ExecutionStats", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExecutionStats$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainMetrics", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainMetrics$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.datastore.v1.Filter", "queryAllDeclaredConstructors": true, @@ -764,6 +854,33 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.datastore.v1.FindNearest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.FindNearest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.FindNearest$DistanceMeasure", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.datastore.v1.GqlQuery", "queryAllDeclaredConstructors": true, @@ -908,6 +1025,15 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.datastore.v1.Mutation$ConflictResolutionStrategy", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.datastore.v1.MutationResult", "queryAllDeclaredConstructors": true, @@ -944,6 +1070,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.datastore.v1.PlanSummary", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PlanSummary$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.datastore.v1.Projection", "queryAllDeclaredConstructors": true, @@ -989,6 +1133,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.datastore.v1.PropertyMask", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyMask$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.datastore.v1.PropertyOrder", "queryAllDeclaredConstructors": true, @@ -1034,6 +1196,33 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.datastore.v1.PropertyTransform", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyTransform$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyTransform$ServerValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.datastore.v1.Query", "queryAllDeclaredConstructors": true, @@ -1412,6 +1601,15 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.protobuf.DescriptorProtos$Edition", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto", "queryAllDeclaredConstructors": true, @@ -1547,6 +1745,114 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$EnumType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$FieldPresence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$JsonFormat", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$MessageEncoding", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$RepeatedFieldEncoding", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$Utf8Validation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$FeatureSetEditionDefault", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$FeatureSetEditionDefault$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto", "queryAllDeclaredConstructors": true, @@ -1610,6 +1916,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$EditionDefault", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$EditionDefault$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.protobuf.DescriptorProtos$FieldOptions$JSType", "queryAllDeclaredConstructors": true, diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientHttpJsonTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientHttpJsonTest.java index fa3a2a4e9..541f3b603 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientHttpJsonTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientHttpJsonTest.java @@ -1,5 +1,5 @@ /* - * 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. @@ -33,11 +33,14 @@ import com.google.datastore.v1.CommitRequest; import com.google.datastore.v1.CommitResponse; import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.ExplainMetrics; +import com.google.datastore.v1.ExplainOptions; import com.google.datastore.v1.Key; import com.google.datastore.v1.LookupResponse; import com.google.datastore.v1.Mutation; import com.google.datastore.v1.MutationResult; import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.PropertyMask; import com.google.datastore.v1.Query; import com.google.datastore.v1.QueryResultBatch; import com.google.datastore.v1.ReadOptions; @@ -153,6 +156,7 @@ public void runQueryTest() throws Exception { .setBatch(QueryResultBatch.newBuilder().build()) .setQuery(Query.newBuilder().build()) .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) .build(); mockService.addResponse(expectedResponse); @@ -162,6 +166,8 @@ public void runQueryTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); RunQueryResponse actualResponse = client.runQuery(request); @@ -196,6 +202,8 @@ public void runQueryExceptionTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); client.runQuery(request); Assert.fail("No exception raised"); @@ -211,6 +219,7 @@ public void runAggregationQueryTest() throws Exception { .setBatch(AggregationResultBatch.newBuilder().build()) .setQuery(AggregationQuery.newBuilder().build()) .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) .build(); mockService.addResponse(expectedResponse); @@ -220,6 +229,7 @@ public void runAggregationQueryTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); RunAggregationQueryResponse actualResponse = client.runAggregationQuery(request); @@ -254,6 +264,7 @@ public void runAggregationQueryExceptionTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); client.runAggregationQuery(request); Assert.fail("No exception raised"); diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientTest.java index 663de9fb0..1dc96c5d1 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientTest.java @@ -1,5 +1,5 @@ /* - * 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. @@ -32,12 +32,15 @@ import com.google.datastore.v1.CommitRequest; import com.google.datastore.v1.CommitResponse; import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.ExplainMetrics; +import com.google.datastore.v1.ExplainOptions; import com.google.datastore.v1.Key; import com.google.datastore.v1.LookupRequest; import com.google.datastore.v1.LookupResponse; import com.google.datastore.v1.Mutation; import com.google.datastore.v1.MutationResult; import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.PropertyMask; import com.google.datastore.v1.Query; import com.google.datastore.v1.QueryResultBatch; import com.google.datastore.v1.ReadOptions; @@ -159,6 +162,7 @@ public void runQueryTest() throws Exception { .setBatch(QueryResultBatch.newBuilder().build()) .setQuery(Query.newBuilder().build()) .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) .build(); mockDatastore.addResponse(expectedResponse); @@ -168,6 +172,8 @@ public void runQueryTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); RunQueryResponse actualResponse = client.runQuery(request); @@ -183,6 +189,8 @@ public void runQueryTest() throws Exception { Assert.assertEquals(request.getReadOptions(), actualRequest.getReadOptions()); Assert.assertEquals(request.getQuery(), actualRequest.getQuery()); Assert.assertEquals(request.getGqlQuery(), actualRequest.getGqlQuery()); + Assert.assertEquals(request.getPropertyMask(), actualRequest.getPropertyMask()); + Assert.assertEquals(request.getExplainOptions(), actualRequest.getExplainOptions()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -201,6 +209,8 @@ public void runQueryExceptionTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); client.runQuery(request); Assert.fail("No exception raised"); @@ -216,6 +226,7 @@ public void runAggregationQueryTest() throws Exception { .setBatch(AggregationResultBatch.newBuilder().build()) .setQuery(AggregationQuery.newBuilder().build()) .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) .build(); mockDatastore.addResponse(expectedResponse); @@ -225,6 +236,7 @@ public void runAggregationQueryTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); RunAggregationQueryResponse actualResponse = client.runAggregationQuery(request); @@ -240,6 +252,7 @@ public void runAggregationQueryTest() throws Exception { Assert.assertEquals(request.getReadOptions(), actualRequest.getReadOptions()); Assert.assertEquals(request.getAggregationQuery(), actualRequest.getAggregationQuery()); Assert.assertEquals(request.getGqlQuery(), actualRequest.getGqlQuery()); + Assert.assertEquals(request.getExplainOptions(), actualRequest.getExplainOptions()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -258,6 +271,7 @@ public void runAggregationQueryExceptionTest() throws Exception { .setDatabaseId("databaseId1688905718") .setPartitionId(PartitionId.newBuilder().build()) .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) .build(); client.runAggregationQuery(request); Assert.fail("No exception raised"); diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastore.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastore.java index d2295784c..ecdbcd2e9 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastore.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastore.java @@ -1,5 +1,5 @@ /* - * 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/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastoreImpl.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastoreImpl.java index 3b3d8b937..c7e0ded1f 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastoreImpl.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastoreImpl.java @@ -1,5 +1,5 @@ /* - * 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/grpc-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreGrpc.java b/grpc-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreGrpc.java index b3dc940b7..d10d42190 100644 --- a/grpc-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreGrpc.java +++ b/grpc-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreGrpc.java @@ -1,5 +1,5 @@ /* - * 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/pom.xml b/pom.xml index e5ad86dbe..1b19ec4fb 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ com.google.cloud sdk-platform-java-config - 3.36.1 + 3.39.0 diff --git a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearest.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearest.java new file mode 100644 index 000000000..999b5b1f2 --- /dev/null +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearest.java @@ -0,0 +1,2272 @@ +/* + * 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; + +/** + * + * + *

+ * 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/Query.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java index 2c0c40f79..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 @@ -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 70533577f..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 @@ -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/QueryProto.java b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProto.java index 60c35e2e1..489e035ab 100644 --- a/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProto.java +++ b/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProto.java @@ -84,6 +84,10 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_datastore_v1_PropertyFilter_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_datastore_v1_PropertyFilter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_FindNearest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_FindNearest_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_datastore_v1_GqlQuery_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -120,7 +124,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "date_time\030\005 \001(\0132\032.google.protobuf.Timest" + "amp\022\016\n\006cursor\030\003 \001(\014\"Q\n\nResultType\022\033\n\027RES" + "ULT_TYPE_UNSPECIFIED\020\000\022\010\n\004FULL\020\001\022\016\n\nPROJ" - + "ECTION\020\002\022\014\n\010KEY_ONLY\020\003\"\362\002\n\005Query\0223\n\nproj" + + "ECTION\020\002\022\014\n\010KEY_ONLY\020\003\"\257\003\n\005Query\0223\n\nproj" + "ection\030\002 \003(\0132\037.google.datastore.v1.Proje" + "ction\0221\n\004kind\030\003 \003(\0132#.google.datastore.v" + "1.KindExpression\022+\n\006filter\030\004 \001(\0132\033.googl" @@ -129,77 +133,90 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "inct_on\030\006 \003(\0132&.google.datastore.v1.Prop" + "ertyReference\022\024\n\014start_cursor\030\007 \001(\014\022\022\n\ne" + "nd_cursor\030\010 \001(\014\022\016\n\006offset\030\n \001(\005\022*\n\005limit" - + "\030\014 \001(\0132\033.google.protobuf.Int32Value\"\344\004\n\020" - + "AggregationQuery\0222\n\014nested_query\030\001 \001(\0132\032" - + ".google.datastore.v1.QueryH\000\022L\n\014aggregat" - + "ions\030\003 \003(\01321.google.datastore.v1.Aggrega" - + "tionQuery.AggregationB\003\340A\001\032\277\003\n\013Aggregati" - + "on\022H\n\005count\030\001 \001(\01327.google.datastore.v1." - + "AggregationQuery.Aggregation.CountH\000\022D\n\003" - + "sum\030\002 \001(\01325.google.datastore.v1.Aggregat" - + "ionQuery.Aggregation.SumH\000\022D\n\003avg\030\003 \001(\0132" - + "5.google.datastore.v1.AggregationQuery.A" - + "ggregation.AvgH\000\022\022\n\005alias\030\007 \001(\tB\003\340A\001\0328\n\005" - + "Count\022/\n\005up_to\030\001 \001(\0132\033.google.protobuf.I" - + "nt64ValueB\003\340A\001\032?\n\003Sum\0228\n\010property\030\001 \001(\0132" - + "&.google.datastore.v1.PropertyReference\032" - + "?\n\003Avg\0228\n\010property\030\001 \001(\0132&.google.datast" - + "ore.v1.PropertyReferenceB\n\n\010operatorB\014\n\n" - + "query_type\"\036\n\016KindExpression\022\014\n\004name\030\001 \001" - + "(\t\"!\n\021PropertyReference\022\014\n\004name\030\002 \001(\t\"F\n" - + "\nProjection\0228\n\010property\030\001 \001(\0132&.google.d" - + "atastore.v1.PropertyReference\"\321\001\n\rProper" - + "tyOrder\0228\n\010property\030\001 \001(\0132&.google.datas" - + "tore.v1.PropertyReference\022?\n\tdirection\030\002" - + " \001(\0162,.google.datastore.v1.PropertyOrder" - + ".Direction\"E\n\tDirection\022\031\n\025DIRECTION_UNS" - + "PECIFIED\020\000\022\r\n\tASCENDING\020\001\022\016\n\nDESCENDING\020" - + "\002\"\231\001\n\006Filter\022@\n\020composite_filter\030\001 \001(\0132$" - + ".google.datastore.v1.CompositeFilterH\000\022>" - + "\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\273\001\n\027com.goo" - + "gle.datastore.v1B\nQueryProtoP\001Z;cloud.go" - + "ogle.com/go/datastore/apiv1/datastorepb;" - + "datastorepb\252\002\031Google.Cloud.Datastore.V1\312" - + "\002\031Google\\Cloud\\Datastore\\V1\352\002\034Google::Cl" - + "oud::Datastore::V1b\006proto3" + + "\030\014 \001(\0132\033.google.protobuf.Int32Value\022;\n\014f" + + "ind_nearest\030\r \001(\0132 .google.datastore.v1." + + "FindNearestB\003\340A\001\"\344\004\n\020AggregationQuery\0222\n" + + "\014nested_query\030\001 \001(\0132\032.google.datastore.v" + + "1.QueryH\000\022L\n\014aggregations\030\003 \003(\01321.google" + + ".datastore.v1.AggregationQuery.Aggregati" + + "onB\003\340A\001\032\277\003\n\013Aggregation\022H\n\005count\030\001 \001(\01327" + + ".google.datastore.v1.AggregationQuery.Ag" + + "gregation.CountH\000\022D\n\003sum\030\002 \001(\01325.google." + + "datastore.v1.AggregationQuery.Aggregatio" + + "n.SumH\000\022D\n\003avg\030\003 \001(\01325.google.datastore." + + "v1.AggregationQuery.Aggregation.AvgH\000\022\022\n" + + "\005alias\030\007 \001(\tB\003\340A\001\0328\n\005Count\022/\n\005up_to\030\001 \001(" + + "\0132\033.google.protobuf.Int64ValueB\003\340A\001\032?\n\003S" + + "um\0228\n\010property\030\001 \001(\0132&.google.datastore." + + "v1.PropertyReference\032?\n\003Avg\0228\n\010property\030" + + "\001 \001(\0132&.google.datastore.v1.PropertyRefe" + + "renceB\n\n\010operatorB\014\n\nquery_type\"\036\n\016KindE" + + "xpression\022\014\n\004name\030\001 \001(\t\"!\n\021PropertyRefer" + + "ence\022\014\n\004name\030\002 \001(\t\"F\n\nProjection\0228\n\010prop" + + "erty\030\001 \001(\0132&.google.datastore.v1.Propert" + + "yReference\"\321\001\n\rPropertyOrder\0228\n\010property" + + "\030\001 \001(\0132&.google.datastore.v1.PropertyRef" + + "erence\022?\n\tdirection\030\002 \001(\0162,.google.datas" + + "tore.v1.PropertyOrder.Direction\"E\n\tDirec" + + "tion\022\031\n\025DIRECTION_UNSPECIFIED\020\000\022\r\n\tASCEN" + + "DING\020\001\022\016\n\nDESCENDING\020\002\"\231\001\n\006Filter\022@\n\020com" + + "posite_filter\030\001 \001(\0132$.google.datastore.v" + + "1.CompositeFilterH\000\022>\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/proto/google/datastore/v1/query.proto b/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto index 5ec0eea61..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 @@ -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/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index c39bbf20b..30cba8255 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.22.0 + 2.24.1 diff --git a/samples/pom.xml b/samples/pom.xml index f8d684ea8..56fd2ae2c 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -31,7 +31,6 @@ install-without-bom snapshot snippets - native-image-sample diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 677692680..d31d40cb9 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 26.47.0 + 26.50.0 pom import 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 index f0c9cd5da..90a94014c 100644 --- a/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java +++ b/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java @@ -29,7 +29,6 @@ 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.Filter; import com.google.cloud.datastore.StructuredQuery.OrderBy; import com.google.cloud.datastore.StructuredQuery.PropertyFilter; @@ -40,11 +39,12 @@ public static void invoke() throws Exception { Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); // Build a query with multi inequal filters and optimized index order of index properties. - Query query = Query.newEntityQueryBuilder() + Query query = + Query.newEntityQueryBuilder() .setKind("employees") - .setFilter(CompositeFilter.and( - PropertyFilter.gt("salary", 100000), - PropertyFilter.gt("experience", 0))) + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("salary", 100000), PropertyFilter.gt("experience", 0))) .setOrderBy(OrderBy.asc("salary"), OrderBy.asc("experience")) .build(); 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 index 1739dbade..24fc7901c 100644 --- a/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java +++ b/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java @@ -28,7 +28,6 @@ import com.google.cloud.datastore.Entity; import com.google.cloud.datastore.Query; import com.google.cloud.datastore.QueryResults; -import com.google.cloud.datastore.StructuredQuery.Filter; import com.google.cloud.datastore.StructuredQuery.OrderBy; import com.google.cloud.datastore.StructuredQuery.PropertyFilter; @@ -40,11 +39,11 @@ public static void invoke() throws Exception { // 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(); + 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); 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 index 6fee2a806..8e3fa4c10 100644 --- a/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.java +++ b/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.java @@ -38,27 +38,29 @@ public class MultiIneqQuerySampleIT { private Key employeeKey2; private Key employeeKey3; - @Rule - public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); @Before public void setUp() { employeeKey1 = datastore.newKeyFactory().setKind("employees").newKey("employee1"); - Entity employee1 = Entity.newBuilder(employeeKey1) + 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) + 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) + Entity employee3 = + Entity.newBuilder(employeeKey3) .set("name", "Jay") .set("salary", 120000) .set("experience", 15) 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..045b16a9a 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 @@ -297,8 +297,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)); }