public class QueryParams extends Object
Parameter Object for queries
that allows to fluently set most of the N1QL query parameters: - server side timeout - credentials - client context ID - scan consistency (with associated scan vector and/or scan wait if relevant)
Note that these are different from statement-related named parameters or positional parameters.
Modifier and Type | Method and Description |
---|---|
static QueryParams |
build()
Start building a
QueryParams , allowing to customize an N1QL request. |
QueryParams |
consistency(ScanConsistency consistency)
Sets scan consistency.
|
void |
injectParams(JsonObject queryJson)
Modifies the given N1QL query (as a
JsonObject ) to reflect these QueryParams . |
QueryParams |
scanWait(long wait,
TimeUnit unit)
If the
NOT_BOUNDED scan consistency has been chosen, does nothing. |
QueryParams |
serverSideTimeout(long timeout,
TimeUnit unit)
Sets a maximum timeout for processing on the server side.
|
QueryParams |
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 QueryParams
.
queryJson
- the N1QL querypublic static QueryParams build()
Start building a QueryParams
, allowing to customize an N1QL request.
QueryParams
public QueryParams 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.QueryParams
for chaining.public QueryParams 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)QueryParams
for chaining.public QueryParams consistency(ScanConsistency consistency)
Sets scan consistency.
Note that NOT_BOUNDED
will unset the scanWait
if it was set.
QueryParams
for chaining.public QueryParams 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.QueryParams
for chaining.Copyright © 2014 Couchbase, Inc.