Interface QueryResult<R>

Type Parameters:
R - The result type of the query.

public interface QueryResult<R>
Container for a single partition's result when executing a StateQueryRequest.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Used by stores to add detailed execution information (if requested) during query execution.
    static <R> QueryResult<R>
    forFailure(FailureReason failureReason, String failureMessage)
    Static factory method to create a result object for a failed query.
    static <R> QueryResult<R>
    forResult(R result)
    Static factory method to create a result object for a successful query.
    static <R> QueryResult<R>
    Static factory method to create a failed query result object to indicate that the store does not know how to handle the query.
    If detailed execution information was requested in StateQueryRequest.enableExecutionInfo(), this method returned the execution details for this partition's result.
    If this partition failed to execute the query, returns the failure message.
    If this partition failed to execute the query, returns the reason.
    This state partition's exact position in its history when this query was executed.
    Returns the result of executing the query on one partition.
    boolean
    True iff the query execution failed.
    boolean
    True iff the query was successfully executed.
    static <R> QueryResult<R>
    notUpToBound(Position currentPosition, PositionBound positionBound, Integer partition)
    Static factory method to create a failed query result object to indicate that the store has not yet caught up to the requested position bound.
    void
    Used by stores to report what exact position in the store's history it was at when it executed the query.
  • Method Details

    • forResult

      static <R> QueryResult<R> forResult(R result)
      Static factory method to create a result object for a successful query. Used by StateStores to respond to a StateStore#query(Query, PositionBound, boolean).
    • forFailure

      static <R> QueryResult<R> forFailure(FailureReason failureReason, String failureMessage)
      Static factory method to create a result object for a failed query. Used by StateStores to respond to a StateStore#query(Query, PositionBound, boolean).
    • forUnknownQueryType

      static <R> QueryResult<R> forUnknownQueryType(Query<R> query, StateStore store)
      Static factory method to create a failed query result object to indicate that the store does not know how to handle the query.

      Used by StateStores to respond to a StateStore#query(Query, PositionBound, boolean).

    • notUpToBound

      static <R> QueryResult<R> notUpToBound(Position currentPosition, PositionBound positionBound, Integer partition)
      Static factory method to create a failed query result object to indicate that the store has not yet caught up to the requested position bound.

      Used by StateStores to respond to a StateStore#query(Query, PositionBound, boolean).

    • addExecutionInfo

      void addExecutionInfo(String message)
      Used by stores to add detailed execution information (if requested) during query execution.
    • setPosition

      void setPosition(Position position)
      Used by stores to report what exact position in the store's history it was at when it executed the query.
    • isSuccess

      boolean isSuccess()
      True iff the query was successfully executed. The response is available in {@link this#getResult()}.
    • isFailure

      boolean isFailure()
      True iff the query execution failed. More information about the failure is available in {@link this#getFailureReason()} and {@link this#getFailureMessage()}.
    • getExecutionInfo

      List<String> getExecutionInfo()
      If detailed execution information was requested in StateQueryRequest.enableExecutionInfo(), this method returned the execution details for this partition's result.
    • getPosition

      Position getPosition()
      This state partition's exact position in its history when this query was executed. Can be used in conjunction with subsequent queries via StateQueryRequest.withPositionBound(PositionBound).

      Note: stores are encouraged, but not required to set this property.

    • getFailureReason

      FailureReason getFailureReason()
      If this partition failed to execute the query, returns the reason.
      Throws:
      IllegalArgumentException - if this is not a failed result.
    • getFailureMessage

      String getFailureMessage()
      If this partition failed to execute the query, returns the failure message.
      Throws:
      IllegalArgumentException - if this is not a failed result.
    • getResult

      R getResult()
      Returns the result of executing the query on one partition. The result type is determined by the query. Note: queries may choose to return null for a successful query, so {@link this#isSuccess()} and {@link this#isFailure()} must be used to determine whether the query was successful of failed on this partition.
      Throws:
      IllegalArgumentException - if this is not a successful query.