From efc7bb06ddc1ee71f794fbbbb610a640cf47355f Mon Sep 17 00:00:00 2001 From: Leto_b Date: Mon, 29 Dec 2025 16:26:10 +0800 Subject: [PATCH] add sessiondataset next function usage note to table cpp api --- .../Master/Table/API/Programming-Cpp-Native-API_apache.md | 1 + .../Master/Table/API/Programming-Cpp-Native-API_timecho.md | 1 + .../latest-Table/API/Programming-Cpp-Native-API_apache.md | 1 + .../latest-Table/API/Programming-Cpp-Native-API_timecho.md | 1 + .../Master/Table/API/Programming-Cpp-Native-API_apache.md | 1 + .../Master/Table/API/Programming-Cpp-Native-API_timecho.md | 1 + .../latest-Table/API/Programming-Cpp-Native-API_apache.md | 1 + .../latest-Table/API/Programming-Cpp-Native-API_timecho.md | 1 + 8 files changed, 8 insertions(+) diff --git a/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md b/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md index 8228dc1f3..5f43b225c 100644 --- a/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md +++ b/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md @@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B 1. `insert(Tablet& tablet, bool sorted = false)`: Inserts a Tablet object containing time series data into the database. The sorted parameter indicates whether the rows in the tablet are already sorted by time. 2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands. 3. `executeQueryStatement(string& sql)`: Executes query SQL statements and returns a SessionDataSet object containing the query results. The optional timeoutInMs parameter indicates the timeout return time. + * Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr` object in a local scope variable (e.g.: `auto row = dataSet->next();`) to ensure the validity of the data lifecycle. If you access it directly via `.get()` or a raw pointer (e.g., `dataSet->next().get()`), the reference count of the smart pointer will drop to zero, the data will be released immediately, and subsequent access will lead to undefined behavior. 4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default). 5. `close()`: Closes the connection. diff --git a/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md b/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md index 22c41a533..0f281b657 100644 --- a/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md +++ b/src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md @@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B 1. `insert(Tablet& tablet, bool sorted = false)`: Inserts a Tablet object containing time series data into the database. The sorted parameter indicates whether the rows in the tablet are already sorted by time. 2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands. 3. `executeQueryStatement(string& sql)`: Executes query SQL statements and returns a SessionDataSet object containing the query results. The optional timeoutInMs parameter indicates the timeout return time. + * Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr` object in a local scope variable (e.g.: `auto row = dataSet->next();`) to ensure the validity of the data lifecycle. If you access it directly via `.get()` or a raw pointer (e.g., `dataSet->next().get()`), the reference count of the smart pointer will drop to zero, the data will be released immediately, and subsequent access will lead to undefined behavior. 4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default). 5. `close()`: Closes the connection. diff --git a/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md b/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md index 8228dc1f3..5f43b225c 100644 --- a/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md +++ b/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md @@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B 1. `insert(Tablet& tablet, bool sorted = false)`: Inserts a Tablet object containing time series data into the database. The sorted parameter indicates whether the rows in the tablet are already sorted by time. 2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands. 3. `executeQueryStatement(string& sql)`: Executes query SQL statements and returns a SessionDataSet object containing the query results. The optional timeoutInMs parameter indicates the timeout return time. + * Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr` object in a local scope variable (e.g.: `auto row = dataSet->next();`) to ensure the validity of the data lifecycle. If you access it directly via `.get()` or a raw pointer (e.g., `dataSet->next().get()`), the reference count of the smart pointer will drop to zero, the data will be released immediately, and subsequent access will lead to undefined behavior. 4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default). 5. `close()`: Closes the connection. diff --git a/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md b/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md index 22c41a533..948f966e9 100644 --- a/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md +++ b/src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md @@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B 1. `insert(Tablet& tablet, bool sorted = false)`: Inserts a Tablet object containing time series data into the database. The sorted parameter indicates whether the rows in the tablet are already sorted by time. 2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands. 3. `executeQueryStatement(string& sql)`: Executes query SQL statements and returns a SessionDataSet object containing the query results. The optional timeoutInMs parameter indicates the timeout return time. + * Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr` object in a local scope variable (e.g.: `auto row = dataSet->next();`) to ensure the validity of the data lifecycle. If you access it directly via `.get()` or a raw pointer (e.g., `dataSet->next().get()`), the reference count of the smart pointer will drop to zero, the data will be released immediately, and subsequent access will lead to undefined behavior. 4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default). 5. `close()`: Closes the connection. diff --git a/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md b/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md index 535cc6ff3..3910f5434 100644 --- a/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md +++ b/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md @@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe 1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。 2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。 3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。 + * 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。 4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。 5. `close()`,关闭连接。 diff --git a/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md b/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md index 3b3b47c24..c569b7958 100644 --- a/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md +++ b/src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md @@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe 1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。 2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。 3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。 + * 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。 4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。 5. `close()`,关闭连接。 diff --git a/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md b/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md index 535cc6ff3..8ea1c89be 100644 --- a/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md +++ b/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md @@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe 1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。 2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。 3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。 + * 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。 4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。 5. `close()`,关闭连接。 diff --git a/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md b/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md index 559c6d6e6..44c7e3a42 100644 --- a/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md +++ b/src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md @@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe 1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。 2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。 3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。 + * 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。 4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。 5. `close()`,关闭连接。