-
Notifications
You must be signed in to change notification settings - Fork 113
/
DatabaseClient.java
604 lines (583 loc) · 26.7 KB
/
DatabaseClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
/*
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.spanner;
import com.google.api.gax.rpc.ServerStream;
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.Options.RpcPriority;
import com.google.cloud.spanner.Options.TransactionOption;
import com.google.cloud.spanner.Options.UpdateOption;
import com.google.spanner.v1.BatchWriteResponse;
/**
* Interface for all the APIs that are used to read/write data into a Cloud Spanner database. An
* instance of this is tied to a specific database.
*/
public interface DatabaseClient {
/**
* Returns the SQL dialect that is used by the database.
*
* @return the SQL dialect that is used by the database.
*/
default Dialect getDialect() {
throw new UnsupportedOperationException("method should be overwritten");
}
/**
* Returns the {@link DatabaseRole} used by the client connection. The database role that is used
* determines the access permissions that a connection has. This can for example be used to create
* connections that are only permitted to access certain tables.
*
* @return the {@link DatabaseRole} used by the client connection.
*/
default String getDatabaseRole() {
throw new UnsupportedOperationException("method should be overwritten");
}
/**
* Writes the given mutations atomically to the database.
*
* <p>This method uses retries and replay protection internally, which means that the mutations
* are applied exactly once on success, or not at all if an error is returned, regardless of any
* failures in the underlying network. Note that if the call is cancelled or reaches deadline, it
* is not possible to know whether the mutations were applied without performing a subsequent
* database operation, but the mutations will have been applied at most once.
*
* <p>Example of blind write.
*
* <pre>{@code
* long singerId = my_singer_id;
* Mutation mutation = Mutation.newInsertBuilder("Singer")
* .set("SingerId")
* .to(singerId)
* .set("FirstName")
* .to("Billy")
* .set("LastName")
* .to("Joel")
* .build();
* dbClient.write(Collections.singletonList(mutation));
* }</pre>
*
* @return the timestamp at which the write was committed
*/
Timestamp write(Iterable<Mutation> mutations) throws SpannerException;
/**
* Writes the given mutations atomically to the database with the given options.
*
* <p>This method uses retries and replay protection internally, which means that the mutations
* are applied exactly once on success, or not at all if an error is returned, regardless of any
* failures in the underlying network. Note that if the call is cancelled or reaches deadline, it
* is not possible to know whether the mutations were applied without performing a subsequent
* database operation, but the mutations will have been applied at most once.
*
* <p>Example of blind write.
*
* <pre>{@code
* long singerId = my_singer_id;
* Mutation mutation = Mutation.newInsertBuilder("Singer")
* .set("SingerId")
* .to(singerId)
* .set("FirstName")
* .to("Billy")
* .set("LastName")
* .to("Joel")
* .build();
* dbClient.writeWithOptions(
* Collections.singletonList(mutation),
* Options.priority(RpcPriority.HIGH));
* }</pre>
*
* Options for a transaction can include:
*
* <ul>
* <li>{@link Options#priority(com.google.cloud.spanner.Options.RpcPriority)}: The {@link
* RpcPriority} to use for the commit request of the transaction. The priority will not be
* applied to any other requests on the transaction.
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
* {@link CommitResponse}.
* </ul>
*
* @return a response with the timestamp at which the write was committed
*/
CommitResponse writeWithOptions(Iterable<Mutation> mutations, TransactionOption... options)
throws SpannerException;
/**
* Writes the given mutations atomically to the database without replay protection.
*
* <p>Since this method does not feature replay protection, it may attempt to apply {@code
* mutations} more than once; if the mutations are not idempotent, this may lead to a failure
* being reported when the mutation was applied once. For example, an insert may fail with {@link
* ErrorCode#ALREADY_EXISTS} even though the row did not exist before this method was called. For
* this reason, most users of the library will prefer to use {@link #write(Iterable)} instead.
* However, {@code writeAtLeastOnce()} requires only a single RPC, whereas {@code write()}
* requires two RPCs (one of which may be performed in advance), and so this method may be
* appropriate for latency sensitive and/or high throughput blind writing.
*
* <p>Example of unprotected blind write.
*
* <pre>{@code
* long singerId = my_singer_id;
* Mutation mutation = Mutation.newInsertBuilder("Singers")
* .set("SingerId")
* .to(singerId)
* .set("FirstName")
* .to("Billy")
* .set("LastName")
* .to("Joel")
* .build();
* dbClient.writeAtLeastOnce(Collections.singletonList(mutation));
* }</pre>
*
* @return the timestamp at which the write was committed
*/
Timestamp writeAtLeastOnce(Iterable<Mutation> mutations) throws SpannerException;
/**
* Writes the given mutations atomically to the database without replay protection.
*
* <p>Since this method does not feature replay protection, it may attempt to apply {@code
* mutations} more than once; if the mutations are not idempotent, this may lead to a failure
* being reported when the mutation was applied once. For example, an insert may fail with {@link
* ErrorCode#ALREADY_EXISTS} even though the row did not exist before this method was called. For
* this reason, most users of the library will prefer to use {@link #write(Iterable)} instead.
* However, {@code writeAtLeastOnce()} requires only a single RPC, whereas {@code write()}
* requires two RPCs (one of which may be performed in advance), and so this method may be
* appropriate for latency sensitive and/or high throughput blind writing.
*
* <p>Example of unprotected blind write.
*
* <pre>{@code
* long singerId = my_singer_id;
* Mutation mutation = Mutation.newInsertBuilder("Singers")
* .set("SingerId")
* .to(singerId)
* .set("FirstName")
* .to("Billy")
* .set("LastName")
* .to("Joel")
* .build();
* dbClient.writeAtLeastOnceWithOptions(
* Collections.singletonList(mutation),
* Options.priority(RpcPriority.LOW));
* }</pre>
*
* Options for a transaction can include:
*
* <ul>
* <li>{@link Options#priority(com.google.cloud.spanner.Options.RpcPriority)}: The {@link
* RpcPriority} to use for the commit request of the transaction. The priority will not be
* applied to any other requests on the transaction.
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
* {@link CommitResponse}.
* </ul>
*
* @return a response with the timestamp at which the write was committed
*/
CommitResponse writeAtLeastOnceWithOptions(
Iterable<Mutation> mutations, TransactionOption... options) throws SpannerException;
/**
* Applies batch of mutation groups in a collection of efficient transactions. The mutation groups
* are applied non-atomically in an unspecified order and thus, they must be independent of each
* other. Partial failure is possible, i.e., some mutation groups may have been applied
* successfully, while some may have failed. The results of individual batches are streamed into
* the response as and when the batches are applied.
*
* <p>One BatchWriteResponse can contain the results for multiple MutationGroups. Inspect the
* indexes field to determine the MutationGroups that the BatchWriteResponse is for.
*
* <p>The mutation groups may be applied more than once. This can lead to failures if the mutation
* groups are non-idempotent. For example, an insert that is replayed can return an {@link
* ErrorCode#ALREADY_EXISTS} error. For this reason, users of the library may prefer to use {@link
* #write(Iterable)} instead. However, {@code batchWriteAtLeastOnce()} method may be appropriate
* for non-atomically committing multiple mutation groups in a single RPC with low latency.
*
* <p>Example of BatchWriteAtLeastOnce
*
* <pre>{@code
* Iterable<MutationGroup> mutationGroups =
* ImmutableList.of(
* MutationGroup.of(
* Mutation.newInsertBuilder("FOO1").set("ID").to(1L).set("NAME").to("Bar1").build(),
* Mutation.newInsertBuilder("FOO2").set("ID").to(2L).set("NAME").to("Bar2").build()),
* MutationGroup.of(
* Mutation.newInsertBuilder("FOO3").set("ID").to(3L).set("NAME").to("Bar3").build(),
* Mutation.newInsertBuilder("FOO4").set("ID").to(4L).set("NAME").to("Bar4").build()),
* MutationGroup.of(
* Mutation.newInsertBuilder("FOO4").set("ID").to(4L).set("NAME").to("Bar4").build(),
* Mutation.newInsertBuilder("FOO5").set("ID").to(5L).set("NAME").to("Bar5").build()),
* MutationGroup.of(
* Mutation.newInsertBuilder("FOO6").set("ID").to(6L).set("NAME").to("Bar6").build()));
* ServerStream<BatchWriteResponse> responses =
* dbClient.batchWriteAtLeastOnce(mutationGroups, Options.tag("batch-write-tag"));
* for (BatchWriteResponse response : responses) {
* // Do something when a response is received.
* }
* }</pre>
*
* Options for a transaction can include:
*
* <ul>
* <li>{@link Options#priority(com.google.cloud.spanner.Options.RpcPriority)}: The {@link
* RpcPriority} to use for the batch write request.
* <li>{@link Options#tag(String)}: The transaction tag to use for the batch write request.
* </ul>
*/
ServerStream<BatchWriteResponse> batchWriteAtLeastOnce(
Iterable<MutationGroup> mutationGroups, TransactionOption... options) throws SpannerException;
/**
* Returns a context in which a single read can be performed using {@link TimestampBound#strong()}
* concurrency. This method will return a {@link ReadContext} that will not return the read
* timestamp that was used by Cloud Spanner. If you want to be able to access the read timestamp,
* you should use the method {@link #singleUseReadOnlyTransaction()}.
*
* <p>Example of single use.
*
* <pre>{@code
* long singerId = my_singer_id;
* String column = "FirstName";
* Struct row =
* dbClient.singleUse().readRow("Singers", Key.of(singerId), Collections.singleton(column));
* String firstName = row.getString(column);
* }</pre>
*/
ReadContext singleUse();
/**
* Returns a context in which a single read can be performed at the given timestamp bound. This
* method will return a {@link ReadContext} that will not return the read timestamp that was used
* by Cloud Spanner. If you want to be able to access the read timestamp, you should use the
* method {@link #singleUseReadOnlyTransaction()}.
*
* <p>Example of single use with timestamp bound.
*
* <pre>{@code
* long singerId = my_singer_id;
* String column = "FirstName";
* Struct row = dbClient.singleUse(TimestampBound.ofMaxStaleness(10, TimeUnit.SECONDS))
* .readRow("Singers", Key.of(singerId), Collections.singleton(column));
* String firstName = row.getString(column);
* }</pre>
*
* @param bound the timestamp bound at which to perform the read
*/
ReadContext singleUse(TimestampBound bound);
/**
* Returns a read-only transaction context in which a single read or query can be performed using
* {@link TimestampBound#strong()} concurrency. This method differs from {@link #singleUse()} in
* that the read timestamp used may be inspected after the read has returned data or finished
* successfully.
*
* <p>Example of single use read only transaction.
*
* <pre>{@code
* long singerId = my_singer_id;
* String column = "FirstName";
* ReadOnlyTransaction txn = dbClient.singleUseReadOnlyTransaction();
* Struct row = txn.readRow("Singers", Key.of(singerId), Collections.singleton(column));
* row.getString(column);
* Timestamp timestamp = txn.getReadTimestamp();
* }</pre>
*/
ReadOnlyTransaction singleUseReadOnlyTransaction();
/**
* 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.
*
* <p>Example of single use read only transaction with timestamp bound.
*
* <pre>{@code
* long singerId = my_singer_id;
* String column = "FirstName";
* ReadOnlyTransaction txn =
* dbClient.singleUseReadOnlyTransaction(TimestampBound.ofMaxStaleness(10, TimeUnit.SECONDS));
* Struct row = txn.readRow("Singers", Key.of(singerId), Collections.singleton(column));
* row.getString(column);
* Timestamp timestamp = txn.getReadTimestamp();
* }</pre>
*
* @param bound the timestamp bound at which to perform the read
*/
ReadOnlyTransaction singleUseReadOnlyTransaction(TimestampBound bound);
/**
* Returns a read-only transaction context in which a multiple reads and/or queries can be
* performed using {@link TimestampBound#strong()} concurrency. All reads/queries will use the
* same timestamp, and the timestamp can be inspected after any read/query has returned data or
* finished successfully.
*
* <p>Example of read only transaction.
*
* <pre>{@code
* long singerId = my_singer_id;
* long albumId = my_album_id;
* String singerColumn = "FirstName";
* String albumColumn = "AlbumTitle";
* String albumTitle = null;
* // ReadOnlyTransaction should be closed to prevent resource leak.
* try (ReadOnlyTransaction txn = dbClient.readOnlyTransaction()) {
* Struct singerRow =
* txn.readRow("Singers", Key.of(singerId), Collections.singleton(singerColumn));
* Struct albumRow =
* txn.readRow("Albums", Key.of(singerId, albumId), Collections.singleton(albumColumn));
* singerRow.getString(singerColumn);
* albumTitle = albumRow.getString(albumColumn);
* }
* }</pre>
*/
ReadOnlyTransaction readOnlyTransaction();
/**
* Returns a read-only transaction context in which a multiple reads and/or queries can be
* performed at the given timestamp bound. All reads/queries will use the same timestamp, and the
* timestamp can be inspected after any read/query has returned data or finished successfully.
*
* <p>Note that the bounded staleness modes, {@link TimestampBound.Mode#MIN_READ_TIMESTAMP} and
* {@link TimestampBound.Mode#MAX_STALENESS}, are not supported for multi-use read-only
* transactions.
*
* <p>Example of read only transaction with timestamp bound.
*
* <pre>{@code
* long singerId = my_singer_id;
* long albumId = my_album_id;
* String singerColumn = "FirstName";
* String albumColumn = "AlbumTitle";
* String albumTitle = null;
* // ReadOnlyTransaction should be closed to prevent resource leak.
* try (ReadOnlyTransaction txn =
* dbClient.readOnlyTransaction(TimestampBound.ofExactStaleness(10, TimeUnit.SECONDS))) {
* Struct singerRow =
* txn.readRow("Singers", Key.of(singerId), Collections.singleton(singerColumn));
* Struct albumRow =
* txn.readRow("Albums", Key.of(singerId, albumId), Collections.singleton(albumColumn));
* singerRow.getString(singerColumn);
* albumTitle = albumRow.getString(albumColumn);
* }
* }</pre>
*
* @param bound the timestamp bound at which to perform the read
*/
ReadOnlyTransaction readOnlyTransaction(TimestampBound bound);
/**
* Returns a transaction runner for executing a single logical transaction with retries. The
* returned runner can only be used once.
*
* <p>Example of a read write transaction.
*
* <pre> <code>
* long singerId = my_singer_id;
* TransactionRunner runner = dbClient.readWriteTransaction();
* runner.run(
* new TransactionCallable<Void>() {
*
* {@literal @}Override
* public Void run(TransactionContext transaction) throws Exception {
* String column = "FirstName";
* Struct row =
* transaction.readRow("Singers", Key.of(singerId), Collections.singleton(column));
* String name = row.getString(column);
* transaction.buffer(
* Mutation.newUpdateBuilder("Singers").set(column).to(name.toUpperCase()).build());
* return null;
* }
* });
* </code></pre>
*
* Options for a transaction can include:
*
* <ul>
* <li>{@link Options#priority(com.google.cloud.spanner.Options.RpcPriority)}: The {@link
* RpcPriority} to use for the commit request of the transaction. The priority will not be
* applied to any other requests on the transaction.
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
* {@link CommitResponse}.
* </ul>
*/
TransactionRunner readWriteTransaction(TransactionOption... options);
/**
* Returns a transaction manager which allows manual management of transaction lifecycle. This API
* is meant for advanced users. Most users should instead use the {@link
* #readWriteTransaction(TransactionOption...)} API instead.
*
* <p>Example of using {@link TransactionManager}.
*
* <pre>{@code
* long singerId = my_singer_id;
* try (TransactionManager manager = dbClient.transactionManager()) {
* TransactionContext transaction = manager.begin();
* while (true) {
* String column = "FirstName";
* Struct row = transaction.readRow("Singers", Key.of(singerId), Collections.singleton(column));
* String name = row.getString(column);
* transaction.buffer(
* Mutation.newUpdateBuilder("Singers").set(column).to(name.toUpperCase()).build());
* try {
* manager.commit();
* break;
* } catch (AbortedException e) {
* Thread.sleep(e.getRetryDelayInMillis());
* transaction = manager.resetForRetry();
* }
* }
* }
* }</pre>
*
* Options for a transaction can include:
*
* <ul>
* <li>{@link Options#priority(com.google.cloud.spanner.Options.RpcPriority)}: The {@link
* RpcPriority} to use for the commit request of the transaction. The priority will not be
* applied to any other requests on the transaction.
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
* {@link CommitResponse}.
* </ul>
*/
TransactionManager transactionManager(TransactionOption... options);
/**
* Returns an asynchronous transaction runner for executing a single logical transaction with
* retries. The returned runner can only be used once.
*
* <p>Example of a read write transaction.
*
* <pre>{@code
* Executor executor = Executors.newSingleThreadExecutor();
* final long singerId = my_singer_id;
* AsyncRunner runner = client.runAsync();
* ApiFuture<Long> rowCount =
* runner.runAsync(
* () -> {
* String column = "FirstName";
* Struct row =
* txn.readRow("Singers", Key.of(singerId), Collections.singleton("Name"));
* String name = row.getString("Name");
* return txn.executeUpdateAsync(
* Statement.newBuilder("UPDATE Singers SET Name=@name WHERE SingerId=@id")
* .bind("id")
* .to(singerId)
* .bind("name")
* .to(name.toUpperCase())
* .build());
* },
* executor);
* }</pre>
*
* Options for a transaction can include:
*
* <ul>
* <li>{@link Options#priority(com.google.cloud.spanner.Options.RpcPriority)}: The {@link
* RpcPriority} to use for the commit request of the transaction. The priority will not be
* applied to any other requests on the transaction.
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
* {@link CommitResponse}.
* </ul>
*/
AsyncRunner runAsync(TransactionOption... options);
/**
* Returns an asynchronous transaction manager which allows manual management of transaction
* lifecycle. This API is meant for advanced users. Most users should instead use the {@link
* #runAsync(TransactionOption...)} API instead.
*
* <p>Example of using {@link AsyncTransactionManager}.
*
* <pre>{@code
* long singerId = 1L;
* try (AsyncTransactionManager manager = client.transactionManagerAsync()) {
* TransactionContextFuture transactionFuture = manager.beginAsync();
* while (true) {
* String column = "FirstName";
* CommitTimestampFuture commitTimestamp =
* transactionFuture
* .then(
* (transaction, __) ->
* transaction.readRowAsync(
* "Singers", Key.of(singerId), Collections.singleton(column)))
* .then(
* (transaction, row) -> {
* String name = row.getString(column);
* return transaction.bufferAsync(
* Mutation.newUpdateBuilder("Singers")
* .set(column)
* .to(name.toUpperCase())
* .build());
* })
* .commitAsync();
* try {
* commitTimestamp.get();
* break;
* } catch (AbortedException e) {
* Thread.sleep(e.getRetryDelayInMillis());
* transactionFuture = manager.resetForRetryAsync();
* }
* }
* }
* }</pre>
*
* Options for a transaction can include:
*
* <p>Options for a transaction can include:
*
* <ul>
* <li>{@link Options#priority(com.google.cloud.spanner.Options.RpcPriority)}: The {@link
* RpcPriority} to use for the commit request of the transaction. The priority will not be
* applied to any other requests on the transaction.
* <li>{@link Options#commitStats()}: Request that the server includes commit statistics in the
* {@link CommitResponse}.
* </ul>
*/
AsyncTransactionManager transactionManagerAsync(TransactionOption... options);
/**
* Returns the lower bound of rows modified by this DML statement.
*
* <p>The method will block until the update is complete. Running a DML statement with this method
* does not offer exactly once semantics, and therefore 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.
*
* <p>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(TransactionOption...)}
* transaction. Smaller scoped statements, such as an OLTP workload, should prefer using {@link
* TransactionContext#executeUpdate(Statement,UpdateOption...)} with {@link
* #readWriteTransaction(TransactionOption...)}.
*
* <p>That said, Partitioned DML is not a drop-in replacement for standard DML used in {@link
* #readWriteTransaction(TransactionOption...)}.
*
* <ul>
* <li>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.
* <li>The statement is not applied atomically to all rows of the table. Rather, the statement
* is applied atomically to partitions of the table, in independent internal transactions.
* Secondary index rows are updated atomically with the base table rows.
* <li>Partitioned DML does not guarantee exactly-once execution semantics against a partition.
* The statement will be applied at least once to each partition. It is strongly recommended
* that the DML statement should be idempotent to avoid unexpected results. For instance, it
* is potentially dangerous to run a statement such as `UPDATE table SET column = column +
* 1` as it could be run multiple times against some rows.
* <li>The partitions are committed automatically - there is no support for Commit or Rollback.
* If the call returns an error, or if the client issuing the DML statement dies, it is
* possible that some rows had the statement executed on them successfully. It is also
* possible that statement was never executed against other rows.
* <li>If any error is encountered during the execution of the partitioned DML operation (for
* instance, a UNIQUE INDEX violation, division by zero, or a value that cannot be stored
* due to schema constraints), then the operation is stopped at that point and an error is
* returned. It is possible that at this point, some partitions have been committed (or even
* committed multiple times), and other partitions have not been run at all.
* </ul>
*
* <p>Given the above, Partitioned DML is good fit for large, database-wide, operations that are
* idempotent, such as deleting old rows from a very large table.
*/
long executePartitionedUpdate(Statement stmt, UpdateOption... options);
}