Class StateQueryResult<R>

java.lang.Object
org.apache.kafka.streams.query.StateQueryResult<R>
Type Parameters:
R - The type of the query result.

@Evolving public class StateQueryResult<R> extends Object
The response object for interactive queries. This wraps the individual partition results, as well as metadata relating to the result as a whole.

  • Constructor Details

    • StateQueryResult

      public StateQueryResult()
  • Method Details

    • setGlobalResult

      public void setGlobalResult(QueryResult<R> r)
      Set the result for a global store query. Used by Kafka Streams and available for tests.
    • addResult

      public void addResult(int partition, QueryResult<R> r)
      Set the result for a partitioned store query. Used by Kafka Streams and available for tests.
    • getPartitionResults

      public Map<Integer,QueryResult<R>> getPartitionResults()
      The query's result for each partition that executed the query. Empty for global store queries.
    • getOnlyPartitionResult

      public QueryResult<R> getOnlyPartitionResult()
      For queries that are expected to match records in only one partition, returns the result.
      Throws:
      IllegalArgumentException - if the results are not for exactly one partition.
    • getGlobalResult

      public QueryResult<R> getGlobalResult()
      The query's result for global store queries. Is null for non-global (partitioned) store queries.
    • getPosition

      public Position getPosition()
      The position of the state store at the moment it executed the query. In conjunction with StateQueryRequest.withPositionBound(org.apache.kafka.streams.query.PositionBound), this can be used to achieve a good balance between consistency and availability in which repeated queries are guaranteed to advance in time while allowing reads to be served from any replica that is caught up to that caller's prior observations.
    • toString

      public String toString()
      Overrides:
      toString in class Object