armink / FlashDB

An ultra-lightweight database that supports key-value and time series data | 一款支持 KV 数据和时序数据的超轻量级数据库
Apache License 2.0
1.71k stars 399 forks source link

feat: add new sector iterator function #206

Closed shihang-zhang closed 1 year ago

shihang-zhang commented 1 year ago

feat: add new sector iterator function to start iterating from last gc sector.)

shihang-zhang commented 1 year ago

Hi armink, I have done a test and please refer to the following for some of the test log. The code runs as designed. Thanks!

[FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 3, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 2, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00000000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00000800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00000800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00001000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00001000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00001800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00001800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00000000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00000000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00000800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00000800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00001000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00001000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00001800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00001800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00000000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00000000 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00000800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1425) Trigger a GC check after created KV. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1295) The remain empty sector is 1, GC threshold is 1. [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1265) Collect a sector @0x00000800 [FlashDB][kv][knx_os] (E:\3\0302lmg\Component\flashdb\src\FlashDB\src\fdb_kvdb.c:1277) oldest_addr is @0x00001000

armink commented 1 year ago

感谢 @shihang-zhang ,PR 已经合并了