Skip to content

Commit

Permalink
add datatypes for api
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashleyhx committed Sep 29, 2023
1 parent 9cc01df commit 1f191f9
Show file tree
Hide file tree
Showing 14 changed files with 648 additions and 20 deletions.
30 changes: 30 additions & 0 deletions src/c_api/prepared_statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,36 @@ void kuzu_prepared_statement_bind_int16(
kuzu_prepared_statement_bind_cpp_value(prepared_statement, param_name, value_ptr);
}

void kuzu_prepared_statement_bind_int8(

Check warning on line 75 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L75

Added line #L75 was not covered by tests
kuzu_prepared_statement* prepared_statement, const char* param_name, int8_t value) {
auto value_ptr = std::make_shared<Value>(value);
kuzu_prepared_statement_bind_cpp_value(prepared_statement, param_name, value_ptr);
}

Check warning on line 79 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L78-L79

Added lines #L78 - L79 were not covered by tests

void kuzu_prepared_statement_bind_uint64(

Check warning on line 81 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L81

Added line #L81 was not covered by tests
kuzu_prepared_statement* prepared_statement, const char* param_name, uint64_t value) {
auto value_ptr = std::make_shared<Value>(value);
kuzu_prepared_statement_bind_cpp_value(prepared_statement, param_name, value_ptr);
}

Check warning on line 85 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L84-L85

Added lines #L84 - L85 were not covered by tests

void kuzu_prepared_statement_bind_uint32(

Check warning on line 87 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L87

Added line #L87 was not covered by tests
kuzu_prepared_statement* prepared_statement, const char* param_name, uint32_t value) {
auto value_ptr = std::make_shared<Value>(value);
kuzu_prepared_statement_bind_cpp_value(prepared_statement, param_name, value_ptr);
}

Check warning on line 91 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L90-L91

Added lines #L90 - L91 were not covered by tests

void kuzu_prepared_statement_bind_uint16(

Check warning on line 93 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L93

Added line #L93 was not covered by tests
kuzu_prepared_statement* prepared_statement, const char* param_name, uint16_t value) {
auto value_ptr = std::make_shared<Value>(value);
kuzu_prepared_statement_bind_cpp_value(prepared_statement, param_name, value_ptr);
}

Check warning on line 97 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L96-L97

Added lines #L96 - L97 were not covered by tests

void kuzu_prepared_statement_bind_uint8(

Check warning on line 99 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L99

Added line #L99 was not covered by tests
kuzu_prepared_statement* prepared_statement, const char* param_name, uint8_t value) {
auto value_ptr = std::make_shared<Value>(value);
kuzu_prepared_statement_bind_cpp_value(prepared_statement, param_name, value_ptr);
}

Check warning on line 103 in src/c_api/prepared_statement.cpp

View check run for this annotation

Codecov / codecov/patch

src/c_api/prepared_statement.cpp#L102-L103

Added lines #L102 - L103 were not covered by tests

void kuzu_prepared_statement_bind_double(
kuzu_prepared_statement* prepared_statement, const char* param_name, double value) {
auto value_ptr = std::make_shared<Value>(value);
Expand Down
50 changes: 50 additions & 0 deletions src/c_api/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ kuzu_value* kuzu_value_create_bool(bool val_) {
return c_value;
}

kuzu_value* kuzu_value_create_int8(int8_t val_) {
auto* c_value = (kuzu_value*)calloc(1, sizeof(kuzu_value));
c_value->_value = new Value(val_);
return c_value;
}

kuzu_value* kuzu_value_create_int16(int16_t val_) {
auto* c_value = (kuzu_value*)calloc(1, sizeof(kuzu_value));
c_value->_value = new Value(val_);
Expand All @@ -64,6 +70,30 @@ kuzu_value* kuzu_value_create_int64(int64_t val_) {
return c_value;
}

kuzu_value* kuzu_value_create_uint8(uint8_t val_) {
auto* c_value = (kuzu_value*)calloc(1, sizeof(kuzu_value));
c_value->_value = new Value(val_);
return c_value;
}

kuzu_value* kuzu_value_create_uint16(uint16_t val_) {
auto* c_value = (kuzu_value*)calloc(1, sizeof(kuzu_value));
c_value->_value = new Value(val_);
return c_value;
}

kuzu_value* kuzu_value_create_uint32(uint32_t val_) {
auto* c_value = (kuzu_value*)calloc(1, sizeof(kuzu_value));
c_value->_value = new Value(val_);
return c_value;
}

kuzu_value* kuzu_value_create_uint64(uint64_t val_) {
auto* c_value = (kuzu_value*)calloc(1, sizeof(kuzu_value));
c_value->_value = new Value(val_);
return c_value;
}

kuzu_value* kuzu_value_create_float(float val_) {
auto* c_value = (kuzu_value*)calloc(1, sizeof(kuzu_value));
c_value->_value = new Value(val_);
Expand Down Expand Up @@ -189,6 +219,10 @@ bool kuzu_value_get_bool(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<bool>();
}

int8_t kuzu_value_get_int8(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<int8_t>();
}

int16_t kuzu_value_get_int16(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<int16_t>();
}
Expand All @@ -201,6 +235,22 @@ int64_t kuzu_value_get_int64(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<int64_t>();
}

uint8_t kuzu_value_get_uint8(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<uint8_t>();
}

uint16_t kuzu_value_get_uint16(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<uint16_t>();
}

uint32_t kuzu_value_get_uint32(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<uint32_t>();
}

uint64_t kuzu_value_get_uint64(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<uint64_t>();
}

float kuzu_value_get_float(kuzu_value* value) {
return static_cast<Value*>(value->_value)->getValue<float>();
}
Expand Down
101 changes: 101 additions & 0 deletions src/include/c_api/kuzu.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ KUZU_C_API typedef enum {
KUZU_INT64 = 23,
KUZU_INT32 = 24,
KUZU_INT16 = 25,
KUZU_INT8 = 26,
KUZU_UINT64 = 27,
KUZU_UINT32 = 28,
KUZU_UINT16 = 29,
KUZU_UINT8 = 30,
KUZU_DOUBLE = 32,
KUZU_FLOAT = 33,
KUZU_DATE = 34,
Expand Down Expand Up @@ -342,6 +347,46 @@ KUZU_C_API void kuzu_prepared_statement_bind_int32(
*/
KUZU_C_API void kuzu_prepared_statement_bind_int16(
kuzu_prepared_statement* prepared_statement, const char* param_name, int16_t value);
/**
* @brief Binds the given int8_t value to the given parameter name in the prepared statement.
* @param prepared_statement The prepared statement instance to bind the value.
* @param param_name The parameter name to bind the value.
* @param value The int8_t value to bind.
*/
KUZU_C_API void kuzu_prepared_statement_bind_int8(
kuzu_prepared_statement* prepared_statement, const char* param_name, int8_t value);
/**
* @brief Binds the given uint64_t value to the given parameter name in the prepared statement.
* @param prepared_statement The prepared statement instance to bind the value.
* @param param_name The parameter name to bind the value.
*/
KUZU_C_API void kuzu_prepared_statement_bind_uint64(
kuzu_prepared_statement* prepared_statement, const char* param_name, uint64_t value);
/**
* @brief Binds the given uint32_t value to the given parameter name in the prepared statement.
* @param prepared_statement The prepared statement instance to bind the value.
* @param param_name The parameter name to bind the value.
* @param value The uint32_t value to bind.
*/
KUZU_C_API void kuzu_prepared_statement_bind_uint32(
kuzu_prepared_statement* prepared_statement, const char* param_name, uint32_t value);
/**
* @brief Binds the given uint16_t value to the given parameter name in the prepared statement.
* @param prepared_statement The prepared statement instance to bind the value.
* @param param_name The parameter name to bind the value.
* @param value The uint16_t value to bind.
*/
KUZU_C_API void kuzu_prepared_statement_bind_uint16(
kuzu_prepared_statement* prepared_statement, const char* param_name, uint16_t value);
/**
* @brief Binds the given int8_t value to the given parameter name in the prepared statement.
* @param prepared_statement The prepared statement instance to bind the value.
* @param param_name The parameter name to bind the value.
* @param value The int8_t value to bind.
*/
KUZU_C_API void kuzu_prepared_statement_bind_uint8(
kuzu_prepared_statement* prepared_statement, const char* param_name, uint8_t value);

/**
* @brief Binds the given double value to the given parameter name in the prepared statement.
* @param prepared_statement The prepared statement instance to bind the value.
Expand Down Expand Up @@ -586,6 +631,12 @@ KUZU_C_API kuzu_value* kuzu_value_create_default(kuzu_logical_type* data_type);
* @param val_ The bool value of the value to create.
*/
KUZU_C_API kuzu_value* kuzu_value_create_bool(bool val_);
/**
* @brief Creates a value with int8 type and the given int8 value. Caller is responsible for
* destroying the returned value.
* @param val_ The int8 value of the value to create.
*/
KUZU_C_API kuzu_value* kuzu_value_create_int8(int8_t val_);
/**
* @brief Creates a value with int16 type and the given int16 value. Caller is responsible for
* destroying the returned value.
Expand All @@ -604,6 +655,30 @@ KUZU_C_API kuzu_value* kuzu_value_create_int32(int32_t val_);
* @param val_ The int64 value of the value to create.
*/
KUZU_C_API kuzu_value* kuzu_value_create_int64(int64_t val_);
/**
* @brief Creates a value with uint8 type and the given uint8 value. Caller is responsible for
* destroying the returned value.
* @param val_ The uint8 value of the value to create.
*/
KUZU_C_API kuzu_value* kuzu_value_create_uint8(uint8_t val_);
/**
* @brief Creates a value with uint16 type and the given uint16 value. Caller is responsible for
* destroying the returned value.
* @param val_ The uint16 value of the value to create.
*/
KUZU_C_API kuzu_value* kuzu_value_create_uint16(uint16_t val_);
/**
* @brief Creates a value with uint32 type and the given uint32 value. Caller is responsible for
* destroying the returned value.
* @param val_ The uint32 value of the value to create.
*/
KUZU_C_API kuzu_value* kuzu_value_create_uint32(uint32_t val_);
/**
* @brief Creates a value with uint64 type and the given uint64 value. Caller is responsible for
* destroying the returned value.
* @param val_ The uint64 value of the value to create.
*/
KUZU_C_API kuzu_value* kuzu_value_create_uint64(uint64_t val_);
/**
* @brief Creates a value with float type and the given float value. Caller is responsible for
* destroying the returned value.
Expand Down Expand Up @@ -715,6 +790,12 @@ KUZU_C_API kuzu_logical_type* kuzu_value_get_data_type(kuzu_value* value);
* @param value The value to return.
*/
KUZU_C_API bool kuzu_value_get_bool(kuzu_value* value);

/**
* @brief Returns the int8 value of the given value. The value must be of type INT8.
* @param value The value to return.
*/
KUZU_C_API int8_t kuzu_value_get_int8(kuzu_value* value);
/**
* @brief Returns the int16 value of the given value. The value must be of type INT16.
* @param value The value to return.
Expand All @@ -730,6 +811,26 @@ KUZU_C_API int32_t kuzu_value_get_int32(kuzu_value* value);
* @param value The value to return.
*/
KUZU_C_API int64_t kuzu_value_get_int64(kuzu_value* value);
/**
* @brief Returns the uint8 value of the given value. The value must be of type UINT8.
* @param value The value to return.
*/
KUZU_C_API uint8_t kuzu_value_get_uint8(kuzu_value* value);
/**
* @brief Returns the uint16 value of the given value. The value must be of type UINT16.
* @param value The value to return.
*/
KUZU_C_API uint16_t kuzu_value_get_uint16(kuzu_value* value);
/**
* @brief Returns the uint32 value of the given value. The value must be of type UINT32.
* @param value The value to return.
*/
KUZU_C_API uint32_t kuzu_value_get_uint32(kuzu_value* value);
/**
* @brief Returns the uint64 value of the given value. The value must be of type UINT64.
* @param value The value to return.
*/
KUZU_C_API uint64_t kuzu_value_get_uint64(kuzu_value* value);
/**
* @brief Returns the float value of the given value. The value must be of type FLOAT.
* @param value The value to return.
Expand Down
Loading

0 comments on commit 1f191f9

Please sign in to comment.