Skip to content

Commit 891c058

Browse files
committed
【更新】至 V2.1.0 版本
1 parent ec6447d commit 891c058

File tree

18 files changed

+1674
-357
lines changed

18 files changed

+1674
-357
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![](docs/_media/flashdb.png)
22

3-
[![Build Status](https://travis-ci.com/armink/FlashDB.svg?branch=master)](https://travis-ci.com/armink/FlashDB) [![license](https://img.shields.io/github/license/armink/FlashDB)](https://raw.githubusercontent.com/armink/FlashDB/master/LICENSE) [![docs](https://img.shields.io/badge/docs-perfect-blue)](https://armink.github.io/FlashDB/#/)
3+
![GitHub Action](https://github.com/armink/FlashDB/workflows/AutoTestCI/badge.svg) [![license](https://img.shields.io/github/license/armink/FlashDB)](https://raw.githubusercontent.com/armink/FlashDB/master/LICENSE) [![docs](https://img.shields.io/badge/docs-perfect-blue)](https://armink.github.io/FlashDB/#/)
44

55
EN | [中文](README_zh.md)
66

README_zh.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
![](docs/_media/flashdb.png)
22

3-
[![Build Status](https://travis-ci.com/armink/FlashDB.svg?branch=master)](https://travis-ci.com/armink/FlashDB) [![license](https://img.shields.io/github/license/armink/FlashDB)](https://raw.githubusercontent.com/armink/FlashDB/master/LICENSE) [![docs](https://img.shields.io/badge/docs-perfect-blue)](http://armink.gitee.io/flashdb/#/zh-cn/ )
3+
![GitHub Action](https://github.com/armink/FlashDB/workflows/AutoTestCI/badge.svg) [![license](https://img.shields.io/github/license/armink/FlashDB)](https://raw.githubusercontent.com/armink/FlashDB/master/LICENSE) [![docs](https://img.shields.io/badge/docs-perfect-blue)](http://armink.gitee.io/flashdb/#/zh-cn/ )
44

55
[EN](README.md) | 中文
66

77
## 简介
88

9-
[FlashDB](https://github.com/armink/FlashDB) 是一款超轻量级的嵌入式数据库,专注于提供嵌入式产品的数据存储方案。与传统的基于文件系统的数据库不同,[FlashDB](https://github.com/armink/FlashDB) 结合了 Flash 的特性,具有较强的性能及可靠性。并在保证极低的资源占用前提下,尽可能延长 Flash 使用寿命。
9+
[FlashDB](http://armink.gitee.io/flashdb/#/zh-cn/) 是一款超轻量级的嵌入式数据库,专注于提供嵌入式产品的数据存储方案。FlashDB 不仅支持传统的基于文件系统的数据库模式,而且结合了 Flash 的特性,具有较强的性能及可靠性。并在保证极低的资源占用前提下,尽可能延长 Flash 使用寿命。
1010

11-
[FlashDB](https://github.com/armink/FlashDB) 提供两种数据库模式:
11+
FlashDB 提供两种数据库模式:
1212

1313
- **键值数据库** :是一种非关系数据库,它将数据存储为键值(Key-Value)对集合,其中键作为唯一标识符。KVDB 操作简洁,可扩展性强。
1414
- **时序数据库** :时间序列数据库 (Time Series Database , 简称 TSDB),它将数据按照 **时间顺序存储** 。TSDB 数据具有时间戳,数据存储量大,插入及查询性能高。
1515

16+
> 欢迎 Star&Fork :https://gitee.com/armink/FlashDB
17+
1618
## 使用场景
1719

1820
如今,物联网产品种类越来越多,运行时产生的数据种类及总量及也在不断变大。FlashDB 提供了多样化的数据存储方案,不仅资源占用小,并且存储容量大,非常适合用于物联网产品。下面是主要应用场景:
@@ -89,4 +91,4 @@ FlashDB 提供了全面的文档说明,详见:http://armink.gitee.io/flashdb
8991

9092
## 许可
9193

92-
采用 Apache-2.0 开源协议,细节请阅读项目中的 LICENSE 文件内容。
94+
采用 Apache-2.0 开源协议,细节请阅读项目中的 LICENSE 文件内容。

docs/api.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The process of constructing a blob object, its internal is the process of initia
1313
| blob | blob initial object |
1414
| value_buf | Buffer for storing data |
1515
| buf_len | The size of the buffer |
16-
| Back | The blob object after creation |
16+
| Return | The blob object after creation |
1717

1818
### Read blob data
1919

@@ -40,7 +40,7 @@ Through the API of KVDB and TSDB, the blob object can be returned, and the stora
4040
| path | FAL mode: the partition name in the partition table, file mode: the path where the database is saved |
4141
| default_kv | The default KV collection, when the first initialization, the default KV will be written to the database |
4242
| user_data | User-defined data, NULL if not available |
43-
| Back | Error Code |
43+
| Return | Error Code |
4444

4545
### Control KVDB
4646

@@ -53,7 +53,7 @@ Through the command control word, the user can perform some control operations o
5353
| db | Database Objects |
5454
| cmd | Command control word |
5555
| arg | Controlled parameters |
56-
| Back | Error Code |
56+
| Return | Error Code |
5757

5858
The supported command control words are as follows:
5959

@@ -102,7 +102,7 @@ Get the corresponding value by KV's name. Support two interfaces
102102
| db | Database Objects |
103103
| key | KV name |
104104
| blob | blob object, as the value of KV |
105-
| Back | Error Code |
105+
| Return | Error Code |
106106
107107
Example:
108108
@@ -122,7 +122,7 @@ fdb_kv_set_blob(kvdb, "temp", fdb_blob_make(&blob, &temp_data, sizeof(temp_data)
122122
| db | Database Objects |
123123
| key | KV name |
124124
| value | KV value |
125-
| Back | Error Code |
125+
| Return | Error Code |
126126

127127
### Get KV
128128

@@ -135,7 +135,7 @@ fdb_kv_set_blob(kvdb, "temp", fdb_blob_make(&blob, &temp_data, sizeof(temp_data)
135135
| db | Database Objects |
136136
| key | KV name |
137137
| blob | Return the blob value of KV through the blob object |
138-
| Back | Error Code |
138+
| Return | Error Code |
139139

140140
Example:
141141

@@ -161,7 +161,7 @@ Unlike the `fdb_kv_get_blob` API, this API does not execute the reading of value
161161
| db | Database Objects |
162162
| key | KV name |
163163
| 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 |
164-
| Back | Error Code |
164+
| Return | Error Code |
165165
166166
#### Get string type KV
167167
@@ -188,7 +188,7 @@ Unlike the `fdb_kv_get_blob` API, this API does not execute the reading of value
188188
| ---- | ---------- |
189189
| db | Database Objects |
190190
| key | KV name |
191-
| Back | Error Code |
191+
| Return | Error Code |
192192
193193
### Reset KVDB
194194
@@ -199,7 +199,7 @@ Reset the KV in KVDB to the **first initial** default value
199199
| Parameters | Description |
200200
| ---- | ---------- |
201201
| db | Database Objects |
202-
| Back | Error Code |
202+
| Return | Error Code |
203203
204204
### Print KV information in KVDB
205205
@@ -208,7 +208,7 @@ Reset the KV in KVDB to the **first initial** default value
208208
| Parameters | Description |
209209
| ---- | ---------- |
210210
| db | Database Objects |
211-
| Back | Error Code |
211+
| Return | Error Code |
212212
213213
### Convert KV objects to blob objects
214214
@@ -221,10 +221,11 @@ Reset the KV in KVDB to the **first initial** default value
221221
| Return | Converted blob object |
222222
223223
### Initialize KV iterator
224-
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kv_iterator_t itr)`
224+
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kvdb_t db, fdb_kv_iterator_t itr)`
225225
226226
| Parameters | Description |
227227
| ---- | -------------------- |
228+
| db | Database Objects |
228229
| itr | Iterator object to be initialized |
229230
| Return | Iterator object after initialization |
230231
@@ -252,7 +253,7 @@ Using this iterator API, all KVs in the entire KVDB can be traversed.
252253
| get_time | Function to get the current timestamp |
253254
| max_len | Maximum length of each TSL |
254255
| user_data | User-defined data, NULL if not available |
255-
| Back | Error Code |
256+
| Return | Error Code |
256257
257258
### Control TSDB
258259
@@ -265,7 +266,7 @@ Through the command control word, the user can perform some control operations o
265266
| db | Database Objects |
266267
| cmd | Command control word |
267268
| arg | Controlled parameters |
268-
| Back | Error Code |
269+
| Return | Error Code |
269270
270271
The supported command control words are as follows:
271272
@@ -300,7 +301,7 @@ For TSDB, the process of adding TSL is the process of appending a new TSL to the
300301
| ---- | --------------------------- |
301302
| db | Database Objects |
302303
| blob | blob object, as TSL data |
303-
| Back | Error Code |
304+
| Return | Error Code |
304305

305306
### Iterative TSL
306307

@@ -313,7 +314,20 @@ Traverse the entire TSDB and execute iterative callbacks
313314
| db | Database Objects |
314315
| cb | Callback function, which will be executed every time the TSL is traversed |
315316
| cb_arg | Parameters of the callback function |
316-
| Back | Error Code |
317+
| Return | Error Code |
318+
319+
### Reverse iterative TSL
320+
321+
Reverse traverse the entire TSDB and execute iterative callbacks
322+
323+
`void fdb_tsl_iter_reverse(fdb_tsdb_t db, fdb_tsl_cb cb, void *arg)`
324+
325+
| Parameters | Description |
326+
| ---------- | ------------------------------------------------------------ |
327+
| db | Database Objects |
328+
| cb | Callback function, which will be executed every time the TSL is traversed |
329+
| cb_arg | Parameters of the callback function |
330+
| Return | Error Code |
317331

318332
### Iterate TSL by time period
319333

@@ -324,11 +338,11 @@ According to the time range, traverse the entire TSDB and execute iterative call
324338
| Parameters | Description |
325339
| ------ | --------------------------------------- |
326340
| db | Database Objects |
327-
| from | Start timestamp |
341+
| from | Start timestamp. It will be a reverse iterator when ending timestamp less than starting timestamp |
328342
| to | End timestamp |
329343
| cb | Callback function, which will be executed every time the TSL is traversed |
330344
| cb_arg | Parameters of the callback function |
331-
| Back | Error Code |
345+
| Return | Error Code |
332346

333347
### Query the number of TSL
334348

@@ -341,7 +355,7 @@ According to the incoming time period, query the number of TSLs that meet the st
341355
| from | Start timestamp |
342356
| to | End timestamp |
343357
| status | TSL status conditions |
344-
| Back | Quantity |
358+
| Return | Quantity |
345359

346360
### Set TSL status
347361

@@ -354,7 +368,7 @@ For TSL status, please refer to `enum fdb_tsl_status`. TSL status MUST be set in
354368
| db | Database Objects |
355369
| tsl | TSL Object |
356370
| status | TSL's new status |
357-
| Back | Error Code |
371+
| Return | Error Code |
358372

359373
### Clear TSDB
360374

@@ -363,7 +377,7 @@ For TSL status, please refer to `enum fdb_tsl_status`. TSL status MUST be set in
363377
| Parameters | Description |
364378
| ---- | ---------- |
365379
| db | Database Objects |
366-
| Back | Error Code |
380+
| Return | Error Code |
367381

368382
### Convert TSL objects to blob objects
369383

docs/sample-kvdb-traversal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void kvdb_tarversal_sample(fdb_kvdb_t kvdb)
1717
size_t data_size;
1818
uint8_t *data_buf;
1919

20-
fdb_kv_iterator_init(&iterator);
20+
fdb_kv_iterator_init(kvdb, &iterator);
2121

2222
while (fdb_kv_iterate(kvdb, &iterator)) {
2323
cur_kv = &(iterator.curr_kv);

docs/zh-cn/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# FlashDB:超轻量级嵌入式数据库
22

3-
[![Build Status](https://travis-ci.com/armink/FlashDB.svg?branch=master)](https://travis-ci.com/armink/FlashDB) [![license](https://img.shields.io/github/license/armink/FlashDB)](https://raw.githubusercontent.com/armink/FlashDB/master/LICENSE)
4-
3+
[![Build Status](https://travis-ci.com/armink/FlashDB.svg?branch=master)](https://travis-ci.com/armink/FlashDB) [![license](https://img.shields.io/github/license/armink/FlashDB)](https://raw.githubusercontent.com/armink/FlashDB/master/LICENSE) [![docs](https://img.shields.io/badge/docs-perfect-blue)](http://armink.gitee.io/flashdb/#/zh-cn/ )
54
## 简介
65

7-
[FlashDB](https://github.com/armink/FlashDB) 是一款超轻量级的嵌入式数据库,专注于提供嵌入式产品的数据存储方案。与传统的基于文件系统的数据库不同,[FlashDB](https://github.com/armink/FlashDB) 结合了 Flash 的特性,具有较强的性能及可靠性。并在保证极低的资源占用前提下,尽可能延长 Flash 使用寿命。
6+
[FlashDB](http://armink.gitee.io/flashdb/#/zh-cn/) 是一款超轻量级的嵌入式数据库,专注于提供嵌入式产品的数据存储方案。与传统的基于文件系统的数据库不同,FlashDB 结合了 Flash 的特性,具有较强的性能及可靠性。并在保证极低的资源占用前提下,尽可能延长 Flash 使用寿命。
87

9-
[FlashDB](https://github.com/armink/FlashDB) 提供两种数据库模式:
8+
FlashDB 提供两种数据库模式:
109

1110
- **键值数据库** :是一种非关系数据库,它将数据存储为键值(Key-Value)对集合,其中键作为唯一标识符。KVDB 操作简洁,可扩展性强。
1211
- **时序数据库** :时间序列数据库 (Time Series Database , 简称 TSDB),它将数据按照 **时间顺序存储** 。TSDB 数据具有时间戳,数据存储量大,插入及查询性能高。
1312

13+
> 欢迎 Star&Fork :https://gitee.com/armink/FlashDB
14+
1415
## 使用场景
1516

1617
如今,物联网产品种类越来越多,运行时产生的数据种类及总量及也在不断变大。FlashDB 提供了多样化的数据存储方案,不仅资源占用小,并且存储容量大,非常适合用于物联网产品。下面是主要应用场景:

docs/zh-cn/api.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,11 @@ if (blob.saved.len > 0) {
221221
| 返回 | 转换后的 blob 对象 |
222222
223223
### 初始化 KV 迭代器
224-
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kv_iterator_t itr)`
224+
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kvdb_t db, fdb_kv_iterator_t itr)`
225225
226226
| 参数 | 描述 |
227227
| ---- | -------------------- |
228+
| db | 数据库对象 |
228229
| itr | 待初始化的迭代器对象 |
229230
| 返回 | 初始化后的迭代器对象 |
230231
@@ -315,21 +316,34 @@ if (blob.saved.len > 0) {
315316
| cb_arg | 回调函数的参数 |
316317
| 返回 | 错误码 |
317318

318-
### 按时间段迭代 TSL
319+
### 逆序迭代 TSL
319320

320-
按时间段范围,遍历整个 TSDB 并执行迭代回调
321+
逆序遍历整个 TSDB 并执行迭代回调
321322

322-
`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)`
323+
`void fdb_tsl_iter_reverse(fdb_tsdb_t db, fdb_tsl_cb cb, void *cb_arg)`
323324

324325
| 参数 | 描述 |
325326
| ------ | --------------------------------------- |
326327
| db | 数据库对象 |
327-
| from | 开始时间戳 |
328-
| to | 结束时间戳 |
329328
| cb | 回调函数,每次遍历到 TSL 时会执行该回调 |
330329
| cb_arg | 回调函数的参数 |
331330
| 返回 | 错误码 |
332331

332+
### 按时间段迭代 TSL
333+
334+
按时间段范围,遍历整个 TSDB 并执行迭代回调
335+
336+
`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)`
337+
338+
| 参数 | 描述 |
339+
| ------ | ------------------------------------------------------------ |
340+
| db | 数据库对象 |
341+
| from | 开始时间戳。如果结束时间戳比开始时间戳要小,此时将会执行逆序迭代。 |
342+
| to | 结束时间戳 |
343+
| cb | 回调函数,每次遍历到 TSL 时会执行该回调 |
344+
| cb_arg | 回调函数的参数 |
345+
| 返回 | 错误码 |
346+
333347
### 查询 TSL 的数量
334348

335349
按照传入的时间段,查询符合状态的 TSL 数量

docs/zh-cn/sample-kvdb-traversal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void kvdb_tarversal_sample(fdb_kvdb_t kvdb)
1717
size_t data_size;
1818
uint8_t *data_buf;
1919

20-
fdb_kv_iterator_init(&iterator);
20+
fdb_kv_iterator_init(kvdb, &iterator);
2121

2222
while (fdb_kv_iterate(kvdb, &iterator)) {
2323
cur_kv = &(iterator.curr_kv);

0 commit comments

Comments
 (0)