public class N1qlParams extends Object implements Serializable
Parameter Object for queries
that allows to fluently set most of the N1QL query parameters: - server side timeout - client context ID - scan consistency (with associated scan vector and/or scan wait if relevant) - max parallelism
Note that these are different from statement-related named parameters or positional parameters.
Modifier and Type | Method and Description |
---|---|
N1qlParams |
adhoc(boolean adhoc)
Allows to specify if this query is adhoc or not.
|
static N1qlParams |
build()
Start building a
N1qlParams , allowing to customize an N1QL request. |
N1qlParams |
consistency(ScanConsistency consistency)
Sets scan consistency.
|
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
hasServerSideTimeout()
Helper method to check if a custom server side timeout has been applied on the params.
|
void |
injectParams(JsonObject queryJson)
Modifies the given N1QL query (as a
JsonObject ) to reflect these N1qlParams . |
boolean |
isAdhoc()
True if this query is adhoc, false otherwise.
|
N1qlParams |
maxParallelism(int maxParallelism)
Allows to override the default maximum parallelism for the query execution on the server side.
|
N1qlParams |
scanWait(long wait,
TimeUnit unit)
If the
NOT_BOUNDED scan consistency has been chosen, does nothing. |
N1qlParams |
serverSideTimeout(long timeout,
TimeUnit unit)
Sets a maximum timeout for processing on the server side.
|
String |
toString() |
N1qlParams |
withContextId(String clientContextId)
Adds a client context ID to the request, that will be sent back in the response, allowing clients to meaningfully trace requests/responses when many are exchanged.
|
public void injectParams(JsonObject queryJson)
Modifies the given N1QL query (as a JsonObject
) to reflect these N1qlParams
.
queryJson
- the N1QL querypublic static N1qlParams build()
Start building a N1qlParams
, allowing to customize an N1QL request.
N1qlParams
public N1qlParams serverSideTimeout(long timeout, TimeUnit unit)
Sets a maximum timeout for processing on the server side.
timeout
- the duration of the timeout.unit
- the unit of the timeout, from nanoseconds to hours.N1qlParams
for chaining.public N1qlParams withContextId(String clientContextId)
Adds a client context ID to the request, that will be sent back in the response, allowing clients to meaningfully trace requests/responses when many are exchanged.
clientContextId
- the client context ID (null to send none)N1qlParams
for chaining.public N1qlParams consistency(ScanConsistency consistency)
Sets scan consistency.
Note that NOT_BOUNDED
will unset the scanWait
if it was set.
N1qlParams
for chaining.public N1qlParams scanWait(long wait, TimeUnit unit)
If the NOT_BOUNDED scan consistency
has been chosen, does nothing.
Otherwise, sets the maximum time the client is willing to wait for an index to catch up to the vector timestamp in the request.
wait
- the duration.unit
- the unit for the duration.N1qlParams
for chaining.public N1qlParams maxParallelism(int maxParallelism)
Allows to override the default maximum parallelism for the query execution on the server side.
maxParallelism
- the maximum parallelism for this query, 0 or negative values disable it.N1qlParams
for chaining.public N1qlParams adhoc(boolean adhoc)
Allows to specify if this query is adhoc or not.
If it is not adhoc (so performed often), the client will try to perform optimizations transparently based on the server capabilities, like preparing the statement and then executing a query plan instead of the raw query.
adhoc
- if the query is adhoc, default is true (plain execution).N1qlParams
for chaining.public boolean hasServerSideTimeout()
Helper method to check if a custom server side timeout has been applied on the params.
public boolean isAdhoc()
True if this query is adhoc, false otherwise.
Copyright © 2014 Couchbase, Inc.