@@ -32,6 +32,9 @@ struct TypeListBuilder {
3232};
3333
3434std::unique_ptr<TypeListBuilder> create_type_list ();
35+ inline void type_list_insert (TypeListBuilder& list, std::unique_ptr<lbug::common::LogicalType> type) {
36+ list.insert (std::move (type));
37+ }
3538
3639struct QueryParams {
3740 std::unordered_map<std::string, std::unique_ptr<lbug::common::Value>> inputParams;
@@ -42,6 +45,10 @@ struct QueryParams {
4245};
4346
4447std::unique_ptr<QueryParams> new_params ();
48+ inline void query_params_insert (QueryParams& params, const rust::Str key,
49+ std::unique_ptr<lbug::common::Value> value) {
50+ params.insert (key, std::move (value));
51+ }
4552
4653std::unique_ptr<lbug::common::LogicalType> create_logical_type (lbug::common::LogicalTypeID id);
4754std::unique_ptr<lbug::common::LogicalType> create_logical_type_list (
@@ -93,6 +100,10 @@ inline uint32_t logical_type_get_decimal_precision(const lbug::common::LogicalTy
93100inline uint32_t logical_type_get_decimal_scale (const lbug::common::LogicalType& logicalType) {
94101 return lbug::common::DecimalType::getScale (logicalType);
95102}
103+ inline lbug::common::LogicalTypeID logical_type_get_logical_type_id (
104+ const lbug::common::LogicalType& logicalType) {
105+ return logicalType.getLogicalTypeID ();
106+ }
96107
97108/* Database */
98109std::unique_ptr<lbug::main::Database> new_database (std::string_view databasePath,
@@ -110,20 +121,56 @@ inline std::unique_ptr<lbug::main::QueryResult> connection_query(lbug::main::Con
110121 std::string_view query) {
111122 return connection.query (query);
112123}
124+ inline std::unique_ptr<lbug::main::PreparedStatement> connection_prepare (
125+ lbug::main::Connection& connection, std::string_view query) {
126+ return connection.prepare (query);
127+ }
128+ inline uint64_t connection_get_max_num_thread_for_exec (lbug::main::Connection& connection) {
129+ return connection.getMaxNumThreadForExec ();
130+ }
131+ inline void connection_set_max_num_thread_for_exec (lbug::main::Connection& connection,
132+ uint64_t numThreads) {
133+ connection.setMaxNumThreadForExec (numThreads);
134+ }
135+ inline void connection_interrupt (lbug::main::Connection& connection) {
136+ connection.interrupt ();
137+ }
138+ inline void connection_set_query_timeout (lbug::main::Connection& connection, uint64_t timeoutMs) {
139+ connection.setQueryTimeOut (timeoutMs);
140+ }
113141
114142/* PreparedStatement */
115143rust::String prepared_statement_error_message (const lbug::main::PreparedStatement& statement);
116144inline lbug::common::StatementType prepared_statement_get_statement_type (
117145 const lbug::main::PreparedStatement& statement) {
118146 return statement.getStatementType ();
119147}
148+ inline bool prepared_statement_is_success (const lbug::main::PreparedStatement& statement) {
149+ return statement.isSuccess ();
150+ }
120151
121152/* QueryResult */
122153rust::String query_result_to_string (const lbug::main::QueryResult& result);
123154rust::String query_result_get_error_message (const lbug::main::QueryResult& result);
155+ inline bool query_result_is_success (const lbug::main::QueryResult& result) {
156+ return result.isSuccess ();
157+ }
158+ inline bool query_result_has_next (const lbug::main::QueryResult& result) {
159+ return result.hasNext ();
160+ }
161+ inline std::shared_ptr<lbug::processor::FlatTuple> query_result_get_next (
162+ lbug::main::QueryResult& result) {
163+ return result.getNext ();
164+ }
124165
125166double query_result_get_compiling_time (const lbug::main::QueryResult& result);
126167double query_result_get_execution_time (const lbug::main::QueryResult& result);
168+ inline size_t query_result_get_num_columns (const lbug::main::QueryResult& result) {
169+ return result.getNumColumns ();
170+ }
171+ inline uint64_t query_result_get_num_tuples (const lbug::main::QueryResult& result) {
172+ return result.getNumTuples ();
173+ }
127174
128175std::unique_ptr<std::vector<lbug::common::LogicalType>> query_result_column_data_types (
129176 const lbug::main::QueryResult& query_result);
@@ -156,6 +203,7 @@ const lbug::common::Value& recursive_rel_get_nodes(const lbug::common::Value& va
156203const lbug::common::Value& recursive_rel_get_rels (const lbug::common::Value& val);
157204
158205/* FlatTuple */
206+ uint32_t flat_tuple_len (const lbug::processor::FlatTuple& flatTuple);
159207const lbug::common::Value& flat_tuple_get_value (const lbug::processor::FlatTuple& flatTuple,
160208 uint32_t index);
161209
@@ -185,6 +233,42 @@ inline lbug::common::PhysicalTypeID value_get_physical_type(const lbug::common::
185233 return value.getDataType ().getPhysicalType ();
186234}
187235rust::String value_to_string (const lbug::common::Value& val);
236+ inline bool value_get_bool (const lbug::common::Value& value) {
237+ return value.getValue <bool >();
238+ }
239+ inline int8_t value_get_i8 (const lbug::common::Value& value) {
240+ return value.getValue <int8_t >();
241+ }
242+ inline int16_t value_get_i16 (const lbug::common::Value& value) {
243+ return value.getValue <int16_t >();
244+ }
245+ inline int32_t value_get_i32 (const lbug::common::Value& value) {
246+ return value.getValue <int32_t >();
247+ }
248+ inline int64_t value_get_i64 (const lbug::common::Value& value) {
249+ return value.getValue <int64_t >();
250+ }
251+ inline uint8_t value_get_u8 (const lbug::common::Value& value) {
252+ return value.getValue <uint8_t >();
253+ }
254+ inline uint16_t value_get_u16 (const lbug::common::Value& value) {
255+ return value.getValue <uint16_t >();
256+ }
257+ inline uint32_t value_get_u32 (const lbug::common::Value& value) {
258+ return value.getValue <uint32_t >();
259+ }
260+ inline uint64_t value_get_u64 (const lbug::common::Value& value) {
261+ return value.getValue <uint64_t >();
262+ }
263+ inline float value_get_float (const lbug::common::Value& value) {
264+ return value.getValue <float >();
265+ }
266+ inline double value_get_double (const lbug::common::Value& value) {
267+ return value.getValue <double >();
268+ }
269+ inline bool value_is_null (const lbug::common::Value& value) {
270+ return value.isNull ();
271+ }
188272
189273std::unique_ptr<lbug::common::Value> create_value_string (lbug::common::LogicalTypeID typ,
190274 const rust::Slice<const unsigned char > value);
@@ -237,6 +321,9 @@ struct ValueListBuilder {
237321std::unique_ptr<lbug::common::Value> get_list_value (std::unique_ptr<lbug::common::LogicalType> typ,
238322 std::unique_ptr<ValueListBuilder> value);
239323std::unique_ptr<ValueListBuilder> create_list ();
324+ inline void value_list_insert (ValueListBuilder& list, std::unique_ptr<lbug::common::Value> value) {
325+ list.insert (std::move (value));
326+ }
240327
241328inline std::string_view string_view_from_str (rust::Str s) {
242329 return {s.data (), s.size ()};
0 commit comments