Interface Statement<PARAMS,RESULT>

Type Parameters:
PARAMS - type holding the statement's parameters
RESULT - statement result type
All Known Implementing Classes:
DeleteByIdStatement, FindAllYqlStatement, FindInStatement, FindRangeStatement, InsertYqlStatement, MultipleVarsYqlStatement, MultipleVarsYqlStatement.Simple, PredicateStatement, UpdateByIdStatement, UpdateInStatement, UpsertYqlStatement, YqlStatement, YqlStatement.Simple

public interface Statement<PARAMS,RESULT>
Represents a statement that can be executed in a YdbRepositoryTransaction.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getQuery(String tablespace)
    Returns parameterized YQL for this query.
    Returns query type (for query merging purposes).
    default boolean
    Tells whether the statement should be prepared, that is, parsed once and then cached for subsequent queries during the same session.
    Prepared statements offer better query performance, but consume additional memory.
    default List<RESULT>
    readFromCache(PARAMS params, tech.ydb.yoj.repository.db.cache.RepositoryCache cache)
    Tries to read the query result from first-level cache.
    readResult(List<tech.ydb.proto.ValueProtos.Column> columns, tech.ydb.proto.ValueProtos.Value value)
    Converts YDB result set into the query result.
    default void
    storeToCache(PARAMS params, List<RESULT> result, tech.ydb.yoj.repository.db.cache.RepositoryCache cache)
    Writes the query result to first-level cache.
    Returns debug representation of this query with the specified parameter values.
    Map<String,tech.ydb.proto.ValueProtos.TypedValue>
    Returns the query's parameter values as YDB protobuf structures.
  • Method Details

    • isPreparable

      default boolean isPreparable()
      Tells whether the statement should be prepared, that is, parsed once and then cached for subsequent queries during the same session.
      Prepared statements offer better query performance, but consume additional memory.

      You should not blindly prepare all statements, especially non-parameterized ones; so by default this method returns false.

      Returns:
      true if the statement should be prepared; false otherwise
    • getQuery

      String getQuery(String tablespace)
      Returns parameterized YQL for this query.
      Parameters:
      tablespace - base path for all tables referenced in the query
      Returns:
      YQL
    • toDebugString

      String toDebugString(PARAMS params)
      Returns debug representation of this query with the specified parameter values.
      Parameters:
      params - parameter values. Might be null depending on the statement type, e.g. for DELETE statements.
      Returns:
      debug representation of the query parameterized with params
    • toQueryParameters

      Map<String,tech.ydb.proto.ValueProtos.TypedValue> toQueryParameters(PARAMS params)
      Returns the query's parameter values as YDB protobuf structures.
      Parameters:
      params - parameter values Might be null depending on the statement type, e.g. for DELETE statements.
      Returns:
      map: parameter name -> value as protobuf
    • readResult

      RESULT readResult(List<tech.ydb.proto.ValueProtos.Column> columns, tech.ydb.proto.ValueProtos.Value value)
      Converts YDB result set into the query result.
      Parameters:
      columns - result set as a YDB protobuf structure
      value - result set as a YDB protobuf structure
      Returns:
      query result
    • readFromCache

      default List<RESULT> readFromCache(PARAMS params, tech.ydb.yoj.repository.db.cache.RepositoryCache cache)
      Tries to read the query result from first-level cache.
      Parameters:
      params - parameter values. Might be null depending on the statement type, e.g. for DELETE statements.
      cache - first-level cache
      Returns:
      query result, if present in first-level cache; null otherwise
    • storeToCache

      default void storeToCache(PARAMS params, List<RESULT> result, tech.ydb.yoj.repository.db.cache.RepositoryCache cache)
      Writes the query result to first-level cache.
      Parameters:
      params - parameter values Might be null depending on the statement type, e.g. for DELETE statements.
      result - result to save; if null, nothing will be saved to cache
      cache - first-level cache
    • getQueryType

      Statement.QueryType getQueryType()
      Returns query type (for query merging purposes).
      Returns:
      query type