public final class Mutation extends Object implements Serializable
The types of mutation that can be created are defined by Mutation.Op. To construct a mutation,
use one of the builder methods. For example, to create a mutation that will insert a value of "x"
into "C1" and a value of "y" into "C2" of table "T", write the following code:
Mutation m = Mutation.newInsertBuilder("T")
.set("C1").to("x")
.set("C2").to("y")
.build();
Mutations are applied to a database by performing a standalone write or buffering them as part of
a transaction. TODO(user): Add links/code samples once the corresponding APIs are available.
Mutation instances are immutable.
| Modifier and Type | Class and Description |
|---|---|
static class |
Mutation.Op
Enumerates the types of mutation that can be applied.
|
static class |
Mutation.WriteBuilder
Builder for
Mutation.Op.INSERT, Mutation.Op.INSERT_OR_UPDATE, Mutation.Op.UPDATE, and Mutation.Op.REPLACE mutations. |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Value> |
asMap()
For all types except
Mutation.Op.DELETE, constructs a map from column name to value. |
static Mutation |
delete(String table,
Key key)
Returns a mutation that will delete the row with primary key
key. |
static Mutation |
delete(String table,
KeySet keySet)
Returns a mutation that will delete all rows with primary keys covered by
keySet. |
boolean |
equals(Object o) |
Iterable<String> |
getColumns()
For all types except
Mutation.Op.DELETE, returns the columns that this mutation will affect. |
KeySet |
getKeySet()
For
Mutation.Op.DELETE mutations, returns the key set that defines the rows to be deleted. |
Mutation.Op |
getOperation()
Returns the type of operation that this mutation will perform.
|
String |
getTable()
Returns the name of the table that this mutation will affect.
|
Iterable<Value> |
getValues()
For all types except
Mutation.Op.DELETE, returns the values that this mutation will write. |
int |
hashCode() |
static Mutation.WriteBuilder |
newInsertBuilder(String table)
Returns a builder that can be used to construct an
Mutation.Op.INSERT mutation against table; see the INSERT documentation for mutation semantics. |
static Mutation.WriteBuilder |
newInsertOrUpdateBuilder(String table)
Returns a builder that can be used to construct an
Mutation.Op.INSERT_OR_UPDATE mutation against
table; see the INSERT_OR_UPDATE documentation for mutation semantics. |
static Mutation.WriteBuilder |
newReplaceBuilder(String table)
Returns a builder that can be used to construct an
Mutation.Op.REPLACE mutation against table; see the REPLACE documentation for mutation semantics. |
static Mutation.WriteBuilder |
newUpdateBuilder(String table)
Returns a builder that can be used to construct an
Mutation.Op.UPDATE mutation against table; see the UPDATE documentation for mutation semantics. |
String |
toString() |
public static Mutation.WriteBuilder newInsertBuilder(String table)
Mutation.Op.INSERT mutation against table; see the INSERT documentation for mutation semantics.public static Mutation.WriteBuilder newUpdateBuilder(String table)
Mutation.Op.UPDATE mutation against table; see the UPDATE documentation for mutation semantics.public static Mutation.WriteBuilder newInsertOrUpdateBuilder(String table)
Mutation.Op.INSERT_OR_UPDATE mutation against
table; see the INSERT_OR_UPDATE documentation for mutation semantics.public static Mutation.WriteBuilder newReplaceBuilder(String table)
Mutation.Op.REPLACE mutation against table; see the REPLACE documentation for mutation semantics.public static Mutation delete(String table, Key key)
key. Exactly equivalent to
delete(table, KeySet.singleKey(key)).public static Mutation delete(String table, KeySet keySet)
keySet.public String getTable()
public Mutation.Op getOperation()
public Iterable<String> getColumns()
Mutation.Op.DELETE, returns the columns that this mutation will affect.IllegalStateException - if operation() == Op.DELETEpublic Iterable<Value> getValues()
Mutation.Op.DELETE, returns the values that this mutation will write. The
number of elements returned is always the same as the number returned by getColumns(),
and the ith value corresponds to the ith column.IllegalStateException - if operation() == Op.DELETEpublic Map<String,Value> asMap()
Mutation.Op.DELETE, constructs a map from column name to value. This is
mainly intended as a convenience for testing; direct access via getColumns() and
getValues() is more efficient.IllegalStateException - if operation() == Op.DELETE, or if any duplicate columns
are present. Detection of duplicates does not consider case.public KeySet getKeySet()
Mutation.Op.DELETE mutations, returns the key set that defines the rows to be deleted.IllegalStateException - if operation() != Op.DELETECopyright © 2019 Google LLC. All rights reserved.