# Cloud Spanner V1 Client - Class Tablet (2.9.0)

2.9.0 (latest) 2.8.1 2.7.0 2.6.1 2.5.1 2.4.1 2.3.0 2.2.0 2.1.0 2.0.1-RC1 1.106.0 1.105.1 1.104.1 1.103.0 1.102.0 1.101.0 1.100.0 1.98.0 1.97.0 1.96.0 1.95.0 1.94.0 1.93.1 1.92.1 1.91.0 1.90.0 1.89.0 1.88.0 1.87.0 1.86.0 1.85.0 1.84.0 1.83.0 1.82.0 1.81.0 1.80.0 1.79.0 1.78.0 1.77.0 1.76.1 1.68.0 1.67.0 1.66.0 1.65.0 1.64.0 1.63.2 1.62.1 1.61.0 1.60.0 1.59.0 1.58.4 1.57.0 1.56.0 1.55.0 1.54.2 Reference documentation and code samples for the Cloud Spanner V1 Client class Tablet.

A `Tablet` represents a single replica of a `Group`. A tablet is served by a
single server at a time, and can move between servers due to server death or
simply load balancing.

Generated from protobuf message `google.spanner.v1.Tablet`

## Namespace

Google \\ Cloud \\ Spanner \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ tablet_uid` | `int|string` The UID of the tablet, unique within the database. Matches the `tablet_uids` and `leader_tablet_uid` fields in `Group`. |
| `↳ server_address` | `string` The address of the server that is serving this tablet -- either an IP address or DNS hostname and a port number. |
| `↳ location` | `string` Where this tablet is located. This is the name of a Google Cloud region, such as "us-central1". |
| `↳ role` | `int` The role of the tablet. |
| `↳ incarnation` | `string` `incarnation` indicates the freshness of the tablet information contained in this proto. Incarnations can be compared lexicographically; if incarnation A is greater than incarnation B, then the `Tablet` corresponding to A is newer than the `Tablet` corresponding to B, and should be used preferentially. |
| `↳ distance` | `int` Distances help the client pick the closest tablet out of the list of tablets for a given request. Tablets with lower distances should generally be preferred. Tablets with the same distance are approximately equally close; the client can choose arbitrarily. Distances do not correspond precisely to expected latency, geographical distance, or anything else. Distances should be compared only between tablets of the same group; they are not meaningful between different groups. A value of zero indicates that the tablet may be in the same zone as the client, and have minimum network latency. A value less than or equal to five indicates that the tablet is thought to be in the same region as the client, and may have a few milliseconds of network latency. Values greater than five are most likely in a different region, with non-trivial network latency. Clients should use the following algorithm: \* \* If the request is using a directed read, eliminate any tablets that do not match the directed read's target zone and/or replica type. \* \* (Read-write transactions only) Choose leader tablet if it has an distance \<=5. \* \* Group and sort tablets by distance. Choose a random tablet with the lowest distance. If the request is not a directed read, only consider replicas with distances \<=5. \* \* Send the request to the fallback endpoint. The tablet picked by this algorithm may be skipped, either because it is marked as `skip` by the server or because the corresponding server is unreachable, flow controlled, etc. Skipped tablets should be added to the `skipped_tablet_uid` field in `RoutingHint`; the algorithm above should then be re-run without including the skipped tablet(s) to pick the next best tablet. |
| `↳ skip` | `bool` If true, the tablet should not be chosen by the client. Typically, this signals that the tablet is unhealthy in some way. Tablets with `skip` set to true should be reported back to the server in `RoutingHint.skipped_tablet_uid`; this cues the server to send updated information for this tablet should it become usable again. |

### getTabletUid

The UID of the tablet, unique within the database. Matches the
`tablet_uids` and `leader_tablet_uid` fields in `Group`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int|string` |   |

### setTabletUid

The UID of the tablet, unique within the database. Matches the
`tablet_uids` and `leader_tablet_uid` fields in `Group`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int|string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getServerAddress

The address of the server that is serving this tablet -- either an IP
address or DNS hostname and a port number.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setServerAddress

The address of the server that is serving this tablet -- either an IP
address or DNS hostname and a port number.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getLocation

Where this tablet is located. This is the name of a Google Cloud region,
such as "us-central1".

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setLocation

Where this tablet is located. This is the name of a Google Cloud region,
such as "us-central1".

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRole

The role of the tablet.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [Role](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/V1.Tablet.Role). |

### setRole

The role of the tablet.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [Role](https://docs.cloud.google.com/php/docs/reference/cloud-spanner/latest/V1.Tablet.Role). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getIncarnation

`incarnation` indicates the freshness of the tablet information contained
in this proto. Incarnations can be compared lexicographically; if
incarnation A is greater than incarnation B, then the `Tablet`
corresponding to A is newer than the `Tablet` corresponding to B, and
should be used preferentially.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setIncarnation

`incarnation` indicates the freshness of the tablet information contained
in this proto. Incarnations can be compared lexicographically; if
incarnation A is greater than incarnation B, then the `Tablet`
corresponding to A is newer than the `Tablet` corresponding to B, and
should be used preferentially.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDistance

Distances help the client pick the closest tablet out of the list of
tablets for a given request. Tablets with lower distances should generally
be preferred. Tablets with the same distance are approximately equally
close; the client can choose arbitrarily.

Distances do not correspond precisely to expected latency, geographical
distance, or anything else. Distances should be compared only between
tablets of the same group; they are not meaningful between different
groups.
A value of zero indicates that the tablet may be in the same zone as
the client, and have minimum network latency. A value less than or equal to
five indicates that the tablet is thought to be in the same region as the
client, and may have a few milliseconds of network latency. Values greater
than five are most likely in a different region, with non-trivial network
latency.
Clients should use the following algorithm:

- If the request is using a directed read, eliminate any tablets that do not match the directed read's target zone and/or replica type.
- (Read-write transactions only) Choose leader tablet if it has an distance \<=5.
- Group and sort tablets by distance. Choose a random tablet with the lowest distance. If the request is not a directed read, only consider replicas with distances \<=5.
- Send the request to the fallback endpoint. The tablet picked by this algorithm may be skipped, either because it is marked as `skip` by the server or because the corresponding server is unreachable, flow controlled, etc. Skipped tablets should be added to the `skipped_tablet_uid` field in `RoutingHint`; the algorithm above should then be re-run without including the skipped tablet(s) to pick the next best tablet.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### setDistance

Distances help the client pick the closest tablet out of the list of
tablets for a given request. Tablets with lower distances should generally
be preferred. Tablets with the same distance are approximately equally
close; the client can choose arbitrarily.

Distances do not correspond precisely to expected latency, geographical
distance, or anything else. Distances should be compared only between
tablets of the same group; they are not meaningful between different
groups.
A value of zero indicates that the tablet may be in the same zone as
the client, and have minimum network latency. A value less than or equal to
five indicates that the tablet is thought to be in the same region as the
client, and may have a few milliseconds of network latency. Values greater
than five are most likely in a different region, with non-trivial network
latency.
Clients should use the following algorithm:

- If the request is using a directed read, eliminate any tablets that do not match the directed read's target zone and/or replica type.
- (Read-write transactions only) Choose leader tablet if it has an distance \<=5.
- Group and sort tablets by distance. Choose a random tablet with the lowest distance. If the request is not a directed read, only consider replicas with distances \<=5.
- Send the request to the fallback endpoint. The tablet picked by this algorithm may be skipped, either because it is marked as `skip` by the server or because the corresponding server is unreachable, flow controlled, etc. Skipped tablets should be added to the `skipped_tablet_uid` field in `RoutingHint`; the algorithm above should then be re-run without including the skipped tablet(s) to pick the next best tablet.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSkip

If true, the tablet should not be chosen by the client. Typically, this
signals that the tablet is unhealthy in some way. Tablets with `skip`
set to true should be reported back to the server in
`RoutingHint.skipped_tablet_uid`; this cues the server to send updated
information for this tablet should it become usable again.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setSkip

If true, the tablet should not be chosen by the client. Typically, this
signals that the tablet is unhealthy in some way. Tablets with `skip`
set to true should be reported back to the server in
`RoutingHint.skipped_tablet_uid`; this cues the server to send updated
information for this tablet should it become usable again.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |