Class QueryRequest

java.lang.Object
com.couchbase.client.core.msg.BaseRequest<QueryResponse>
com.couchbase.client.core.msg.query.QueryRequest
All Implemented Interfaces:
ChunkDecodable<QueryChunkHeader,QueryChunkRow,QueryChunkTrailer,QueryResponse>, Encodable<com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest>, HttpRequest<QueryChunkHeader,QueryChunkRow,QueryChunkTrailer,QueryResponse>, Request<QueryResponse>

  • Constructor Details

  • Method Details

    • queryContext

      public static String queryContext(String bucket, String scope)
      Helper method to build the query context from bucket and scope.
      Parameters:
      bucket - the name of the bucket.
      scope - the name of the scope.
      Returns:
      the build query context string.
    • encode

      public com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest encode()
      Specified by:
      encode in interface Encodable<com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest>
    • decode

      public QueryResponse decode(ResponseStatus status, QueryChunkHeader header, Flux<QueryChunkRow> rows, Mono<QueryChunkTrailer> trailer)
      Description copied from interface: ChunkDecodable
      Decodes a chunked response into the response format.
      Specified by:
      decode in interface ChunkDecodable<QueryChunkHeader,QueryChunkRow,QueryChunkTrailer,QueryResponse>
      Parameters:
      status - the http response status.
      header - the chunk header.
      rows - the chunk rows.
      trailer - the chunk trailer.
      Returns:
      a decoded response including all the chunk parts.
    • serviceType

      public ServiceType serviceType()
      Description copied from interface: Request
      The service type of this request.

      Can be null if this is a 'virtual service' (e.g. transactions), which don't map 1:1 to a particular cluster service, but need to integrate into various codepaths that are built around ServiceType such as ThresholdLoggingTracer. Virtual requests must not be sent into core at present, as there is limited support for them.

      Specified by:
      serviceType in interface Request<QueryResponse>
      Returns:
      the service type for this request.
    • target

      public NodeIdentifier target()
      Description copied from interface: Request
      Returns the node that should service this request, or null to let the service locator decide.
      Specified by:
      target in interface Request<QueryResponse>
      Returns:
      (nullable)
    • statement

      public String statement()
    • credentials

      public Authenticator credentials()
    • operationId

      public String operationId()
      Description copied from interface: Request
      Returns a potentially non-unique identifier that is useful for tracing output.

      Note: might be null! It depends on the type of operation. It is also different from the unqiue operation ID that increments to provide additional context (i.e in query the context uuid, in kv the opaque value).

      Specified by:
      operationId in interface Request<QueryResponse>
      Returns:
      if present, the operation id. Null otherwise.
    • idempotent

      public boolean idempotent()
      Description copied from interface: Request
      Returns if the given request is idempotent or not.

      By default, this method always returns false for data consistency reasons. Only specific idempotent operations should override this default since it impacts retry handling quite a bit. DO NOT SET THIS TO TRUE ON MUTATING OPERATIONS!

      Specified by:
      idempotent in interface Request<QueryResponse>
      Returns:
      true if idempotent.
    • bucket

      public String bucket()
      Description copied from interface: Request
      Returns the name of the bucket this request is scoped to, or null if not scoped to a bucket.
      Specified by:
      bucket in interface Request<QueryResponse>
      Returns:
      (nullable)
    • scope

      public String scope()
    • serviceContext

      public Map<String,Object> serviceContext()
      Description copied from interface: Request
      Returns contextual information for each individual service.
      Specified by:
      serviceContext in interface Request<QueryResponse>
      Overrides:
      serviceContext in class BaseRequest<QueryResponse>
      Returns:
      the service context.
    • toPrepareRequest

      @Internal public QueryRequest toPrepareRequest(boolean autoExecute, RequestTracer requestTracer)
      Returns a new request that creates a prepared statement using this request as a template.
    • toExecuteRequest

      @Internal public QueryRequest toExecuteRequest(String preparedStatementName, String encodedPlan, RequestTracer requestTracer)
      Returns a copy of this request tailored to execute a prepared statement.
      Parameters:
      preparedStatementName - name of the prepared statement
      encodedPlan - (nullable) query plan, or null if enhanced prepared statements are enabled.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • name

      public String name()
      Description copied from interface: Request
      The unique name of the request, usually related to the type but not necessarily.

      The default implementation is derived from the class name (i.e. FooRequest returns foo), but if that does not match up it should be overridden in the actual class.

      Specified by:
      name in interface Request<QueryResponse>
      Returns:
      the name of the request type.