[doc] update the doc for reverse iterator.

This commit is contained in:
朱天龙 (Armink) 2022-06-11 14:47:12 +08:00
parent 4e393e1326
commit 393773aa8a
2 changed files with 53 additions and 27 deletions

View File

@ -13,7 +13,7 @@ The process of constructing a blob object, its internal is the process of initia
| blob | blob initial object | | blob | blob initial object |
| value_buf | Buffer for storing data | | value_buf | Buffer for storing data |
| buf_len | The size of the buffer | | buf_len | The size of the buffer |
| Back | The blob object after creation | | Return | The blob object after creation |
### Read blob data ### Read blob data
@ -40,7 +40,7 @@ Through the API of KVDB and TSDB, the blob object can be returned, and the stora
| path | FAL mode: the partition name in the partition table, file mode: the path where the database is saved | | path | FAL mode: the partition name in the partition table, file mode: the path where the database is saved |
| default_kv | The default KV collection, when the first initialization, the default KV will be written to the database | | default_kv | The default KV collection, when the first initialization, the default KV will be written to the database |
| user_data | User-defined data, NULL if not available | | user_data | User-defined data, NULL if not available |
| Back | Error Code | | Return | Error Code |
### Control KVDB ### Control KVDB
@ -53,7 +53,7 @@ Through the command control word, the user can perform some control operations o
| db | Database Objects | | db | Database Objects |
| cmd | Command control word | | cmd | Command control word |
| arg | Controlled parameters | | arg | Controlled parameters |
| Back | Error Code | | Return | Error Code |
The supported command control words are as follows: The supported command control words are as follows:
@ -102,7 +102,7 @@ Get the corresponding value by KV's name. Support two interfaces
| db | Database Objects | | db | Database Objects |
| key | KV name | | key | KV name |
| blob | blob object, as the value of KV | | blob | blob object, as the value of KV |
| Back | Error Code | | Return | Error Code |
Example: Example:
@ -122,7 +122,7 @@ fdb_kv_set_blob(kvdb, "temp", fdb_blob_make(&blob, &temp_data, sizeof(temp_data)
| db | Database Objects | | db | Database Objects |
| key | KV name | | key | KV name |
| value | KV value | | value | KV value |
| Back | Error Code | | Return | Error Code |
### Get KV ### Get KV
@ -135,7 +135,7 @@ fdb_kv_set_blob(kvdb, "temp", fdb_blob_make(&blob, &temp_data, sizeof(temp_data)
| db | Database Objects | | db | Database Objects |
| key | KV name | | key | KV name |
| blob | Return the blob value of KV through the blob object | | blob | Return the blob value of KV through the blob object |
| Back | Error Code | | Return | Error Code |
Example: Example:
@ -161,7 +161,7 @@ Unlike the `fdb_kv_get_blob` API, this API does not execute the reading of value
| db | Database Objects | | db | Database Objects |
| key | KV name | | key | KV name |
| kv | Through the KV object, return the attributes of the KV, and then use `fdb_kv_to_blob` to convert to a blob object, and then read the data | | kv | Through the KV object, return the attributes of the KV, and then use `fdb_kv_to_blob` to convert to a blob object, and then read the data |
| Back | Error Code | | Return | Error Code |
#### Get string type KV #### Get string type KV
@ -188,7 +188,7 @@ Unlike the `fdb_kv_get_blob` API, this API does not execute the reading of value
| ---- | ---------- | | ---- | ---------- |
| db | Database Objects | | db | Database Objects |
| key | KV name | | key | KV name |
| Back | Error Code | | Return | Error Code |
### Reset KVDB ### Reset KVDB
@ -199,7 +199,7 @@ Reset the KV in KVDB to the **first initial** default value
| Parameters | Description | | Parameters | Description |
| ---- | ---------- | | ---- | ---------- |
| db | Database Objects | | db | Database Objects |
| Back | Error Code | | Return | Error Code |
### Print KV information in KVDB ### Print KV information in KVDB
@ -208,7 +208,7 @@ Reset the KV in KVDB to the **first initial** default value
| Parameters | Description | | Parameters | Description |
| ---- | ---------- | | ---- | ---------- |
| db | Database Objects | | db | Database Objects |
| Back | Error Code | | Return | Error Code |
### Convert KV objects to blob objects ### Convert KV objects to blob objects
@ -252,7 +252,7 @@ Using this iterator API, all KVs in the entire KVDB can be traversed.
| get_time | Function to get the current timestamp | | get_time | Function to get the current timestamp |
| max_len | Maximum length of each TSL | | max_len | Maximum length of each TSL |
| user_data | User-defined data, NULL if not available | | user_data | User-defined data, NULL if not available |
| Back | Error Code | | Return | Error Code |
### Control TSDB ### Control TSDB
@ -265,7 +265,7 @@ Through the command control word, the user can perform some control operations o
| db | Database Objects | | db | Database Objects |
| cmd | Command control word | | cmd | Command control word |
| arg | Controlled parameters | | arg | Controlled parameters |
| Back | Error Code | | Return | Error Code |
The supported command control words are as follows: The supported command control words are as follows:
@ -300,7 +300,7 @@ For TSDB, the process of adding TSL is the process of appending a new TSL to the
| ---- | --------------------------- | | ---- | --------------------------- |
| db | Database Objects | | db | Database Objects |
| blob | blob object, as TSL data | | blob | blob object, as TSL data |
| Back | Error Code | | Return | Error Code |
### Iterative TSL ### Iterative TSL
@ -313,7 +313,20 @@ Traverse the entire TSDB and execute iterative callbacks
| db | Database Objects | | db | Database Objects |
| cb | Callback function, which will be executed every time the TSL is traversed | | cb | Callback function, which will be executed every time the TSL is traversed |
| cb_arg | Parameters of the callback function | | cb_arg | Parameters of the callback function |
| Back | Error Code | | Return | Error Code |
### Reverse iterative TSL
Reverse traverse the entire TSDB and execute iterative callbacks
`void fdb_tsl_iter_reverse(fdb_tsdb_t db, fdb_tsl_cb cb, void *arg)`
| Parameters | Description |
| ---------- | ------------------------------------------------------------ |
| db | Database Objects |
| cb | Callback function, which will be executed every time the TSL is traversed |
| cb_arg | Parameters of the callback function |
| Return | Error Code |
### Iterate TSL by time period ### Iterate TSL by time period
@ -324,11 +337,11 @@ According to the time range, traverse the entire TSDB and execute iterative call
| Parameters | Description | | Parameters | Description |
| ------ | --------------------------------------- | | ------ | --------------------------------------- |
| db | Database Objects | | db | Database Objects |
| from | Start timestamp | | from | Start timestamp. It will be a reverse iterator when ending timestap less than starting timestap |
| to | End timestamp | | to | End timestamp |
| cb | Callback function, which will be executed every time the TSL is traversed | | cb | Callback function, which will be executed every time the TSL is traversed |
| cb_arg | Parameters of the callback function | | cb_arg | Parameters of the callback function |
| Back | Error Code | | Return | Error Code |
### Query the number of TSL ### Query the number of TSL
@ -341,7 +354,7 @@ According to the incoming time period, query the number of TSLs that meet the st
| from | Start timestamp | | from | Start timestamp |
| to | End timestamp | | to | End timestamp |
| status | TSL status conditions | | status | TSL status conditions |
| Back | Quantity | | Return | Quantity |
### Set TSL status ### Set TSL status
@ -354,7 +367,7 @@ For TSL status, please refer to `enum fdb_tsl_status`. TSL status MUST be set in
| db | Database Objects | | db | Database Objects |
| tsl | TSL Object | | tsl | TSL Object |
| status | TSL's new status | | status | TSL's new status |
| Back | Error Code | | Return | Error Code |
### Clear TSDB ### Clear TSDB
@ -363,7 +376,7 @@ For TSL status, please refer to `enum fdb_tsl_status`. TSL status MUST be set in
| Parameters | Description | | Parameters | Description |
| ---- | ---------- | | ---- | ---------- |
| db | Database Objects | | db | Database Objects |
| Back | Error Code | | Return | Error Code |
### Convert TSL objects to blob objects ### Convert TSL objects to blob objects

View File

@ -315,6 +315,19 @@ if (blob.saved.len > 0) {
| cb_arg | 回调函数的参数 | | cb_arg | 回调函数的参数 |
| 返回 | 错误码 | | 返回 | 错误码 |
### 逆序迭代 TSL
逆序遍历整个 TSDB 并执行迭代回调
`void fdb_tsl_iter_reverse(fdb_tsdb_t db, fdb_tsl_cb cb, void *cb_arg)`
| 参数 | 描述 |
| ------ | --------------------------------------- |
| db | 数据库对象 |
| cb | 回调函数,每次遍历到 TSL 时会执行该回调 |
| cb_arg | 回调函数的参数 |
| 返回 | 错误码 |
### 按时间段迭代 TSL ### 按时间段迭代 TSL
按时间段范围,遍历整个 TSDB 并执行迭代回调 按时间段范围,遍历整个 TSDB 并执行迭代回调
@ -322,9 +335,9 @@ if (blob.saved.len > 0) {
`void fdb_tsl_iter_by_time(fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_tsl_cb cb, void *cb_arg)` `void fdb_tsl_iter_by_time(fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_tsl_cb cb, void *cb_arg)`
| 参数 | 描述 | | 参数 | 描述 |
| ------ | --------------------------------------- | | ------ | ------------------------------------------------------------ |
| db | 数据库对象 | | db | 数据库对象 |
| from | 开始时间戳 | | from | 开始时间戳。如果结束时间戳比开始时间戳要小,此时将会执行逆序迭代。 |
| to | 结束时间戳 | | to | 结束时间戳 |
| cb | 回调函数,每次遍历到 TSL 时会执行该回调 | | cb | 回调函数,每次遍历到 TSL 时会执行该回调 |
| cb_arg | 回调函数的参数 | | cb_arg | 回调函数的参数 |