Class RawQueryExecutor
java.lang.Object
com.couchbase.client.java.util.rawQuerying.RawQueryExecutor
@Uncommitted @Public public class RawQueryExecutor extends Object
A utility class that allows to perform
N1QL
and FTS
queries
synchronously and receive a raw version of the service's JSON response.
The responses can directly be exposed as JsonObject
or String
, but custom methods allow
to work from a byte array (for N1QL) or String (for FTS) and perform a custom deserialization.
Note that this class is outside of the Bucket API as it is uncommitted,
and is not common to all Couchbase SDKs.- Since:
- 2.3
- Author:
- Simon Baslé
-
Constructor Summary
Constructors Constructor Description RawQueryExecutor(AsyncRawQueryExecutor async, CouchbaseEnvironment env)
RawQueryExecutor(String bucket, String password, ClusterFacade core, CouchbaseEnvironment env)
RawQueryExecutor(String bucket, String username, String password, ClusterFacade core, CouchbaseEnvironment env)
-
Method Summary
Modifier and Type Method Description JsonObject
ftsToJsonObject(SearchQuery query)
Synchronously perform aSearchQuery
and return the raw N1QL response as aJsonObject
.<T> T
ftsToRawCustom(SearchQuery query, rx.functions.Func1<String,T> deserializer)
Synchronously perform aSearchQuery
and apply a user function to deserialize the raw JSON FTS response, which is represented as aString
.String
ftsToRawJson(SearchQuery query)
Synchronously perform aSearchQuery
and return the raw N1QL response as a String.JsonObject
n1qlToJsonObject(N1qlQuery query)
Synchronously perform aN1qlQuery
and return the raw N1QL response as aJsonObject
.<T> T
n1qlToRawCustom(N1qlQuery query, rx.functions.Func1<TranscoderUtils.ByteBufToArray,T> deserializer)
Synchronously perform aN1qlQuery
and apply a user function to deserialize the raw N1QL response, which is represented as a "TranscoderUtils.ByteBufToArray".String
n1qlToRawJson(N1qlQuery query)
Synchronously perform aN1qlQuery
and return the raw N1QL response as a String.
-
Constructor Details
-
RawQueryExecutor
-
RawQueryExecutor
public RawQueryExecutor(String bucket, String password, ClusterFacade core, CouchbaseEnvironment env) -
RawQueryExecutor
public RawQueryExecutor(String bucket, String username, String password, ClusterFacade core, CouchbaseEnvironment env)
-
-
Method Details
-
n1qlToJsonObject
Synchronously perform aN1qlQuery
and return the raw N1QL response as aJsonObject
. Note that the query is executed "as is", without any processing comparable to what is done inBucket.query(N1qlQuery)
(like enforcing a server side timeout or managing prepared statements).- Parameters:
query
- the query to execute.- Returns:
- the N1QL response as a
JsonObject
.
-
n1qlToRawJson
Synchronously perform aN1qlQuery
and return the raw N1QL response as a String. Note that the query is executed "as is", without any processing comparable to what is done inBucket.query(N1qlQuery)
(like enforcing a server side timeout or managing prepared statements).- Parameters:
query
- the query to execute.- Returns:
- the N1QL response as a String.
-
n1qlToRawCustom
public <T> T n1qlToRawCustom(N1qlQuery query, rx.functions.Func1<TranscoderUtils.ByteBufToArray,T> deserializer)Synchronously perform aN1qlQuery
and apply a user function to deserialize the raw N1QL response, which is represented as a "TranscoderUtils.ByteBufToArray". The array is derived from aByteBuf
that will be released, so it shouldn't be used to back the returned instance. Its scope should be considered the scope of the call method. Note that the query is executed "as is", without any processing comparable to what is done inBucket.query(N1qlQuery)
(like enforcing a server side timeout or managing prepared statements).- Type Parameters:
T
- the type of the response, once deserialized by the user-provided function.- Parameters:
query
- the query to execute.deserializer
- a deserializer function that transforms the byte representation of the response into a custom type T.- Returns:
- the N1QL response as a T.
-
ftsToJsonObject
Synchronously perform aSearchQuery
and return the raw N1QL response as aJsonObject
. Note that the query is executed "as is", without any processing comparable to what is done inBucket.query(SearchQuery)
(like enforcing a server side timeout).- Parameters:
query
- the query to execute.- Returns:
- the FTS response as a
JsonObject
.
-
ftsToRawJson
Synchronously perform aSearchQuery
and return the raw N1QL response as a String. Note that the query is executed "as is", without any processing comparable to what is done inBucket.query(SearchQuery)
(like enforcing a server side timeout).- Parameters:
query
- the query to execute.- Returns:
- the FTS response as a String.
-
ftsToRawCustom
Synchronously perform aSearchQuery
and apply a user function to deserialize the raw JSON FTS response, which is represented as aString
. Note that the query is executed "as is", without any processing comparable to what is done inBucket.query(SearchQuery)
(like enforcing a server side timeout).- Type Parameters:
T
- the type of the response, once deserialized by the user-provided function.- Parameters:
query
- the query to execute.deserializer
- a deserializer function that transforms the String representation of the response into a custom type T.- Returns:
- the FTS response as a T.
-