Send feedback
Class Mutation (6.74.1)
Stay organized with collections
Save and categorize content based on your preferences.
Version 6.74.1 keyboard_arrow_down
public final class Mutation implements Serializable
Represents an individual table modification to be applied to Cloud Spanner.
The types of mutation that can be created are defined by 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.
Static Methods
delete(String table, Key key)
public static Mutation delete ( String table , Key key )
Returns a mutation that will delete the row with primary key key
. Exactly equivalent to
delete(table, KeySet.singleKey(key))
.
Parameters
Name
Description
table
String
key
Key
delete(String table, KeySet keySet)
public static Mutation delete ( String table , KeySet keySet )
Returns a mutation that will delete all rows with primary keys covered by keySet
.
newInsertBuilder(String table)
public static Mutation . WriteBuilder newInsertBuilder ( String table )
Returns a builder that can be used to construct an Op#INSERT mutation against
table
; see the INSERT
documentation for mutation semantics.
Parameter
Name
Description
table
String
newInsertOrUpdateBuilder(String table)
public static Mutation . WriteBuilder newInsertOrUpdateBuilder ( String table )
Returns a builder that can be used to construct an Op#INSERT_OR_UPDATE mutation against
table
; see the INSERT_OR_UPDATE
documentation for mutation semantics.
Parameter
Name
Description
table
String
newReplaceBuilder(String table)
public static Mutation . WriteBuilder newReplaceBuilder ( String table )
Returns a builder that can be used to construct an Op#REPLACE mutation against
table
; see the REPLACE
documentation for mutation semantics.
Parameter
Name
Description
table
String
newUpdateBuilder(String table)
public static Mutation . WriteBuilder newUpdateBuilder ( String table )
Returns a builder that can be used to construct an Op#UPDATE mutation against
table
; see the UPDATE
documentation for mutation semantics.
Parameter
Name
Description
table
String
Methods
asMap()
public Map<String , Value> asMap ()
For all types except 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.
equals(Object o)
public boolean equals ( Object o )
Parameter
Name
Description
o
Object
Overrides
getColumns()
public Iterable<String> getColumns ()
For all types except Op#DELETE , returns the columns that this mutation will affect.
getKeySet()
public KeySet getKeySet ()
For Op#DELETE mutations, returns the key set that defines the rows to be deleted.
Returns
Type
Description
KeySet
getOperation()
public Mutation . Op getOperation ()
Returns the type of operation that this mutation will perform.
getTable()
Returns the name of the table that this mutation will affect.
Returns
Type
Description
String
getValues()
public Iterable<Value> getValues ()
For all types except 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 i
th value corresponds to the i
th column.
hashCode()
Returns
Type
Description
int
Overrides
toString()
Returns
Type
Description
String
Overrides
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-04 UTC.
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-10-04 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-04 UTC."]]