Skip to content

Commit

Permalink
【更新】至 V2.1.0 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
armink committed Jul 25, 2024
1 parent ec6447d commit 891c058
Show file tree
Hide file tree
Showing 18 changed files with 1,674 additions and 357 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![](docs/_media/flashdb.png)

[![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/#/)
![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/#/)

EN | [中文](README_zh.md)

Expand Down
10 changes: 6 additions & 4 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
![](docs/_media/flashdb.png)

[![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/ )
![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/ )

[EN](README.md) | 中文

## 简介

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

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

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

> 欢迎 Star&Fork :https://gitee.com/armink/FlashDB
## 使用场景

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

## 许可

采用 Apache-2.0 开源协议,细节请阅读项目中的 LICENSE 文件内容。
采用 Apache-2.0 开源协议,细节请阅读项目中的 LICENSE 文件内容。
54 changes: 34 additions & 20 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The process of constructing a blob object, its internal is the process of initia
| blob | blob initial object |
| value_buf | Buffer for storing data |
| buf_len | The size of the buffer |
| Back | The blob object after creation |
| Return | The blob object after creation |

### Read blob data

Expand All @@ -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 |
| 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 |
| Back | Error Code |
| Return | Error Code |

### Control KVDB

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

The supported command control words are as follows:

Expand Down Expand Up @@ -102,7 +102,7 @@ Get the corresponding value by KV's name. Support two interfaces
| db | Database Objects |
| key | KV name |
| blob | blob object, as the value of KV |
| Back | Error Code |
| Return | Error Code |
Example:
Expand All @@ -122,7 +122,7 @@ fdb_kv_set_blob(kvdb, "temp", fdb_blob_make(&blob, &temp_data, sizeof(temp_data)
| db | Database Objects |
| key | KV name |
| value | KV value |
| Back | Error Code |
| Return | Error Code |

### Get KV

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

Example:

Expand All @@ -161,7 +161,7 @@ Unlike the `fdb_kv_get_blob` API, this API does not execute the reading of value
| db | Database Objects |
| 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 |
| Back | Error Code |
| Return | Error Code |
#### Get string type KV
Expand All @@ -188,7 +188,7 @@ Unlike the `fdb_kv_get_blob` API, this API does not execute the reading of value
| ---- | ---------- |
| db | Database Objects |
| key | KV name |
| Back | Error Code |
| Return | Error Code |
### Reset KVDB
Expand All @@ -199,7 +199,7 @@ Reset the KV in KVDB to the **first initial** default value
| Parameters | Description |
| ---- | ---------- |
| db | Database Objects |
| Back | Error Code |
| Return | Error Code |
### Print KV information in KVDB
Expand All @@ -208,7 +208,7 @@ Reset the KV in KVDB to the **first initial** default value
| Parameters | Description |
| ---- | ---------- |
| db | Database Objects |
| Back | Error Code |
| Return | Error Code |
### Convert KV objects to blob objects
Expand All @@ -221,10 +221,11 @@ Reset the KV in KVDB to the **first initial** default value
| Return | Converted blob object |
### Initialize KV iterator
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kv_iterator_t itr)`
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kvdb_t db, fdb_kv_iterator_t itr)`
| Parameters | Description |
| ---- | -------------------- |
| db | Database Objects |
| itr | Iterator object to be initialized |
| Return | Iterator object after initialization |
Expand Down Expand Up @@ -252,7 +253,7 @@ Using this iterator API, all KVs in the entire KVDB can be traversed.
| get_time | Function to get the current timestamp |
| max_len | Maximum length of each TSL |
| user_data | User-defined data, NULL if not available |
| Back | Error Code |
| Return | Error Code |
### Control TSDB
Expand All @@ -265,7 +266,7 @@ Through the command control word, the user can perform some control operations o
| db | Database Objects |
| cmd | Command control word |
| arg | Controlled parameters |
| Back | Error Code |
| Return | Error Code |
The supported command control words are as follows:
Expand Down Expand Up @@ -300,7 +301,7 @@ For TSDB, the process of adding TSL is the process of appending a new TSL to the
| ---- | --------------------------- |
| db | Database Objects |
| blob | blob object, as TSL data |
| Back | Error Code |
| Return | Error Code |

### Iterative TSL

Expand All @@ -313,7 +314,20 @@ Traverse the entire TSDB and execute iterative callbacks
| db | Database Objects |
| cb | Callback function, which will be executed every time the TSL is traversed |
| 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

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

### Query the number of TSL

Expand All @@ -341,7 +355,7 @@ According to the incoming time period, query the number of TSLs that meet the st
| from | Start timestamp |
| to | End timestamp |
| status | TSL status conditions |
| Back | Quantity |
| Return | Quantity |

### Set TSL status

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

### Clear TSDB

Expand All @@ -363,7 +377,7 @@ For TSL status, please refer to `enum fdb_tsl_status`. TSL status MUST be set in
| Parameters | Description |
| ---- | ---------- |
| db | Database Objects |
| Back | Error Code |
| Return | Error Code |

### Convert TSL objects to blob objects

Expand Down
2 changes: 1 addition & 1 deletion docs/sample-kvdb-traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void kvdb_tarversal_sample(fdb_kvdb_t kvdb)
size_t data_size;
uint8_t *data_buf;

fdb_kv_iterator_init(&iterator);
fdb_kv_iterator_init(kvdb, &iterator);

while (fdb_kv_iterate(kvdb, &iterator)) {
cur_kv = &(iterator.curr_kv);
Expand Down
9 changes: 5 additions & 4 deletions docs/zh-cn/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# FlashDB:超轻量级嵌入式数据库

[![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)

[![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/ )
## 简介

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

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

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

> 欢迎 Star&Fork :https://gitee.com/armink/FlashDB
## 使用场景

如今,物联网产品种类越来越多,运行时产生的数据种类及总量及也在不断变大。FlashDB 提供了多样化的数据存储方案,不仅资源占用小,并且存储容量大,非常适合用于物联网产品。下面是主要应用场景:
Expand Down
26 changes: 20 additions & 6 deletions docs/zh-cn/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ if (blob.saved.len > 0) {
| 返回 | 转换后的 blob 对象 |
### 初始化 KV 迭代器
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kv_iterator_t itr)`
`fdb_kv_iterator_t fdb_kv_iterator_init(fdb_kvdb_t db, fdb_kv_iterator_t itr)`
| 参数 | 描述 |
| ---- | -------------------- |
| db | 数据库对象 |
| itr | 待初始化的迭代器对象 |
| 返回 | 初始化后的迭代器对象 |
Expand Down Expand Up @@ -315,21 +316,34 @@ if (blob.saved.len > 0) {
| cb_arg | 回调函数的参数 |
| 返回 | 错误码 |

### 按时间段迭代 TSL
### 逆序迭代 TSL

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

`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_reverse(fdb_tsdb_t db, fdb_tsl_cb cb, void *cb_arg)`

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

### 按时间段迭代 TSL

按时间段范围,遍历整个 TSDB 并执行迭代回调

`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 | 数据库对象 |
| from | 开始时间戳。如果结束时间戳比开始时间戳要小,此时将会执行逆序迭代。 |
| to | 结束时间戳 |
| cb | 回调函数,每次遍历到 TSL 时会执行该回调 |
| cb_arg | 回调函数的参数 |
| 返回 | 错误码 |

### 查询 TSL 的数量

按照传入的时间段,查询符合状态的 TSL 数量
Expand Down
2 changes: 1 addition & 1 deletion docs/zh-cn/sample-kvdb-traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void kvdb_tarversal_sample(fdb_kvdb_t kvdb)
size_t data_size;
uint8_t *data_buf;

fdb_kv_iterator_init(&iterator);
fdb_kv_iterator_init(kvdb, &iterator);

while (fdb_kv_iterate(kvdb, &iterator)) {
cur_kv = &(iterator.curr_kv);
Expand Down
Loading

0 comments on commit 891c058

Please sign in to comment.