Apache Ignite C++ Client
Loading...
Searching...
No Matches
sql.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
21#include "ignite/client/sql/result_set.h"
22#include "ignite/client/sql/sql_statement.h"
23#include "ignite/client/transaction/transaction.h"
24#include "ignite/common/detail/config.h"
25#include "ignite/common/ignite_result.h"
26#include "ignite/common/primitive.h"
27
28#include <memory>
29#include <utility>
30
31namespace ignite {
32
33namespace detail {
34class sql_impl;
35}
36
40class sql {
41 friend class ignite_client;
42
43public:
44 // Delete
45 sql() = delete;
46
56 IGNITE_API void execute_async(transaction *tx, cancellation_token *token, const sql_statement &statement,
57 std::vector<primitive> args, ignite_callback<result_set> callback);
58
68 IGNITE_API result_set execute(transaction *tx, cancellation_token *token, const sql_statement &statement,
69 std::vector<primitive> args) {
70 return sync<result_set>(
71 [this, tx, token, &statement, args = std::move(args)](auto callback) mutable {
72 execute_async(tx, token, statement, std::move(args), std::move(callback));
73 }
74 );
75 }
76
85 IGNITE_API void execute_script_async(cancellation_token *token, const sql_statement &statement,
86 std::vector<primitive> args, ignite_callback<void> callback);
87
95 IGNITE_API void execute_script(cancellation_token *token, const sql_statement &statement,
96 std::vector<primitive> args) {
97 sync<void>([this, token, &statement, args = std::move(args)](auto callback) mutable {
98 execute_script_async(token, statement, std::move(args), std::move(callback));
99 });
100 }
101
102private:
108 explicit sql(std::shared_ptr<detail::sql_impl> impl)
109 : m_impl(std::move(impl)) {}
110
112 std::shared_ptr<detail::sql_impl> m_impl;
113};
114
115} // namespace ignite
Definition cancellation_token.h:33
Definition result_set.h:37
Definition sql_statement.h:32
Definition sql.h:40
IGNITE_API void execute_script(cancellation_token *token, const sql_statement &statement, std::vector< primitive > args)
Definition sql.h:95
IGNITE_API void execute_async(transaction *tx, cancellation_token *token, const sql_statement &statement, std::vector< primitive > args, ignite_callback< result_set > callback)
Definition sql.cpp:23
IGNITE_API void execute_script_async(cancellation_token *token, const sql_statement &statement, std::vector< primitive > args, ignite_callback< void > callback)
Definition sql.cpp:28
IGNITE_API result_set execute(transaction *tx, cancellation_token *token, const sql_statement &statement, std::vector< primitive > args)
Definition sql.h:68
Definition transaction.h:35