You can execute a sequence of write operations as a single atomic unit so long as all the rows that you are operating upon share the same shard key. By atomic unit, we mean all of the operations will execute successfully, or none of them will.
Also, the sequence is performed in isolation. This means that if you have a thread running a particularly long sequence, then another thread cannot intrude on the data in use by the sequence. The second thread will not be able to see any of the modifications made by the long-running sequence until the sequence is complete. The second thread also will not be able to modify any of the data in use by the long-running sequence.
Be aware that sequences only support write operations. You can perform puts and deletes, but you cannot retrieve data when using sequences.
When using a sequence of operations:
All of the keys in use by the sequence must share the same shard key.
Operations are placed into a list, but the operations are not necessarily executed in the order that they appear in the list. Instead, they are executed in an internally defined sequence that prevents deadlocks.
The rest of this chapter shows how to use
TableAPI.execute() to create and run a sequence of operations.