@InterfaceStability.Uncommitted @InterfaceAudience.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.
Constructor and Description |
---|
RawQueryExecutor(AsyncRawQueryExecutor async,
CouchbaseEnvironment env) |
RawQueryExecutor(String bucket,
String password,
ClusterFacade core,
CouchbaseEnvironment env) |
Modifier and Type | Method and Description |
---|---|
JsonObject |
ftsToJsonObject(SearchQuery query)
Synchronously perform a
SearchQuery and return the raw N1QL response as a JsonObject . |
<T> T |
ftsToRawCustom(SearchQuery query,
Func1<String,T> deserializer)
Synchronously perform a
SearchQuery and apply a user function to deserialize the raw JSON FTS response, which is represented as a String . |
String |
ftsToRawJson(SearchQuery query)
Synchronously perform a
SearchQuery and return the raw N1QL response as a String. |
JsonObject |
n1qlToJsonObject(N1qlQuery query)
Synchronously perform a
N1qlQuery and return the raw N1QL response as a JsonObject . |
<T> T |
n1qlToRawCustom(N1qlQuery query,
Func1<TranscoderUtils.ByteBufToArray,T> deserializer)
Synchronously perform a
N1qlQuery and apply a user function to deserialize the raw N1QL response, which is represented as a TranscoderUtils.ByteBufToArray . |
String |
n1qlToRawJson(N1qlQuery query)
Synchronously perform a
N1qlQuery and return the raw N1QL response as a String. |
public RawQueryExecutor(AsyncRawQueryExecutor async, CouchbaseEnvironment env)
public RawQueryExecutor(String bucket, String password, ClusterFacade core, CouchbaseEnvironment env)
public JsonObject n1qlToJsonObject(N1qlQuery query)
Synchronously perform a N1qlQuery
and return the raw N1QL response as a JsonObject
.
Note that the query is executed “as is”, without any processing comparable to what is done in Bucket.query(N1qlQuery)
(like enforcing a server side timeout or managing prepared statements).
query
- the query to execute.JsonObject
.public String n1qlToRawJson(N1qlQuery query)
Synchronously perform a N1qlQuery
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 in Bucket.query(N1qlQuery)
(like enforcing a server side timeout or managing prepared statements).
query
- the query to execute.public <T> T n1qlToRawCustom(N1qlQuery query, Func1<TranscoderUtils.ByteBufToArray,T> deserializer)
Synchronously perform a N1qlQuery
and apply a user function to deserialize the raw N1QL response, which is represented as a TranscoderUtils.ByteBufToArray
.
The array is derived from a ByteBuf
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 in Bucket.query(N1qlQuery)
(like enforcing a server side timeout or managing prepared statements).
query
- the query to execute.deserializer
- a deserializer function that transforms the byte representation of the response into a custom type T.T
- the type of the response, once deserialized by the user-provided function.public JsonObject ftsToJsonObject(SearchQuery query)
Synchronously perform a SearchQuery
and return the raw N1QL response as a JsonObject
.
Note that the query is executed “as is”, without any processing comparable to what is done in Bucket.query(SearchQuery)
(like enforcing a server side timeout).
query
- the query to execute.JsonObject
.public String ftsToRawJson(SearchQuery query)
Synchronously perform a SearchQuery
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 in Bucket.query(SearchQuery)
(like enforcing a server side timeout).
query
- the query to execute.public <T> T ftsToRawCustom(SearchQuery query, Func1<String,T> deserializer)
Synchronously perform a SearchQuery
and apply a user function to deserialize the raw JSON FTS response, which is represented as a String
.
Note that the query is executed “as is”, without any processing comparable to what is done in Bucket.query(SearchQuery)
(like enforcing a server side timeout).
query
- the query to execute.deserializer
- a deserializer function that transforms the String representation of the response into a custom type T.T
- the type of the response, once deserialized by the user-provided function.Copyright © 2015 Couchbase, Inc.