Package oracle.nosql.driver.ops

## Class WriteMultipleRequest

- java.lang.Object
- - oracle.nosql.driver.ops.Request
  - - oracle.nosql.driver.ops.WriteMultipleRequest

-     public class WriteMultipleRequest
      extends Request

  Represents the input to a `NoSQLHandle.writeMultiple(oracle.nosql.driver.ops.WriteMultipleRequest)` operation. This request can be used to perform a sequence of `PutRequest` or `DeleteRequest` 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.getSuccess()` returns true. The execution result of each operations can be retrieved using `WriteMultipleResult.getResults()`.

  If the WriteMultiple operation is aborted because of the failure of an operation with abortIfUnsuccessful set to true, then `WriteMultipleResult.getSuccess()` return false, the index of failed operation can be accessed using `WriteMultipleResult.getFailedOperationIndex()`, and the execution result of failed operation can be accessed using `WriteMultipleResult.getFailedOperationResult()`.

  See Also:
    `NoSQLHandle.writeMultiple(oracle.nosql.driver.ops.WriteMultipleRequest)`

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `WriteMultipleRequest()` | Constructs an empty request

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `WriteMultipleRequest` | `add​(Request request, boolean abortIfUnsuccessful)` | Adds a Request to the operation list.
    `void` | `clear()` | Removes all of the operations from the WriteMultiple request.
    `int` | `getNumOperations()` | Returns the number of Requests.
    `Request` | `getRequest​(int index)` | Returns the Request at the given position, it may be either a `PutRequest` or a `DeleteRequest` object.
    `int` | `getTimeout()` | Returns the timeout to use for the operation, in milliseconds.
    `String` | `getTypeName()` | Returns the type name of the request.
    `WriteMultipleRequest` | `setCompartment​(String compartment)` | Cloud service only.
    `WriteMultipleRequest` | `setDurability​(Durability durability)` | Sets the durability to use for the operation.
    `WriteMultipleRequest` | `setTimeout​(int timeoutMs)` | Sets the request timeout value, in milliseconds.

    - ### Methods inherited from class oracle.nosql.driver.ops.DurableRequest

      `getDurability`

    - ### Methods inherited from class oracle.nosql.driver.ops.Request

      `getCompartment, getRateLimitDelayedMs, getReadRateLimiter, getRetryStats, getTableName, getWriteRateLimiter, setRateLimitDelayedMs, setReadRateLimiter, setWriteRateLimiter`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### WriteMultipleRequest

          public WriteMultipleRequest()

      Constructs an empty request

  - ### Method Detail

    - #### add

          public WriteMultipleRequest add​(Request request,
                                          boolean abortIfUnsuccessful)

      Adds a Request to the operation list.
      Parameters:
        `request` - the Request to add, either `PutRequest` or `DeleteRequest`.
        `abortIfUnsuccessful` - is true if this operation should cause the entire WriteMultiple operation to abort when this operation fails.
      Returns:
        this
      Throws:
        `BatchOperationNumberLimitException` - if the number of requests exceeds the limit, or IllegalArgumentException if the request is neither a `PutRequest` or `DeleteRequest`. or any invalid state of the Request.

    - #### setCompartment

          public WriteMultipleRequest setCompartment​(String compartment)

      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 `SignatureProvider.createWithInstancePrincipal()`

      Parameters:
        `compartment` - the 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:
        this

    - #### getTimeout

          public int getTimeout()

      Returns the timeout to use for the operation, in milliseconds. A value of 0 indicates that the timeout has not been set.
      Returns:
        the value

    - #### getNumOperations

          public int getNumOperations()

      Returns the number of Requests.
      Returns:
        the number of Requests

    - #### getRequest

          public Request getRequest​(int index)

      Returns the Request at the given position, it may be either a `PutRequest` or a `DeleteRequest` object.
      Parameters:
        `index` - the position of Request to get
      Returns:
        the Request at the given position
      Throws:
        `IndexOutOfBoundsException` - if the position is negative or greater or equal to the number of Requests.

    - #### setTimeout

          public WriteMultipleRequest setTimeout​(int timeoutMs)

      Sets the request timeout value, in milliseconds. This overrides any default value set in `NoSQLHandleConfig`. The value must be positive.
      Parameters:
        `timeoutMs` - the timeout value, in milliseconds
      Returns:
        this
      Throws:
        `IllegalArgumentException` - if the timeout value is less than or equal to 0

    - #### clear

          public void clear()

      Removes all of the operations from the WriteMultiple request.

    - #### setDurability

          public WriteMultipleRequest setDurability​(Durability durability)

      Sets the durability to use for the operation. on-prem only.
      Parameters:
        `durability` - the durability value. Set to null for the default durability setting on the kvstore server.
      Returns:
        this
      Since:
        5.3.0

    - #### getTypeName

          public String getTypeName()

      Description copied from class: `Request`
      Returns the type name of the request. This is used for stats.
      Specified by:
        `getTypeName` in class `Request`
      Returns:
        the type name of the request