| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Small timeseries database written in C, designed to efficiently store and retrieve timestamped data records. Mostly to explore persistent log data structure applications.
Still at a very early stage, the main concepts are
At the current stage, no server attached, just a tiny library with some crude APIs;
Plus a few other helpers.
Build the libtimeseries.so first
makeIn the target project, a generic hello world
#include <stdio.h>
#include "timeseries.h"
int main(void) {
// Example usage of timeseries library functions
Timeseries_DB *db = tsdb_init("example_ts");
// Use timeseries functions...
tsdb_close(db);
return 0;
}Build it linking the library
gcc -o my_project main.c -I/path/to/timeseries/include -L/path/to/timeseries -ltimeseriesTo run it
LD_LIBRARY_PATH=/path/to/timeseries.so ./my_project#include "timeseries.h"
int main() {
// Initialize the database
Timeseries_DB *db = tsdb_init("testdb");
if (!db)
abort();
// Create a timeseries, retention is not implemented yet
Timeseries *ts = ts_create(db, "temperatures", 0, DP_IGNORE);
if (!ts)
abort();
// Insert records into the timeseries
ts_insert(ts, 1710033421702081792, 25.5);
ts_insert(ts, 1710033422047657984, 26.0);
// Find a record by timestamp
Record r;
int result = ts_find(ts, 1710033422047657984, &r);
if (result == 0) {
printf("Record found: timestamp=%lu, value=%.2lf\n", r.timestamp, r.value);
} else {
printf("Record not found.\n");
}
// Release the timeseries
ts_close(ts);
// Close the database
tsdb_close(db);
return 0;
}Event based server (rely on ev at least initially), TCP as the main transport protocol, text-based custom protocol inspired by RESP but simpler.
Definition of a simple, text-based format for clients to interact with the server, allowing them to send commands and receive responses.
Define the basic operations in a SQL-like query language
CREATE creates a database or a timeseries
CREATE <database name>
CREATE <timeseries name> INTO <database name> [<retention period>] [<duplication policy>]
INSERT insertion of point(s) in a timeseries
INSERT <timeseries name> INTO <database name> <timestamp | *> <value>, ...
SELECT query a timeseries, selection of point(s) and aggregations
SELECT <timeseries name> FROM <database name> RANGE <start_timestamp> TO <end_timestamp> WHERE value [>|<|=|<=|>=|!=] <literal> AGGREGATE [AVG|MIN|MAX] BY <literal>
DELETE delete a timeseries or a database
DELETE <database name> DELETE <timeseries name> FROM <database name>
Client Sends Command: Clients send commands to the server in the specified text format.
Server Parses Command: The server parses the received command and executes the corresponding operation on the timeseries database.
Server Sends Response: After processing the command, the server sends a response back to the client indicating the result of the operation or providing requested data.
Client Processes Response: Clients receive and process the response from the server, handling success or error conditions accordingly.
| Back | FazBrowse Home | New Git URL |