Skip to content

Commit d26d2ce

Browse files
authored
Merge pull request #294 from chdb-io/patchset-3.0
Patchset 3.0
2 parents e5fbb15 + d7cdddf commit d26d2ce

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

README-zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
## 架构
3232
<div align="center">
33-
<img src="docs/_static/arch-chdb2.png" width="450">
33+
<img src="docs/_static/arch-chdb3.png" width="450">
3434
</div>
3535

3636
## 安装方式

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
## Arch
3535
<div align="center">
36-
<img src="https://github.com/chdb-io/chdb/raw/main/docs/_static/arch-chdb2.png" width="450">
36+
<img src="https://github.com/chdb-io/chdb/raw/main/docs/_static/arch-chdb3.png" width="450">
3737
</div>
3838

3939
## Get Started

docs/_static/arch-chdb3.png

100 KB
Loading

programs/local/chdb.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct query_queue
6666
{
6767
std::mutex mutex;
6868
std::condition_variable query_cv; // For query submission
69-
std::condition_variable result_cv;
69+
std::condition_variable result_cv; // For query result retrieval
7070
query_request current_query;
7171
local_result_v2 * current_result = nullptr;
7272
bool has_query = false;
@@ -75,15 +75,47 @@ struct query_queue
7575
};
7676
#endif
7777

78+
/**
79+
* Connection structure for chDB
80+
* Contains server instance, connection state, and query processing queue
81+
*/
7882
struct chdb_conn
7983
{
80-
void * server; // LocalServer * server;
81-
bool connected;
82-
void * queue; // query_queue*
84+
void * server; /* ClickHouse LocalServer instance */
85+
bool connected; /* Connection state flag */
86+
void * queue; /* Query processing queue */
8387
};
8488

89+
/**
90+
* Creates a new chDB connection.
91+
* Only one active connection is allowed per process.
92+
* Creating a new connection with different path requires closing existing connection.
93+
*
94+
* @param argc Number of command-line arguments
95+
* @param argv Command-line arguments array (--path=<db_path> to specify database location)
96+
* @return Pointer to connection pointer, or NULL on failure
97+
* @note Default path is ":memory:" if not specified
98+
*/
8599
CHDB_EXPORT struct chdb_conn ** connect_chdb(int argc, char ** argv);
100+
101+
/**
102+
* Closes an existing chDB connection and cleans up resources.
103+
* Thread-safe function that handles connection shutdown and cleanup.
104+
*
105+
* @param conn Pointer to connection pointer to close
106+
*/
86107
CHDB_EXPORT void close_conn(struct chdb_conn ** conn);
108+
109+
/**
110+
* Executes a query on the given connection.
111+
* Thread-safe function that handles query execution in a separate thread.
112+
*
113+
* @param conn Connection to execute query on
114+
* @param query SQL query string to execute
115+
* @param format Output format string (e.g., "CSV", default format)
116+
* @return Query result structure containing output or error message
117+
* @note Returns error result if connection is invalid or closed
118+
*/
87119
CHDB_EXPORT struct local_result_v2 * query_conn(struct chdb_conn * conn, const char * query, const char * format);
88120

89121
#ifdef __cplusplus

0 commit comments

Comments
 (0)