WriteMultipleRequest¶
- class borneo.WriteMultipleRequest[source]¶
Bases:
Request
Represents the input to a
NoSQLHandle.write_multiple()
operation.This request can be used to perform a sequence of
PutRequest
orDeleteRequest
operations associated with a table that share the same shard key portion of their primary keys, the WriteMultiple operation as whole is atomic. It is an efficient way to atomically modify multiple related rows.On a successful operation
WriteMultipleResult.get_success()
returns True. The execution result of each operations can be retrieved usingWriteMultipleResult.get_results()
.If the WriteMultiple operation is aborted because of the failure of an operation with abort_if_unsuccessful set to True, then
WriteMultipleResult.get_success()
return False, the index of failed operation can be accessed usingWriteMultipleResult.get_failed_operation_index()
, and the execution result of failed operation can be accessed usingWriteMultipleResult.get_failed_operation_result()
.Methods Summary
add
(request, abort_if_unsuccessful)Adds a Request to the operation list, do validation check before adding it.
clear
()Removes all of the operations from the WriteMultiple request.
Cloud service only.
On-premise only.
Returns the number of Requests.
get_request
(index)Returns the Request at the given position, it may be either a
PutRequest
orDeleteRequest
object.Returns the table name to use for the operation.
Returns the timeout to use for the operation, in milliseconds.
set_compartment
(compartment)Cloud service only.
set_durability
(durability)On-premise only.
set_timeout
(timeout_ms)Sets the request timeout value, in milliseconds.
Methods Documentation
- add(request, abort_if_unsuccessful)[source]¶
Adds a Request to the operation list, do validation check before adding it.
- Parameters:
request (Request) – the Request to add, either
PutRequest
orDeleteRequest
.abort_if_unsuccessful (bool) – True if this operation should cause the entire WriteMultiple operation to abort when this operation fails.
- Returns:
self.
- Raises:
BatchOperationNumberLimitException – raises the exception if the number of requests exceeds the limit, or IllegalArgumentException if the request is neither a
PutRequest
orDeleteRequest
. Or any invalid state of the Request.IllegalArgumentException – raises the exception if parameters are not expected type.
- get_compartment()¶
Cloud service only.
Get the compartment id or name if set for the request.
- Returns:
compartment id or name if set for the request, otherwise None if not set.
- Return type:
str
- get_durability()[source]¶
On-premise only. Gets the durability to use for the operation or None if not set :returns: the Durability :versionadded: 5.3.0
- get_num_operations()[source]¶
Returns the number of Requests.
- Returns:
the number of Requests.
- Return type:
int
- get_request(index)[source]¶
Returns the Request at the given position, it may be either a
PutRequest
orDeleteRequest
object.- Parameters:
index (int) – the position of Request to get.
- Returns:
the Request at the given position.
- Return type:
- Raises:
IndexOutOfBoundsException – raises the exception if the position is negative or greater or equal to the number of Requests.
IllegalArgumentException – raises the exception if index is a negative number.
- get_table_name()¶
Returns the table name to use for the operation.
- Returns:
the table name, or None if not set.
- Returns:
str
- get_timeout()[source]¶
Returns the timeout to use for the operation, in milliseconds. A value of 0 indicates that the timeout has not been set.
- Returns:
the timeout value.
- Return type:
int
- set_compartment(compartment)[source]¶
Cloud service only.
Sets the name or id of a compartment to be used for this operation.
The compartment may be specified as either a name (or path for nested compartments) or as an id (OCID). A name (vs id) can only be used when authenticated using a specific user identity. It is not available if authenticated as an Instance Principal which can be done when calling the service from a compute instance in the Oracle Cloud Infrastructure. See
borneo.iam.SignatureProvider.create_with_instance_principal()
.- Parameters:
compartment (str) – the compartment name or id. If using a nested compartment, specify the full compartment path compartmentA.compartmentB, but exclude the name of the root compartment (tenant).
- Returns:
self.
- Raises:
IllegalArgumentException – raises the exception if compartment is not a str.
- set_durability(durability)[source]¶
On-premise only. Sets the durability to use for the operation.
- Parameters:
durability (Durability) – the Durability to use
- Returns:
self.
- Raises:
IllegalArgumentException – raises the exception if Durability is not valid
- Versionadded:
5.3.0
- set_timeout(timeout_ms)[source]¶
Sets the request timeout value, in milliseconds. This overrides any default value set in
NoSQLHandleConfig
. The value must be positive.- Parameters:
timeout_ms (int) – the timeout value, in milliseconds.
- Returns:
self.
- Raises:
IllegalArgumentException – raises the exception if the timeout value is less than or equal to 0.