Package com.couchbase.client.java.subdoc
Class AsyncMutateInBuilder
java.lang.Object
com.couchbase.client.java.subdoc.AsyncMutateInBuilder
@Committed @Public public class AsyncMutateInBuilder extends Object
A builder for subdocument mutations. In order to perform the final set of operations, use the
execute()
method. Operations are performed asynchronously (see MutateInBuilder
for a synchronous
version).
Instances of this builder should be obtained through AsyncBucket.mutateIn(String)
rather than directly
constructed.- Since:
- 2.2
- Author:
- Simon Baslé
-
Field Summary
Fields Modifier and Type Field Description protected long
cas
protected String
docId
protected int
expiry
protected boolean
insertDocument
protected List<MutationSpec>
mutationSpecs
protected PersistTo
persistTo
protected ReplicateTo
replicateTo
protected boolean
upsertDocument
-
Constructor Summary
Constructors Constructor Description AsyncMutateInBuilder(ClusterFacade core, String bucketName, CouchbaseEnvironment environment, FragmentTranscoder transcoder, String docId)
Instances of this builder should be obtained throughAsyncBucket.mutateIn(String)
rather than directly constructed. -
Method Summary
Modifier and Type Method Description <T> AsyncMutateInBuilder
arrayAddUnique(String path, T value)
Insert a value in an existing array only if the value isn't already contained in the array (by way of string comparison).<T> AsyncMutateInBuilder
arrayAddUnique(String path, T value, boolean createPath)
Deprecated.<T> AsyncMutateInBuilder
arrayAddUnique(String path, T value, SubdocOptionsBuilder optionsBuilder)
Insert a value in an existing array only if the value isn't already contained in the array (by way of string comparison).<T> AsyncMutateInBuilder
arrayAppend(String path, T value)
Append to an existing array, pushing the value to the back/last position in the array.<T> AsyncMutateInBuilder
arrayAppend(String path, T value, boolean createPath)
Deprecated.UsearrayAppend(String, Object, SubdocOptionsBuilder)
instead.<T> AsyncMutateInBuilder
arrayAppend(String path, T value, SubdocOptionsBuilder optionsBuilder)
Append to an existing array, pushing the value to the back/last position in the array.<T> AsyncMutateInBuilder
arrayAppendAll(String path, Collection<T> values, boolean createPath)
Deprecated.<T> AsyncMutateInBuilder
arrayAppendAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder)
Append multiple values at once in an existing array, pushing all values in the collection's iteration order to the back/end of the array.<T> AsyncMutateInBuilder
arrayAppendAll(String path, T... values)
Append multiple values at once in an existing array, pushing all values to the back/end of the array.<T> AsyncMutateInBuilder
arrayInsert(String path, T value)
Insert into an existing array at a specific position (denoted in the path, eg.<T> AsyncMutateInBuilder
arrayInsert(String path, T value, SubdocOptionsBuilder optionsBuilder)
Insert into an existing array at a specific position (denoted in the path, eg.<T> AsyncMutateInBuilder
arrayInsertAll(String path, Collection<T> values)
Insert multiple values at once in an existing array at a specified position (denoted in the path, eg.<T> AsyncMutateInBuilder
arrayInsertAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder)
Insert multiple values at once in an existing array at a specified position (denoted in the path, eg.<T> AsyncMutateInBuilder
arrayInsertAll(String path, T... values)
Insert multiple values at once in an existing array at a specified position (denoted in the path, eg.<T> AsyncMutateInBuilder
arrayPrepend(String path, T value)
Prepend to an existing array, pushing the value to the front/first position in the array.<T> AsyncMutateInBuilder
arrayPrepend(String path, T value, boolean createPath)
Deprecated.UsearrayPrepend(String, Object, SubdocOptionsBuilder)
instead.<T> AsyncMutateInBuilder
arrayPrepend(String path, T value, SubdocOptionsBuilder optionsBuilder)
Prepend to an existing array, pushing the value to the front/first position in the array.<T> AsyncMutateInBuilder
arrayPrependAll(String path, Collection<T> values, boolean createPath)
Deprecated.<T> AsyncMutateInBuilder
arrayPrependAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder)
Prepend multiple values at once in an existing array, pushing all values in the collection's iteration order to the front/start of the array.<T> AsyncMutateInBuilder
arrayPrependAll(String path, T... values)
Prepend multiple values at once in an existing array, pushing all values to the front/start of the array.AsyncMutateInBuilder
counter(String path, long delta)
Increment/decrement a numerical fragment in a JSON document.AsyncMutateInBuilder
counter(String path, long delta, boolean createPath)
Deprecated.Usecounter(String, long, SubdocOptionsBuilder)
instead.AsyncMutateInBuilder
counter(String path, long delta, SubdocOptionsBuilder optionsBuilder)
Increment/decrement a numerical fragment in a JSON document.AsyncMutateInBuilder
createDocument(boolean createDocument)
Deprecated.UseupsertDocument(boolean)
instead.protected rx.Observable<DocumentFragment<Mutation>>
doMultiMutate(long timeout, TimeUnit timeUnit)
protected rx.Observable<DocumentFragment<Mutation>>
doSingleMutate(MutationSpec spec, long timeout, TimeUnit timeUnit)
rx.Observable<DocumentFragment<Mutation>>
execute()
Perform severalmutation
operations inside a single existingJSON document
.rx.Observable<DocumentFragment<Mutation>>
execute(long timeout, TimeUnit timeUnit)
Perform severalmutation
operations inside a single existingJSON document
.rx.Observable<DocumentFragment<Mutation>>
execute(PersistTo persistTo)
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements.rx.Observable<DocumentFragment<Mutation>>
execute(PersistTo persistTo, long timeout, TimeUnit timeUnit)
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements.rx.Observable<DocumentFragment<Mutation>>
execute(PersistTo persistTo, ReplicateTo replicateTo)
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements.rx.Observable<DocumentFragment<Mutation>>
execute(PersistTo persistTo, ReplicateTo replicateTo, long timeout, TimeUnit timeUnit)
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements.rx.Observable<DocumentFragment<Mutation>>
execute(ReplicateTo replicateTo)
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements.rx.Observable<DocumentFragment<Mutation>>
execute(ReplicateTo replicateTo, long timeout, TimeUnit timeUnit)
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements.<T> AsyncMutateInBuilder
insert(String path, T fragment)
Insert a fragment, provided the last element of the path doesn't exist.<T> AsyncMutateInBuilder
insert(String path, T fragment, boolean createPath)
Deprecated.Useinsert(String, Object, SubdocOptionsBuilder)
instead.<T> AsyncMutateInBuilder
insert(String path, T fragment, SubdocOptionsBuilder optionsBuilder)
Insert a fragment, provided the last element of the path doesn't exist.AsyncMutateInBuilder
insertDocument(boolean insertDocument)
Set insertDocument to true, if the document has to be created only if it does not exist<T> AsyncMutateInBuilder
remove(String path)
Remove an entry in a JSON document (scalar, array element, dictionary entry, whole array or dictionary, depending on the path).<T> AsyncMutateInBuilder
remove(String path, SubdocOptionsBuilder optionsBuilder)
Remove an entry in a JSON document (scalar, array element, dictionary entry, whole array or dictionary, depending on the path).<T> AsyncMutateInBuilder
replace(String path, T fragment)
Replace an existing value by the given fragment.<T> AsyncMutateInBuilder
replace(String path, T fragment, SubdocOptionsBuilder optionsBuilder)
Replace an existing value by the given fragment.String
toString()
AsyncMutateInBuilder
upsert(JsonObject content)
Upsert a full JSON document.<T> AsyncMutateInBuilder
upsert(String path, T fragment)
Insert a fragment, replacing the old value if the path exists.<T> AsyncMutateInBuilder
upsert(String path, T fragment, boolean createPath)
Deprecated.Useupsert(String, Object, SubdocOptionsBuilder)
instead.<T> AsyncMutateInBuilder
upsert(String path, T fragment, SubdocOptionsBuilder optionsBuilder)
Insert a fragment, replacing the old value if the path exists.AsyncMutateInBuilder
upsertDocument(boolean upsertDocument)
Set upsertDocument to true, if the document has to be createdAsyncMutateInBuilder
withCas(long cas)
Apply the whole mutation using optimistic locking, checking against the provided CAS value.AsyncMutateInBuilder
withDurability(PersistTo persistTo)
Set a persistence durability constraint for the whole mutation.AsyncMutateInBuilder
withDurability(PersistTo persistTo, ReplicateTo replicateTo)
Set both a persistence and a replication durability constraints for the whole mutation.AsyncMutateInBuilder
withDurability(ReplicateTo replicateTo)
Set a replication durability constraint for the whole mutation.AsyncMutateInBuilder
withExpiry(int expiry)
Change the expiry of the enclosing document as part of the mutation.
-
Field Details
-
docId
-
mutationSpecs
-
expiry
protected int expiry -
cas
protected long cas -
persistTo
-
replicateTo
-
upsertDocument
protected boolean upsertDocument -
insertDocument
protected boolean insertDocument
-
-
Constructor Details
-
AsyncMutateInBuilder
@Private public AsyncMutateInBuilder(ClusterFacade core, String bucketName, CouchbaseEnvironment environment, FragmentTranscoder transcoder, String docId)Instances of this builder should be obtained throughAsyncBucket.mutateIn(String)
rather than directly constructed.
-
-
Method Details
-
execute
Perform severalmutation
operations inside a single existingJSON document
. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
execute
Perform severalmutation
operations inside a single existingJSON document
. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
.- Parameters:
timeout
- the specific timeout to apply for the operation.timeUnit
- the time unit for the timeout.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
execute
public rx.Observable<DocumentFragment<Mutation>> execute(PersistTo persistTo, ReplicateTo replicateTo)Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- The durability constraint could not be fulfilled because of a temporary or persistent problem:DurabilityException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
. ADurabilityException
typically happens if the given amount of replicas needed to fulfill the durability requirement cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured andReplicateTo.TWO
is used, the observable is errored with aDurabilityException
. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). **It is important to understand that the original execute has already happened, so the actual execute and the watching for durability requirements are two separate tasks internally.**- Parameters:
persistTo
- the persistence requirement to watch.replicateTo
- the replication requirement to watch.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
execute
public rx.Observable<DocumentFragment<Mutation>> execute(PersistTo persistTo, ReplicateTo replicateTo, long timeout, TimeUnit timeUnit)Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- The durability constraint could not be fulfilled because of a temporary or persistent problem:DurabilityException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
. ADurabilityException
typically happens if the given amount of replicas needed to fulfill the durability requirement cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured andReplicateTo.TWO
is used, the observable is errored with aDurabilityException
. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). **It is important to understand that the original execute has already happened, so the actual execute and the watching for durability requirements are two separate tasks internally.**- Parameters:
persistTo
- the persistence requirement to watch.replicateTo
- the replication requirement to watch.timeout
- the specific timeout to apply for the operation.timeUnit
- the time unit for the timeout.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
execute
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- The durability constraint could not be fulfilled because of a temporary or persistent problem:DurabilityException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
. ADurabilityException
typically happens if the given amount of replicas needed to fulfill the durability requirement cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured andReplicateTo.TWO
is used, the observable is errored with aDurabilityException
. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). **It is important to understand that the original execute has already happened, so the actual execute and the watching for durability requirements are two separate tasks internally.**- Parameters:
persistTo
- the persistence requirement to watch.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
execute
public rx.Observable<DocumentFragment<Mutation>> execute(PersistTo persistTo, long timeout, TimeUnit timeUnit)Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- The durability constraint could not be fulfilled because of a temporary or persistent problem:DurabilityException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
. ADurabilityException
typically happens if the given amount of replicas needed to fulfill the durability requirement cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured andReplicateTo.TWO
is used, the observable is errored with aDurabilityException
. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). **It is important to understand that the original execute has already happened, so the actual execute and the watching for durability requirements are two separate tasks internally.**- Parameters:
persistTo
- the persistence requirement to watch.timeout
- the specific timeout to apply for the operation.timeUnit
- the time unit for the timeout.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
execute
Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- The durability constraint could not be fulfilled because of a temporary or persistent problem:DurabilityException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
. ADurabilityException
typically happens if the given amount of replicas needed to fulfill the durability requirement cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured andReplicateTo.TWO
is used, the observable is errored with aDurabilityException
. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). **It is important to understand that the original execute has already happened, so the actual execute and the watching for durability requirements are two separate tasks internally.**- Parameters:
replicateTo
- the replication requirement to watch.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
execute
public rx.Observable<DocumentFragment<Mutation>> execute(ReplicateTo replicateTo, long timeout, TimeUnit timeUnit)Perform severalmutation
operations inside a single existingJSON document
and watch for durability requirements. The list of mutations and paths to mutate in the JSON is added through builder methods likearrayInsert(String, Object)
. Multi-mutations are applied as a whole, atomically at the document level. That means that if one of the mutations fails, none of the mutations are applied. Otherwise, all mutations can be considered successful and the whole operation will receive aDocumentFragment
with the updated cas (and optionallyMutationToken
). The subdocument API has the benefit of only transmitting the fragment of the document you want to mutate on the wire, instead of the whole document. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No mutation was defined through the builder API:IllegalArgumentException
- A mutation spec couldn't be encoded and the whole operation was cancelled:TranscodingException
- The multi-mutation failed:MultiMutationException
- The durability constraint could not be fulfilled because of a temporary or persistent problem:DurabilityException
- CAS was provided but optimistic locking failed:CASMismatchException
When receiving aMultiMutationException
, one can inspect the exception to find the zero-based index and errorstatus code
of the first failingMutation
. Subsequent mutations may have also failed had they been attempted, but a single spec failing causes the whole operation to be cancelled. Other top-level error conditions are similar to those encountered during a document-levelAsyncBucket.replace(Document)
. ADurabilityException
typically happens if the given amount of replicas needed to fulfill the durability requirement cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured andReplicateTo.TWO
is used, the observable is errored with aDurabilityException
. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). **It is important to understand that the original execute has already happened, so the actual execute and the watching for durability requirements are two separate tasks internally.**- Parameters:
replicateTo
- the replication requirement to watch.timeout
- the specific timeout to apply for the operation.timeUnit
- the time unit for the timeout.- Returns:
- an
Observable
of a singleDocumentFragment
(if successful) containing updated cas metadata. Note that some individual results could also bear a value, like counter operations.
-
withExpiry
Change the expiry of the enclosing document as part of the mutation. Note that if the document had an expiration time set, it needs to be set again at this operation otherwise it will be reset to 0 (this is similar to a regular mutation where a new expiration must be set as well).- Parameters:
expiry
- the new expiry to apply (not setting it will disable expiration for the full document)- Returns:
- this builder for chaining.
-
withCas
Apply the whole mutation using optimistic locking, checking against the provided CAS value.- Parameters:
cas
- the CAS to compare the enclosing document to.- Returns:
- this builder for chaining.
-
withDurability
Set a persistence durability constraint for the whole mutation.- Parameters:
persistTo
- the persistence durability constraint to observe.- Returns:
- this builder for chaining.
-
withDurability
Set a replication durability constraint for the whole mutation.- Parameters:
replicateTo
- the replication durability constraint to observe.- Returns:
- this builder for chaining.
-
withDurability
Set both a persistence and a replication durability constraints for the whole mutation.- Parameters:
persistTo
- the persistence durability constraint to observe.replicateTo
- the replication durability constraint to observe.- Returns:
- this builder for chaining.
-
createDocument
Deprecated.UseupsertDocument(boolean)
instead.Set createDocument to true, if the document has to be created- Parameters:
createDocument
- true to create document.
-
upsertDocument
Set upsertDocument to true, if the document has to be created- Parameters:
upsertDocument
- true to create document.
-
insertDocument
Set insertDocument to true, if the document has to be created only if it does not exist- Parameters:
insertDocument
- true to insert document.
-
replace
Replace an existing value by the given fragment.- Parameters:
path
- the path where the value to replace is.fragment
- the new value.
-
replace
public <T> AsyncMutateInBuilder replace(String path, T fragment, SubdocOptionsBuilder optionsBuilder)Replace an existing value by the given fragment.- Parameters:
path
- the path where the value to replace is.fragment
- the new value.optionsBuilder
-SubdocOptionsBuilder
-
insert
Deprecated.Useinsert(String, Object, SubdocOptionsBuilder)
instead.Insert a fragment, provided the last element of the path doesn't exist.- Parameters:
path
- the path where to insert a new dictionary value.fragment
- the new dictionary value to insert.createPath
- true to create missing intermediary nodes.
-
insert
Insert a fragment, provided the last element of the path doesn't exist.- Parameters:
path
- the path where to insert a new dictionary value.fragment
- the new dictionary value to insert.
-
insert
public <T> AsyncMutateInBuilder insert(String path, T fragment, SubdocOptionsBuilder optionsBuilder)Insert a fragment, provided the last element of the path doesn't exist.- Parameters:
path
- the path where to insert a new dictionary value.fragment
- the new dictionary value to insert.optionsBuilder
-SubdocOptionsBuilder
-
upsert
Deprecated.Useupsert(String, Object, SubdocOptionsBuilder)
instead.Insert a fragment, replacing the old value if the path exists.- Parameters:
path
- the path where to insert (or replace) a dictionary value.fragment
- the new dictionary value to be applied.createPath
- true to create missing intermediary nodes.
-
upsert
Insert a fragment, replacing the old value if the path exists.- Parameters:
path
- the path where to insert (or replace) a dictionary value.fragment
- the new dictionary value to be applied.
-
upsert
Upsert a full JSON document.- Parameters:
content
- full content of the JSON document
-
upsert
public <T> AsyncMutateInBuilder upsert(String path, T fragment, SubdocOptionsBuilder optionsBuilder)Insert a fragment, replacing the old value if the path exists.- Parameters:
path
- the path where to insert (or replace) a dictionary value.fragment
- the new dictionary value to be applied.optionsBuilder
-SubdocOptionsBuilder
-
remove
Remove an entry in a JSON document (scalar, array element, dictionary entry, whole array or dictionary, depending on the path).- Parameters:
path
- the path to remove.
-
remove
Remove an entry in a JSON document (scalar, array element, dictionary entry, whole array or dictionary, depending on the path).- Parameters:
path
- the path to remove.optionsBuilder
-SubdocOptionsBuilder
-
counter
Deprecated.Usecounter(String, long, SubdocOptionsBuilder)
instead.Increment/decrement a numerical fragment in a JSON document. If the value (last element of the path) doesn't exist the counter is created and takes the value of the delta.- Parameters:
path
- the path to the counter (must be containing a number).delta
- the value to increment or decrement the counter by.createPath
- true to create missing intermediary nodes.
-
counter
Increment/decrement a numerical fragment in a JSON document. If the value (last element of the path) doesn't exist the counter is created and takes the value of the delta.- Parameters:
path
- the path to the counter (must be containing a number).delta
- the value to increment or decrement the counter by.
-
counter
Increment/decrement a numerical fragment in a JSON document. If the value (last element of the path) doesn't exist the counter is created and takes the value of the delta.- Parameters:
path
- the path to the counter (must be containing a number).delta
- the value to increment or decrement the counter by.optionsBuilder
-SubdocOptionsBuilder
-
arrayPrepend
Deprecated.UsearrayPrepend(String, Object, SubdocOptionsBuilder)
instead.Prepend to an existing array, pushing the value to the front/first position in the array.- Parameters:
path
- the path of the array.value
- the value to insert at the front of the array.createPath
- true to create missing intermediary nodes.
-
arrayPrepend
Prepend to an existing array, pushing the value to the front/first position in the array.- Parameters:
path
- the path of the array.value
- the value to insert at the front of the array.
-
arrayPrepend
public <T> AsyncMutateInBuilder arrayPrepend(String path, T value, SubdocOptionsBuilder optionsBuilder)Prepend to an existing array, pushing the value to the front/first position in the array.- Parameters:
path
- the path of the array.value
- the value to insert at the front of the array.optionsBuilder
-SubdocOptionsBuilder
-
arrayPrependAll
@Deprecated public <T> AsyncMutateInBuilder arrayPrependAll(String path, Collection<T> values, boolean createPath)Deprecated.Prepend multiple values at once in an existing array, pushing all values in the collection's iteration order to the front/start of the array. First value becomes the first element of the array, second value the second, etc... All existing values are shifted right in the array, by the number of inserted elements. Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayPrepend(String, Object, boolean)
(String, Object)} by grouping mutations in a single packet. For example given an array [ A, B, C ], prepending the values X and Y yields [ X, Y, A, B, C ] and not [ [ X, Y ], A, B, C ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the collection of values to insert at the front of the array as individual elements.createPath
- true to create missing intermediary nodes.
-
arrayPrependAll
public <T> AsyncMutateInBuilder arrayPrependAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder)Prepend multiple values at once in an existing array, pushing all values in the collection's iteration order to the front/start of the array. First value becomes the first element of the array, second value the second, etc... All existing values are shifted right in the array, by the number of inserted elements. Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayPrepend(String, Object, boolean)
(String, Object)} by grouping mutations in a single packet. For example given an array [ A, B, C ], prepending the values X and Y yields [ X, Y, A, B, C ] and not [ [ X, Y ], A, B, C ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the collection of values to insert at the front of the array as individual elements.optionsBuilder
-SubdocOptionsBuilder
-
arrayPrependAll
Prepend multiple values at once in an existing array, pushing all values to the front/start of the array. This is provided as a convenience alternative toarrayPrependAll(String, Collection, boolean)
. Note that parent nodes are not created when using this method (ie. createPath = false). First value becomes the first element of the array, second value the second, etc... All existing values are shifted right in the array, by the number of inserted elements. Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayPrepend(String, Object, boolean)
(String, Object)} by grouping mutations in a single packet. For example given an array [ A, B, C ], prepending the values X and Y yields [ X, Y, A, B, C ] and not [ [ X, Y ], A, B, C ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the values to insert at the front of the array as individual elements.- See Also:
if you need to create missing intermediary nodes.
-
arrayAppend
Deprecated.UsearrayAppend(String, Object, SubdocOptionsBuilder)
instead.Append to an existing array, pushing the value to the back/last position in the array.- Parameters:
path
- the path of the array.value
- the value to insert at the back of the array.createPath
- true to create missing intermediary nodes.
-
arrayAppend
Append to an existing array, pushing the value to the back/last position in the array.- Parameters:
path
- the path of the array.value
- the value to insert at the back of the array.
-
arrayAppend
public <T> AsyncMutateInBuilder arrayAppend(String path, T value, SubdocOptionsBuilder optionsBuilder)Append to an existing array, pushing the value to the back/last position in the array.- Parameters:
path
- the path of the array.value
- the value to insert at the back of the array.optionsBuilder
-SubdocOptionsBuilder
-
arrayAppendAll
@Deprecated public <T> AsyncMutateInBuilder arrayAppendAll(String path, Collection<T> values, boolean createPath)Deprecated.Append multiple values at once in an existing array, pushing all values in the collection's iteration order to the back/end of the array. Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayAppend(String, Object, boolean)
by grouping mutations in a single packet. For example given an array [ A, B, C ], appending the values X and Y yields [ A, B, C, X, Y ] and not [ A, B, C, [ X, Y ] ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the collection of values to individually insert at the back of the array.createPath
- true to create missing intermediary nodes.
-
arrayAppendAll
public <T> AsyncMutateInBuilder arrayAppendAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder)Append multiple values at once in an existing array, pushing all values in the collection's iteration order to the back/end of the array. Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayAppend(String, Object, boolean)
by grouping mutations in a single packet. For example given an array [ A, B, C ], appending the values X and Y yields [ A, B, C, X, Y ] and not [ A, B, C, [ X, Y ] ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the collection of values to individually insert at the back of the array.optionsBuilder
-SubdocOptionsBuilder
-
arrayAppendAll
Append multiple values at once in an existing array, pushing all values to the back/end of the array. This is provided as a convenience alternative toarrayAppendAll(String, Collection, boolean)
. Note that parent nodes are not created when using this method (ie. createPath = false). Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayAppend(String, Object, boolean)
by grouping mutations in a single packet. For example given an array [ A, B, C ], appending the values X and Y yields [ A, B, C, X, Y ] and not [ A, B, C, [ X, Y ] ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the values to individually insert at the back of the array.- See Also:
if you need to create missing intermediary nodes.
-
arrayInsert
Insert into an existing array at a specific position (denoted in the path, eg. "sub.array[2]").- Parameters:
path
- the path (including array position) where to insert the value.value
- the value to insert in the array.
-
arrayInsert
public <T> AsyncMutateInBuilder arrayInsert(String path, T value, SubdocOptionsBuilder optionsBuilder)Insert into an existing array at a specific position (denoted in the path, eg. "sub.array[2]").- Parameters:
path
- the path (including array position) where to insert the value.value
- the value to insert in the array.optionsBuilder
-SubdocOptionsBuilder
-
arrayInsertAll
Insert multiple values at once in an existing array at a specified position (denoted in the path, eg. "sub.array[2]"), inserting all values in the collection's iteration order at the given position and shifting existing values beyond the position by the number of elements in the collection. Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayInsert(String, Object)
by grouping mutations in a single packet. For example given an array [ A, B, C ], inserting the values X and Y at position 1 yields [ A, B, X, Y, C ] and not [ A, B, [ X, Y ], C ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the values to insert at the specified position of the array, each value becoming an entry at or after the insert position.
-
arrayInsertAll
public <T> AsyncMutateInBuilder arrayInsertAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder)Insert multiple values at once in an existing array at a specified position (denoted in the path, eg. "sub.array[2]"), inserting all values in the collection's iteration order at the given position and shifting existing values beyond the position by the number of elements in the collection. Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayInsert(String, Object)
by grouping mutations in a single packet. For example given an array [ A, B, C ], inserting the values X and Y at position 1 yields [ A, B, X, Y, C ] and not [ A, B, [ X, Y ], C ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the values to insert at the specified position of the array, each value becoming an entry at or after the insert position.optionsBuilder
-SubdocOptionsBuilder
-
arrayInsertAll
Insert multiple values at once in an existing array at a specified position (denoted in the path, eg. "sub.array[2]"), inserting all values at the given position and shifting existing values beyond the position by the number of elements in the collection. This is provided as a convenience alternative toarrayInsertAll(String, Collection)
. Note that parent nodes are not created when using this method (ie. createPath = false). Each item in the collection is inserted as an individual element of the array, but a bit of overhead is saved compared to individualarrayInsert(String, Object)
by grouping mutations in a single packet. For example given an array [ A, B, C ], inserting the values X and Y at position 1 yields [ A, B, X, Y, C ] and not [ A, B, [ X, Y ], C ].- Type Parameters:
T
- the type of data in the collection (must be JSON serializable).- Parameters:
path
- the path of the array.values
- the values to insert at the specified position of the array, each value becoming an entry at or after the insert position.- See Also:
if you need to create missing intermediary nodes.
-
arrayAddUnique
@Deprecated public <T> AsyncMutateInBuilder arrayAddUnique(String path, T value, boolean createPath)Deprecated.UsearrayAddUnique(String, Object, SubdocOptionsBuilder)
instead.Insert a value in an existing array only if the value isn't already contained in the array (by way of string comparison).- Parameters:
path
- the path to mutate in the JSON.value
- the value to insert.createPath
- true to create missing intermediary nodes.
-
arrayAddUnique
Insert a value in an existing array only if the value isn't already contained in the array (by way of string comparison).- Parameters:
path
- the path to mutate in the JSON.value
- the value to insert.
-
arrayAddUnique
public <T> AsyncMutateInBuilder arrayAddUnique(String path, T value, SubdocOptionsBuilder optionsBuilder)Insert a value in an existing array only if the value isn't already contained in the array (by way of string comparison).- Parameters:
path
- the path to mutate in the JSON.value
- the value to insert.optionsBuilder
-SubdocOptionsBuilder
-
doMultiMutate
-
doSingleMutate
protected rx.Observable<DocumentFragment<Mutation>> doSingleMutate(MutationSpec spec, long timeout, TimeUnit timeUnit) -
toString
-
arrayAddUnique(String, Object, SubdocOptionsBuilder)
instead.