Skip to content

Commit 4f83945

Browse files
authored
add sessiondataset next function usage note to table cpp api (#948)
1 parent 1173dac commit 4f83945

File tree

8 files changed

+8
-0
lines changed

8 files changed

+8
-0
lines changed

src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B
168168
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.
169169
2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands.
170170
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.
171+
* Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr<RowRecord>` 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.
171172
4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default).
172173
5. `close()`: Closes the connection.
173174

src/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B
168168
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.
169169
2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands.
170170
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.
171+
* Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr<RowRecord>` 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.
171172
4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default).
172173
5. `close()`: Closes the connection.
173174

src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B
168168
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.
169169
2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands.
170170
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.
171+
* Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr<RowRecord>` 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.
171172
4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default).
172173
5. `close()`: Closes the connection.
173174

src/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ All operations in the C++ client are performed through the TableSession class. B
168168
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.
169169
2. `executeNonQueryStatement(string& sql)`: Executes non-query SQL statements, such as DDL (Data Definition Language) or DML (Data Manipulation Language) commands.
170170
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.
171+
* Note: When retrieving rows of query results by calling `SessionDataSet::next()`, you must store the returned `std::shared_ptr<RowRecord>` 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.
171172
4. `open(bool enableRPCCompression = false)`: Opens the connection and determines whether to enable RPC compression (client state must match server state, disabled by default).
172173
5. `close()`: Closes the connection.
173174

src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_apache.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe
181181
1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。
182182
2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。
183183
3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。
184+
* 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr<RowRecord>` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。
184185
4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。
185186
5. `close()`,关闭连接。
186187

src/zh/UserGuide/Master/Table/API/Programming-Cpp-Native-API_timecho.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe
181181
1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。
182182
2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。
183183
3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。
184+
* 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr<RowRecord>` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。
184185
4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。
185186
5. `close()`,关闭连接。
186187

src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_apache.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe
181181
1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。
182182
2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。
183183
3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。
184+
* 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr<RowRecord>` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。
184185
4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。
185186
5. `close()`,关闭连接。
186187

src/zh/UserGuide/latest-Table/API/Programming-Cpp-Native-API_timecho.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ C++ 客户端的操作均通过 TableSession 类进行,下面将给出 TableSe
181181
1. `insert(Tablet& tablet, bool sorted = false)`,将一个包含时间序列数据的Tablet对象插入到数据库中,sorted参数指明tablet中的行是否已按时间排序。
182182
2. `executeNonQueryStatement(string& sql)`,执行非查询SQL语句,如DDL(数据定义语言)或DML(数据操作语言)命令。
183183
3. `executeQueryStatement(string& sql)`,执行查询SQL语句,并返回包含查询结果的SessionDataSet对象,可选timeoutInMs参数指示超时返回时间。
184+
* 注意:调用 `SessionDataSet::next()` 获取查询结果行时,必须将返回的 `std::shared_ptr<RowRecord>` 对象存储在局部作用域变量中(例如:`auto row = dataSet->next();`),以确保数据生命周期有效。若直接通过 `.get()` 或裸指针访问(如 `dataSet->next().get()`),将导致智能指针引用计数归零,数据被立即释放,后续访问将引发未定义行为。
184185
4. `open(bool enableRPCCompression = false)`,开启连接,并决定是否启用RPC压缩(客户端状态须与服务端一致,默认不开启)。
185186
5. `close()`,关闭连接。
186187

0 commit comments

Comments
 (0)