Interface Statement<PARAMS,RESULT>
- Type Parameters:
PARAMS- type holding the statement's parametersRESULT- 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 -
Method Summary
Modifier and TypeMethodDescriptionReturns parameterized YQL for this query.Returns query type (for query merging purposes).default booleanTells 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.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 voidstoreToCache(PARAMS params, List<RESULT> result, tech.ydb.yoj.repository.db.cache.RepositoryCache cache) Writes the query result to first-level cache.toDebugString(PARAMS params) Returns debug representation of this query with the specified parameter values.toQueryParameters(PARAMS params) 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:
trueif the statement should be prepared;falseotherwise
-
getQuery
Returns parameterized YQL for this query.- Parameters:
tablespace- base path for all tables referenced in the query- Returns:
- YQL
-
toDebugString
Returns debug representation of this query with the specified parameter values.- Parameters:
params- parameter values. Might benulldepending on the statement type, e.g. for DELETE statements.- Returns:
- debug representation of the query parameterized with
params
-
toQueryParameters
Returns the query's parameter values as YDB protobuf structures.- Parameters:
params- parameter values Might benulldepending 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 structurevalue- 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 benulldepending on the statement type, e.g. for DELETE statements.cache- first-level cache- Returns:
- query result, if present in first-level cache;
nullotherwise
-
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 benulldepending on the statement type, e.g. for DELETE statements.result- result to save; ifnull, nothing will be saved to cachecache- first-level cache
-
getQueryType
Statement.QueryType getQueryType()Returns query type (for query merging purposes).- Returns:
- query type
-