From 1c683858aaeab236b957152a32b4f1e3ff53bec6 Mon Sep 17 00:00:00 2001 From: Sneha Shah Date: Fri, 5 Oct 2018 15:24:06 -0700 Subject: [PATCH 1/2] Launch Cloud Spanner DML & PartitionedDML support Revert "Revert "Revert "Revert "Cloud Spanner DML & PartitionedDML support (#3703)" (#3741)" (#3755)" (#3761)" This reverts commit 68f38e1e376eb90579ed922ef6a290f74bae2404. --- .../google/cloud/spanner/DatabaseClient.java | 49 ++- .../cloud/spanner/DatabaseClientImpl.java | 14 +- .../com/google/cloud/spanner/ResultSet.java | 13 +- .../com/google/cloud/spanner/SessionPool.java | 12 + .../com/google/cloud/spanner/SpannerImpl.java | 184 ++++++++--- .../cloud/spanner/TransactionContext.java | 7 + .../cloud/spanner/spi/v1/GrpcSpannerRpc.java | 12 + .../cloud/spanner/spi/v1/SpannerRpc.java | 3 + .../cloud/spanner/GrpcResultSetTest.java | 24 +- .../google/cloud/spanner/it/ITDMLTest.java | 298 ++++++++++++++++++ 10 files changed, 552 insertions(+), 64 deletions(-) create mode 100644 google-cloud-clients/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDMLTest.java diff --git a/google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClient.java b/google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClient.java index 3120e651feb2..969af0275fcf 100644 --- a/google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClient.java +++ b/google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClient.java @@ -135,7 +135,7 @@ public interface DatabaseClient { ReadOnlyTransaction singleUseReadOnlyTransaction(); /** -   * Returns a read-only transaction context in which a single read or query can be performed at the + * Returns a read-only transaction context in which a single read or query can be performed at * given timestamp bound. This method differs from {@link #singleUse(TimestampBound)} in that the * read timestamp used may be inspected after the read has returned data or finished successfully. * @@ -269,4 +269,51 @@ public interface DatabaseClient { * */ TransactionManager transactionManager(); + + /** + * Returns the lower bound of rows modified by this DML statement. + * + *

The method will block until the update is complete. Running a DML statement with this method + * does not offer exactly once semantics, and therfore the DML statement should be idempotent. The + * DML statement must be fully-partitionable. Specifically, the statement must be expressible as + * the union of many statements which each access only a single row of the table. This is a + * Partitioned DML transaction in which a single Partitioned DML statement is executed. + * Partitioned DML partitions the key space and runs the DML statement over each partition in + * parallel using separate, internal transactions that commit independently. Partitioned DML + * transactions do not need to be committed. + * + *

Partitioned DML updates are used to execute a single DML statement with a different + * execution strategy that provides different, and often better, scalability properties for large, + * table-wide operations than DML in a {@link #readWriteTransaction()} transaction. Smaller scoped + * statements, such as an OLTP workload, should prefer using {@link + * TransactionContext#executeUpdate(Statement)} with {@link #readWriteTransaction()}. + * + *