public final class Key implements 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.
Implements
SerializableInherited Members
Static Methods
newBuilder()
public static Key.Builder newBuilder()
Returns a new builder for constructing a key.
Returns | |
---|---|
Type | Description |
Key.Builder |
of(Object[] values)
public static Key of(Object[] values)
Construct a key with parts specified by values
. Each object in values
must be
either null
or one of the following supported types:
Boolean
for theBOOL
Cloud Spanner typeInteger
,Long
for theINT64
Cloud Spanner typeFloat
,Double
for theFLOAT64
Cloud Spanner typeBigDecimal
for theNUMERIC
Cloud Spanner typeString
for theSTRING
Cloud Spanner typeString
for theJSON
Cloud Spanner type- ByteArray for the
BYTES
Cloud Spanner type - Timestamp for the
TIMESTAMP
Cloud Spanner type - Date for the
DATE
Cloud Spanner type
Parameter | |
---|---|
Name | Description |
values |
Object[] |
Returns | |
---|---|
Type | Description |
Key |
Methods
equals(Object o)
public boolean equals(Object o)
Parameter | |
---|---|
Name | Description |
o |
Object |
Returns | |
---|---|
Type | Description |
boolean |
getParts()
public Iterable<Object> 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 by #of(Object...) are converted to one of the canonical types.
BOOL
is represented byBoolean
INT64
is represented byLong
FLOAT64
is represented byDouble
NUMERIC
is represented byBigDecimal
STRING
is represented byString
JSON
is represented byString
BYTES
is represented by ByteArrayTIMESTAMP
is represented by TimestampDATE
is represented by Date
hashCode()
public int hashCode()
Returns | |
---|---|
Type | Description |
int |
size()
public int size()
Returns the number of parts in this key, including null
values.
Returns | |
---|---|
Type | Description |
int |
toBuilder()
public Key.Builder toBuilder()
Returns a builder initialized with the value of this key.
Returns | |
---|---|
Type | Description |
Key.Builder |
toString()
public String toString()
Returns | |
---|---|
Type | Description |
String |