Package com.google.cloud.spanner
Class Key
java.lang.Object
com.google.cloud.spanner.Key
- All Implemented Interfaces:
Serializable
Represents a row key in a Cloud Spanner table or index. A key is a tuple of values constrained to
the scalar Cloud Spanner types: currently these are
BOOLEAN, INT64,
FLOAT64, STRING, BYTES and TIMESTAMP. Values may be null where the table
definition permits it.
Key is used to define the row, or endpoints of a range of rows, to retrieve in read
operations or to delete in a mutation.
Key instances are immutable.
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleangetParts()Returns the parts in this key.inthashCode()static Key.BuilderReturns a new builder for constructing a key.static KeyConstruct a key with parts specified byvalues.intsize()Returns the number of parts in this key, includingnullvalues.Returns a builder initialized with the value of this key.toString()
-
Method Details
-
of
Construct a key with parts specified byvalues. Each object invaluesmust be eithernullor one of the following supported types:Booleanfor theBOOLCloud Spanner typeInteger,Longfor theINT64Cloud Spanner typeFloat,Doublefor theFLOAT64Cloud Spanner typeBigDecimalfor theNUMERICCloud Spanner typeStringfor theSTRINGCloud Spanner typeStringfor theJSONCloud Spanner typeByteArrayfor theBYTESCloud Spanner typeTimestampfor theTIMESTAMPCloud Spanner typeDatefor theDATECloud Spanner typeUUIDfor theUUIDCloud Spanner type
- Throws:
IllegalArgumentException- if any member ofvaluesis not a supported type
-
newBuilder
Returns a new builder for constructing a key. -
size
public int size()Returns the number of parts in this key, includingnullvalues. -
getParts
Returns the parts in this key. Each part is represented by the corresponding Cloud Spanner type's canonical Java type, as listed below. Note that other types supported byof(Object...)are converted to one of the canonical types.BOOLis represented byBooleanINT64is represented byLongFLOAT64is represented byDoubleNUMERICis represented byBigDecimalSTRINGis represented byStringJSONis represented byStringBYTESis represented byByteArrayTIMESTAMPis represented byTimestampDATEis represented byDate
- Returns:
- an unmodifiable list containing the key parts
-
toBuilder
Returns a builder initialized with the value of this key. -
toString
-
equals
-
hashCode
public int hashCode()
-