Package com.couchbase.client.java.subdoc
Class AsyncLookupInBuilder
- java.lang.Object
-
- com.couchbase.client.java.subdoc.AsyncLookupInBuilder
-
@Committed @Public public class AsyncLookupInBuilder extends Object
A builder for subdocument lookups. In order to perform the final set of operations, use theexecute()
method. Operations are performed asynchronously (seeLookupInBuilder
for a synchronous version). Instances of this builder should be obtained throughAsyncBucket.lookupIn(String)
rather than directly constructed.- Since:
- 2.2
- Author:
- Simon Baslé
-
-
Constructor Summary
Constructors Constructor Description AsyncLookupInBuilder(ClusterFacade core, String bucketName, CouchbaseEnvironment environment, FragmentTranscoder transcoder, String docId)
Instances of this builder should be obtained throughAsyncBucket.lookupIn(String)
rather than directly constructed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncLookupInBuilder
accessDeleted(boolean accessDeleted)
Set accessDeleted to true, if the document has been deleted to access xattrsprotected rx.Observable<DocumentFragment<Lookup>>
doMultiLookup(long timeout, TimeUnit timeUnit)
Helper method to perform a multi path lookup.protected rx.Observable<DocumentFragment<Lookup>>
doSingleLookup(LookupSpec spec, long timeout, TimeUnit timeUnit)
rx.Observable<DocumentFragment<Lookup>>
execute()
Perform severallookup
operations inside a single existingJSON document
.rx.Observable<DocumentFragment<Lookup>>
execute(long timeout, TimeUnit timeUnit)
Perform severallookup
operations inside a single existingJSON document
.AsyncLookupInBuilder
exists(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
Check if a value exists inside the document (if it does not, attempting to get theDocumentFragment.content(int)
will raise an error).AsyncLookupInBuilder
exists(String... paths)
Check if a value exists inside the document (if it does not, attempting to get theDocumentFragment.content(int)
will raise an error).AsyncLookupInBuilder
exists(String path, SubdocOptionsBuilder optionsBuilder)
Check if a value exists inside the document (if it does not, attempting to get theDocumentFragment.content(int)
will raise an error).AsyncLookupInBuilder
get()
Get the full JSON document.AsyncLookupInBuilder
get(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document.AsyncLookupInBuilder
get(String... paths)
Get a value inside the JSON document.AsyncLookupInBuilder
get(String path, SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document.AsyncLookupInBuilder
getCount(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document.AsyncLookupInBuilder
getCount(String... paths)
Get the count of values inside the JSON document.AsyncLookupInBuilder
getCount(String path, SubdocOptionsBuilder optionsBuilder)
Get the count of values inside the JSON document.AsyncLookupInBuilder
includeRaw(boolean includeRaw)
Set to true, includes the raw byte value for each GET in the results, in addition to the deserialized content.boolean
isIncludeRaw()
String
toString()
-
-
-
Constructor Detail
-
AsyncLookupInBuilder
@Private public AsyncLookupInBuilder(ClusterFacade core, String bucketName, CouchbaseEnvironment environment, FragmentTranscoder transcoder, String docId)
Instances of this builder should be obtained throughAsyncBucket.lookupIn(String)
rather than directly constructed.
-
-
Method Detail
-
accessDeleted
@Committed public AsyncLookupInBuilder accessDeleted(boolean accessDeleted)
Set accessDeleted to true, if the document has been deleted to access xattrs- Parameters:
accessDeleted
- true to access deleted document xattrs
-
execute
public rx.Observable<DocumentFragment<Lookup>> execute()
Perform severallookup
operations inside a single existingJSON document
. The list of path to look for inside the JSON is constructed through builder methodsget(String...)
andexists(String...)
. The subdocument API has the benefit of only transmitting the fragment of the document you work with on the wire, instead of the whole document. If multiple operations are specified, each spec will receive an answer, overall contained in aDocumentFragment
, meaning that if sub-document level error conditions happen (like the path is malformed or doesn't exist), the whole operation still succeeds. If a single operation is specified, then any error other that a path not found will cause the Observable to fail with the correspondingSubDocumentException
. Otherwise aDocumentFragment
is returned. CallingDocumentFragment.content(String)
or one of its variants on a failed spec/path will throw the correspondingSubDocumentException
. For successful gets, it will return the value (or null in the case of a path not found, and only in this case). For exists, it will return true (or false for a path not found). To check for any error without throwing an exception, useDocumentFragment.status(String)
(or its index-based variant). To check that a given path (or index) is valid for callingcontent()
on it without raising an Exception, useDocumentFragment.exists(String)
. One special fatal error can also happen, when the value couldn't be decoded from JSON. In that case, the ResponseStatus for the path isResponseStatus.FAILURE
and the content(path) will throw aTranscodingException
. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No lookup was defined through the builder API:IllegalArgumentException
Other document-level error conditions are similar to those encountered during a document-levelAsyncBucket.get(String)
.- Returns:
- an
Observable
of a singleDocumentFragment
representing the whole list of results (1 for each spec), unless a document-level error happened (in which case an exception is propagated).
-
execute
public rx.Observable<DocumentFragment<Lookup>> execute(long timeout, TimeUnit timeUnit)
Perform severallookup
operations inside a single existingJSON document
. The list of path to look for inside the JSON is constructed through builder methodsget(String...)
andexists(String...)
. The subdocument API has the benefit of only transmitting the fragment of the document you work with on the wire, instead of the whole document. If multiple operations are specified, each spec will receive an answer, overall contained in aDocumentFragment
, meaning that if sub-document level error conditions happen (like the path is malformed or doesn't exist), the whole operation still succeeds. If a single operation is specified, then any error other that a path not found will cause the Observable to fail with the correspondingSubDocumentException
. Otherwise aDocumentFragment
is returned. CallingDocumentFragment.content(String)
or one of its variants on a failed spec/path will throw the correspondingSubDocumentException
. For successful gets, it will return the value (or null in the case of a path not found, and only in this case). For exists, it will return true (or false for a path not found). To check for any error without throwing an exception, useDocumentFragment.status(String)
(or its index-based variant). To check that a given path (or index) is valid for callingcontent()
on it without raising an Exception, useDocumentFragment.exists(String)
. One special fatal error can also happen, when the value couldn't be decoded from JSON. In that case, the ResponseStatus for the path isResponseStatus.FAILURE
and the content(path) will throw aTranscodingException
. This Observable most notable error conditions are: - The enclosing document does not exist:DocumentDoesNotExistException
- The enclosing document is not JSON:DocumentNotJsonException
- No lookup was defined through the builder API:IllegalArgumentException
Other document-level error conditions are similar to those encountered during a document-levelAsyncBucket.get(String)
.- Parameters:
timeout
- the specific timeout to apply for the operation.timeUnit
- the time unit for the timeout.- Returns:
- an
Observable
of a singleDocumentFragment
representing the whole list of results (1 for each spec), unless a document-level error happened (in which case an exception is propagated).
-
includeRaw
public AsyncLookupInBuilder includeRaw(boolean includeRaw)
Set to true, includes the raw byte value for each GET in the results, in addition to the deserialized content.
-
isIncludeRaw
public boolean isIncludeRaw()
- Returns:
- true if this builder is configured to include raw byte values for each GET result.
-
get
public AsyncLookupInBuilder get(String... paths)
Get a value inside the JSON document.- Parameters:
paths
- the path inside the document where to get the value from.- Returns:
- this builder for chaining.
-
get
@Committed public AsyncLookupInBuilder get()
Get the full JSON document.- Returns:
- this builder for chaining.
-
get
public AsyncLookupInBuilder get(String path, SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document.- Parameters:
path
- the path inside the document where to get the value from.optionsBuilder
-SubdocOptionsBuilder
- Returns:
- this builder for chaining.
-
get
public AsyncLookupInBuilder get(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document.- Parameters:
paths
- the path inside the document where to get the value from.optionsBuilder
-SubdocOptionsBuilder
- Returns:
- this builder for chaining.
-
exists
public AsyncLookupInBuilder exists(String... paths)
Check if a value exists inside the document (if it does not, attempting to get theDocumentFragment.content(int)
will raise an error). This doesn't transmit the value on the wire if it exists, saving the corresponding byte overhead.- Parameters:
paths
- the path inside the document to check for existence.- Returns:
- this builder for chaining.
-
exists
public AsyncLookupInBuilder exists(String path, SubdocOptionsBuilder optionsBuilder)
Check if a value exists inside the document (if it does not, attempting to get theDocumentFragment.content(int)
will raise an error). This doesn't transmit the value on the wire if it exists, saving the corresponding byte overhead.- Parameters:
path
- the path inside the document to check for existence.optionsBuilder
-SubdocOptionsBuilder
- Returns:
- this builder for chaining.
-
exists
public AsyncLookupInBuilder exists(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
Check if a value exists inside the document (if it does not, attempting to get theDocumentFragment.content(int)
will raise an error). This doesn't transmit the value on the wire if it exists, saving the corresponding byte overhead.- Parameters:
paths
- the path inside the document to check for existence.optionsBuilder
-SubdocOptionsBuilder
- Returns:
- this builder for chaining.
-
getCount
public AsyncLookupInBuilder getCount(String... paths)
Get the count of values inside the JSON document. This method is only available with Couchbase Server 5.0 and later.- Parameters:
paths
- the path inside the document where to get the count from.- Returns:
- this builder for chaining.
-
getCount
public AsyncLookupInBuilder getCount(String path, SubdocOptionsBuilder optionsBuilder)
Get the count of values inside the JSON document. This method is only available with Couchbase Server 5.0 and later.- Parameters:
path
- the path inside the document where to get the count from.optionsBuilder
-SubdocOptionsBuilder
- Returns:
- this builder for chaining.
-
getCount
public AsyncLookupInBuilder getCount(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document. This method is only available with Couchbase Server 5.0 and later.- Parameters:
paths
- the path inside the document where to get the value from.optionsBuilder
-SubdocOptionsBuilder
- Returns:
- this builder for chaining.
-
doSingleLookup
protected rx.Observable<DocumentFragment<Lookup>> doSingleLookup(LookupSpec spec, long timeout, TimeUnit timeUnit)
-
doMultiLookup
protected rx.Observable<DocumentFragment<Lookup>> doMultiLookup(long timeout, TimeUnit timeUnit)
Helper method to perform a multi path lookup.
-
-