![]() |
Hazelcast C++ Client
Hazelcast C++ Client Library
|
Definition of an SQL statement. More...
#include <sql_statement.h>
Public Member Functions | |
sql_statement (hazelcast_client &client, std::string query) | |
Creates a statement with the given query. More... | |
const std::string & | sql () const |
sql_statement & | sql (std::string sql_string) |
Sets the SQL string to be executed. More... | |
template<typename... Param> | |
sql_statement & | set_parameters (Param... params) |
Sets the values for statement parameters. More... | |
template<typename Param > | |
sql_statement & | add_parameter (const Param &value) |
Adds a single parameter value to the end of the parameter values list. More... | |
sql_statement & | clear_parameters () |
Clears statement parameter values. More... | |
int32_t | cursor_buffer_size () const |
Gets the cursor buffer size (measured in the number of rows). More... | |
sql_statement & | cursor_buffer_size (int32_t size) |
Sets the cursor buffer size (measured in the number of rows). More... | |
std::chrono::milliseconds | timeout () const |
Gets the execution timeout in milliseconds. More... | |
sql_statement & | timeout (std::chrono::milliseconds timeout) |
Sets the execution timeout in milliseconds. More... | |
sql_expected_result_type | expected_result_type () const |
Gets the expected result type. More... | |
sql_statement & | expected_result_type (sql_expected_result_type type) |
Sets the expected result type. More... | |
const boost::optional< std::string > & | schema () const |
Gets the schema name. More... | |
sql_statement & | schema (boost::optional< std::string > schema) |
Sets the schema name. More... | |
Static Public Attributes | |
static constexpr std::chrono::milliseconds | TIMEOUT_NOT_SET { -1 } |
Value for the timeout that is not set. More... | |
static constexpr std::chrono::milliseconds | TIMEOUT_DISABLED { 0 } |
Value for the timeout that is disabled, meaning there's no time limit to run a query. | |
static constexpr std::chrono::milliseconds | DEFAULT_TIMEOUT |
Default timeout. More... | |
static constexpr int32_t | DEFAULT_CURSOR_BUFFER_SIZE = 4096 |
Default cursor buffer size. | |
Definition of an SQL statement.
This object is mutable. Properties are read once before the execution is started. Changes to properties do not affect the behavior of already running statements.
Definition at line 41 of file sql_statement.h.
hazelcast::client::sql::sql_statement::sql_statement | ( | hazelcast_client & | client, |
std::string | query | ||
) |
Creates a statement with the given query.
client | The hazelcast client to be used for the statement. |
query | The query string. |
Definition at line 337 of file sql.cpp.
sql_statement & hazelcast::client::sql::sql_statement::add_parameter | ( | const Param & | value | ) |
Adds a single parameter value to the end of the parameter values list.
value | parameter value |
Definition at line 241 of file sql_statement.h.
sql_statement & hazelcast::client::sql::sql_statement::clear_parameters | ( | ) |
Clears statement parameter values.
int32_t hazelcast::client::sql::sql_statement::cursor_buffer_size | ( | ) | const |
sql_statement & hazelcast::client::sql::sql_statement::cursor_buffer_size | ( | int32_t | size | ) |
Sets the cursor buffer size (measured in the number of rows).
When a statement is submitted for execution, a sql_result is returned as a result. When rows are ready to be consumed, they are put into an internal buffer of the cursor. This parameter defines the maximum number of rows in that buffer. When the threshold is reached, the backpressure mechanism will slow down the execution, possibly to a complete halt, to prevent out-of-memory.
Only positive values are allowed.
The default value is expected to work well for most workloads. A bigger buffer size may give you a slight performance boost for queries with large result sets at the cost of increased memory consumption.
Defaults to sql_statement::DEFAULT_CURSOR_BUFFER_SIZE.
size | cursor buffer size (measured in the number of rows) |
sql::sql_expected_result_type hazelcast::client::sql::sql_statement::expected_result_type | ( | ) | const |
sql_statement& hazelcast::client::sql::sql_statement::expected_result_type | ( | sql_expected_result_type | type | ) |
Sets the expected result type.
type | expected result type |
const boost::optional< std::string > & hazelcast::client::sql::sql_statement::schema | ( | ) | const |
sql_statement & hazelcast::client::sql::sql_statement::schema | ( | boost::optional< std::string > | schema | ) |
Sets the schema name.
The engine will try to resolve the non-qualified object identifiers from the statement in the given schema. If not found, the default search path will be used, which looks for objects in the predefined schemas
and
.
The schema name is case sensitive. For example,
and
are different schemas.
The default value is
meaning only the default search path is used.
schema | the current schema name |
Definition at line 432 of file sql.cpp.
sql_statement & hazelcast::client::sql::sql_statement::set_parameters | ( | Param... | params | ) |
Sets the values for statement parameters.
You may define parameter placeholders in the statement with the
character. For every placeholder, a value must be provided.
When the method is called, the contents of the list are copied. Subsequent changes to the original list don't change the statement parameters.
value | the first statement parameter |
other_params | the other statement parameters if exist |
Definition at line 250 of file sql_statement.h.
const std::string & hazelcast::client::sql::sql_statement::sql | ( | ) | const |
sql_statement & hazelcast::client::sql::sql_statement::sql | ( | std::string | sql_string | ) |
Sets the SQL string to be executed.
The SQL string cannot be empty.
sql_string | SQL string |
hazelcast::client::exception::illegal_argument | if passed SQL string is empty |
std::chrono::milliseconds hazelcast::client::sql::sql_statement::timeout | ( | ) | const |
sql_statement & hazelcast::client::sql::sql_statement::timeout | ( | std::chrono::milliseconds | timeout | ) |
Sets the execution timeout in milliseconds.
If the timeout is reached for a running statement, it will be cancelled forcefully.
Zero value means no timeout. sql_statement::TIMEOUT_NOT_SET means that the value from sql_config::statement_timeout() will be used. Other negative values are prohibited.
Defaults to sql_statement::TIMEOUT_NOT_SET .
timeout | execution timeout in milliseconds, \c0 for no timeout, -1 to user member's default timeout |
Definition at line 409 of file sql.cpp.
|
staticconstexpr |
|
staticconstexpr |
Value for the timeout that is not set.
The value of sql_config::statement_timeout_millis will be used.
Definition at line 48 of file sql_statement.h.