Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ Also check the changes in springql-core: <https://github.com/SpringQL/SpringQL/b
<!-- markdownlint-disable MD024 -->
## [Unreleased]

## [v0.14.0] - 2022-06-24

### Changed

- `SpringRow` into `SpringSinkRow` ([#50](https://github.com/SpringQL/SpringQL-client-c/pull/50))
- `spring_row_close` -> `spring_sink_row_close` ([#50](https://github.com/SpringQL/SpringQL-client-c/pull/50))

### Added

- Following new APIs: ([#50](https://github.com/SpringQL/SpringQL-client-c/pull/50))
- `SpringSourceRow`
- `spring_source_row_from_json`
- `spring_source_row_close`

## [v0.13.0+4]

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "springql-client-c"
version = "0.13.0+4"
version = "0.14.0"

authors = ["Sho Nakatani <lay.sakura@gmail.com>"]
license = "MIT OR Apache-2.0"
Expand All @@ -15,6 +15,6 @@ name = "springql_client"
cbindgen = "0.24"

[dependencies]
springql-core = "0.13.0"
springql = "0.14.0"

log = "0.4"
4 changes: 2 additions & 2 deletions c_example/doc_app1/doc_app1.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int main()

fprintf(stderr, "waiting JSON records in tcp/54300...\n");

SpringRow *row;
SpringSinkRow *row;
while (1)
{
row = spring_pop(pipeline, "q");
Expand All @@ -108,7 +108,7 @@ int main()
assert_ok(ret);

fprintf(stderr, "%s\t%f\n", ts, temperature_fahrenheit);
spring_row_close(row);
spring_sink_row_close(row);
}

ret = spring_close(pipeline);
Expand Down
6 changes: 3 additions & 3 deletions c_example/doc_app2/doc_app2.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int main()

fprintf(stderr, "waiting JSON records in tcp/54300...\n");

SpringRow *row;
SpringSinkRow *row;
bool is_err = false;
while (1)
{
Expand All @@ -159,7 +159,7 @@ int main()
assert_ok(ret);

fprintf(stderr, "[q_avg_all] %s\t%f\n", ts, avg_amount);
spring_row_close(row);
spring_sink_row_close(row);
}
else
{
Expand All @@ -182,7 +182,7 @@ int main()
assert_ok(ret);

fprintf(stderr, "[q_avg_by_symbol] %s\t%s\t%f\n", ts, symbol, avg_amount);
spring_row_close(row);
spring_sink_row_close(row);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions c_example/trade_projection/trade_projection.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void pop_print(const SpringPipeline *pipeline)
{
SpringErrno ret;

SpringRow *row = spring_pop(pipeline, "q_sink_trade");
SpringSinkRow *row = spring_pop(pipeline, "q_sink_trade");
assert_not_null(row);

int r = spring_column_text(row, 0, (char *)ts, TS_LEN);
Expand All @@ -103,7 +103,7 @@ void pop_print(const SpringPipeline *pipeline)

printf("[row#%d] ts=%s amount=%d\n", i, ts, amount);

spring_row_close(row);
spring_sink_row_close(row);
}
}

Expand Down
73 changes: 57 additions & 16 deletions springql.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ typedef void *SpringConfig;
typedef void *SpringPipeline;

/**
* Row object from an in memory queue.
* Row object to pop from an in memory queue.
*/
typedef void *SpringRow;
typedef void *SpringSinkRow;

/**
* Row object to push into an in memory queue.
*/
typedef void *SpringSourceRow;

/**
* Returns default configuration.
Expand Down Expand Up @@ -146,7 +151,7 @@ enum SpringErrno spring_command(const SpringPipeline *pipeline, const char *sql)
*
* - `Unavailable`: queue named `queue` does not exist.
*/
SpringRow *spring_pop(const SpringPipeline *pipeline, const char *queue);
SpringSinkRow *spring_pop(const SpringPipeline *pipeline, const char *queue);

/**
* Pop a row from an in memory queue. This is a non-blocking function.
Expand All @@ -160,19 +165,55 @@ SpringRow *spring_pop(const SpringPipeline *pipeline, const char *queue);
*
* - `Unavailable`: queue named `queue` does not exist.
*/
SpringRow *spring_pop_non_blocking(const SpringPipeline *pipeline,
const char *queue,
bool *is_err);
SpringSinkRow *spring_pop_non_blocking(const SpringPipeline *pipeline,
const char *queue,
bool *is_err);

/**
* Push a row into an in memory queue. This is a non-blocking function.
*
* # Returns
*
* - `Ok`: on success.
* - `Unavailable`: queue named `queue` does not exist.
*/
enum SpringErrno spring_push(const SpringPipeline *pipeline,
const char *queue,
const SpringSourceRow *row);

/**
* Create a source row from JSON string
*
* # Returns
*
* - non-NULL: Successfully created a row.
* - NULL: Error occurred.
*
* # Errors
*
* - `InvalidFormat`: JSON string is invalid.
*/
SpringSourceRow *spring_source_row_from_json(const char *json);

/**
* Frees heap occupied by a `SpringSourceRow`.
*
* # Returns
*
* - `Ok`: on success.
* - `CNull`: `pipeline` is a NULL pointer.
*/
enum SpringErrno spring_source_row_close(SpringSourceRow *row);

/**
* Frees heap occupied by a `SpringRow`.
* Frees heap occupied by a `SpringSinkRow`.
*
* # Returns
*
* - `Ok`: on success.
* - `CNull`: `pipeline` is a NULL pointer.
*/
enum SpringErrno spring_row_close(SpringRow *row);
enum SpringErrno spring_sink_row_close(SpringSinkRow *row);

/**
* Get a 2-byte integer column.
Expand All @@ -191,7 +232,7 @@ enum SpringErrno spring_row_close(SpringRow *row);
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
enum SpringErrno spring_column_short(const SpringRow *row, uint16_t i_col, short *out);
enum SpringErrno spring_column_short(const SpringSinkRow *row, uint16_t i_col, short *out);

/**
* Get a 4-byte integer column.
Expand All @@ -210,7 +251,7 @@ enum SpringErrno spring_column_short(const SpringRow *row, uint16_t i_col, short
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
enum SpringErrno spring_column_int(const SpringRow *row, uint16_t i_col, int *out);
enum SpringErrno spring_column_int(const SpringSinkRow *row, uint16_t i_col, int *out);

/**
* Get an 8-byte integer column.
Expand All @@ -229,7 +270,7 @@ enum SpringErrno spring_column_int(const SpringRow *row, uint16_t i_col, int *ou
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
enum SpringErrno spring_column_long(const SpringRow *row, uint16_t i_col, long *out);
enum SpringErrno spring_column_long(const SpringSinkRow *row, uint16_t i_col, long *out);

/**
* Get a 4-byte unsigned integer column.
Expand All @@ -248,7 +289,7 @@ enum SpringErrno spring_column_long(const SpringRow *row, uint16_t i_col, long *
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
enum SpringErrno spring_column_unsigned_int(const SpringRow *row,
enum SpringErrno spring_column_unsigned_int(const SpringSinkRow *row,
uint16_t i_col,
unsigned int *out);

Expand All @@ -270,7 +311,7 @@ enum SpringErrno spring_column_unsigned_int(const SpringRow *row,
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
int spring_column_text(const SpringRow *row, uint16_t i_col, char *out, int out_len);
int spring_column_text(const SpringSinkRow *row, uint16_t i_col, char *out, int out_len);

/**
* Get a BLOB column.
Expand All @@ -290,7 +331,7 @@ int spring_column_text(const SpringRow *row, uint16_t i_col, char *out, int out_
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
int spring_column_blob(const SpringRow *row, uint16_t i_col, void *out, int out_len);
int spring_column_blob(const SpringSinkRow *row, uint16_t i_col, void *out, int out_len);

/**
* Get a bool column.
Expand All @@ -309,7 +350,7 @@ int spring_column_blob(const SpringRow *row, uint16_t i_col, void *out, int out_
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
enum SpringErrno spring_column_bool(const SpringRow *row, uint16_t i_col, bool *out);
enum SpringErrno spring_column_bool(const SpringSinkRow *row, uint16_t i_col, bool *out);

/**
* Get a 4-byte floating point column.
Expand All @@ -328,7 +369,7 @@ enum SpringErrno spring_column_bool(const SpringRow *row, uint16_t i_col, bool *
* - `i_col` is out of range.
* - `CNull`: Column value is NULL.
*/
enum SpringErrno spring_column_float(const SpringRow *row, uint16_t i_col, float *out);
enum SpringErrno spring_column_float(const SpringSinkRow *row, uint16_t i_col, float *out);

/**
* Write the most recent error number into `errno` and message into a caller-provided buffer as a UTF-8
Expand Down
Loading