@InterfaceStability.Experimental @InterfaceAudience.Private public class N1qlQueryExecutor extends Object
A class used to execute various N1QL queries.
Modifier and Type | Field and Description |
---|---|
protected static String |
ERROR_5000_SPECIFIC_MESSAGE |
Modifier | Constructor and Description |
---|---|
|
N1qlQueryExecutor(com.couchbase.client.core.ClusterFacade core,
String bucket,
String password)
Construct a new N1qlQueryExecutor that will send requests through the given
ClusterFacade . |
protected |
N1qlQueryExecutor(com.couchbase.client.core.ClusterFacade core,
String bucket,
String password,
LRUCache<String,PreparedPayload> lruCache)
This constructor is for testing purpose, prefer using
N1qlQueryExecutor(ClusterFacade, String, String) . |
Modifier and Type | Method and Description |
---|---|
protected Observable<AsyncN1qlQueryResult> |
dispatchPrepared(N1qlQuery query) |
Observable<AsyncN1qlQueryResult> |
execute(N1qlQuery query) |
protected Observable<AsyncN1qlQueryResult> |
executePrepared(N1qlQuery query,
PreparedPayload payload)
Issues a proper N1QL EXECUTE, detecting if parameters must be added to it.
|
protected Observable<AsyncN1qlQueryResult> |
executeQuery(N1qlQuery query)
Experimental, Internal: Queries a N1QL secondary index.
|
protected PreparedPayload |
extractPreparedPayloadFromResponse(PrepareStatement prepared,
JsonObject response)
Extracts the
PreparedPayload from the server’s response during a PREPARE. |
int |
invalidateQueryCache()
Invalidates and clears the query cache.
|
protected Observable<PreparedPayload> |
prepare(Statement statement)
Experimental: Queries a N1QL secondary index and prepare an execution plan via the given statement in
String form. |
protected Observable<AsyncN1qlQueryResult> |
prepareAndExecute(N1qlQuery query)
Issues a N1QL PREPARE, puts the plan in cache then EXECUTE it.
|
protected Observable<AsyncN1qlQueryResult> |
retryPrepareAndExecuteOnce(Throwable error,
N1qlQuery query)
In case the error warrants a retry, issue a PREPARE, followed by an update of the cache and an EXECUTE.
|
protected static final String ERROR_5000_SPECIFIC_MESSAGE
public N1qlQueryExecutor(com.couchbase.client.core.ClusterFacade core, String bucket, String password)
Construct a new N1qlQueryExecutor that will send requests through the given ClusterFacade
. For queries that are not ad-hoc, it will cache up to queries.
core
- the core through which to send requests.bucket
- the bucket to bootstrap from.password
- the password for the bucket.protected N1qlQueryExecutor(com.couchbase.client.core.ClusterFacade core, String bucket, String password, LRUCache<String,PreparedPayload> lruCache)
This constructor is for testing purpose, prefer using N1qlQueryExecutor(ClusterFacade, String, String)
.
public Observable<AsyncN1qlQueryResult> execute(N1qlQuery query)
protected Observable<AsyncN1qlQueryResult> executeQuery(N1qlQuery query)
Experimental, Internal: Queries a N1QL secondary index.
The returned Observable
can error under the following conditions:
BackpressureException
RequestCancelledException
query
- the full query as a Json String, including all necessary parameters.protected Observable<AsyncN1qlQueryResult> dispatchPrepared(N1qlQuery query)
protected Observable<AsyncN1qlQueryResult> retryPrepareAndExecuteOnce(Throwable error, N1qlQuery query)
In case the error warrants a retry, issue a PREPARE, followed by an update of the cache and an EXECUTE. Any failure in the EXECUTE won’t continue the retry cycle.
protected Observable<AsyncN1qlQueryResult> prepareAndExecute(N1qlQuery query)
Issues a N1QL PREPARE, puts the plan in cache then EXECUTE it.
protected Observable<AsyncN1qlQueryResult> executePrepared(N1qlQuery query, PreparedPayload payload)
Issues a proper N1QL EXECUTE, detecting if parameters must be added to it.
protected Observable<PreparedPayload> prepare(Statement statement)
Experimental: Queries a N1QL secondary index and prepare an execution plan via the given statement in String
form. Statement can contain placeholders. The resulting PreparedPayload
can be cached and (re)used later in a PreparedN1qlQuery
.
The returned Observable
can error under the following conditions:
BackpressureException
RequestCancelledException
statement
- the statement to prepare a plan for.PreparedPayload
that can be cached and reused later in PreparedN1qlQuery
.protected PreparedPayload extractPreparedPayloadFromResponse(PrepareStatement prepared, JsonObject response)
Extracts the PreparedPayload
from the server’s response during a PREPARE.
public int invalidateQueryCache()
Invalidates and clears the query cache.
Copyright © 2014 Couchbase, Inc.