mirror of
https://github.com/armink/FlashDB.git
synced 2026-09-23 07:23:49 +08:00
feat(tsdb): Add fdb_tsl_max_blob_count() to get TSDB capacity (#417)
AutoTestCI / AutoTest (GRAN=1) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=128) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=256) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=32) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=64) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=8) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=1) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=128) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=256) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=32) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=64) (push) Has been cancelled
AutoTestCI / AutoTest (GRAN=8) (push) Has been cancelled
This commit is contained in:
@@ -65,6 +65,7 @@ void fdb_tsl_iter (fdb_tsdb_t db, fdb_tsl_cb cb, void *cb_arg);
|
||||
void fdb_tsl_iter_reverse(fdb_tsdb_t db, 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);
|
||||
size_t fdb_tsl_query_count (fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_tsl_status_t status);
|
||||
size_t fdb_tsl_max_blob_count(fdb_tsdb_t db);
|
||||
fdb_err_t fdb_tsl_set_status (fdb_tsdb_t db, fdb_tsl_t tsl, fdb_tsl_status_t status);
|
||||
void fdb_tsl_clean (fdb_tsdb_t db);
|
||||
fdb_blob_t fdb_tsl_to_blob (fdb_tsl_t tsl, fdb_blob_t blob);
|
||||
|
||||
@@ -804,6 +804,28 @@ size_t fdb_tsl_query_count(fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_ts
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of blobs that a TSL can hold, assuming
|
||||
* all blobs are max_len (or FDB_TSDB_FIXED_BLOB_SIZE if defined).
|
||||
*
|
||||
* @param db database object
|
||||
* @return the database capacity
|
||||
*/
|
||||
size_t fdb_tsl_max_blob_count(fdb_tsdb_t db)
|
||||
{
|
||||
#ifdef FDB_TSDB_FIXED_BLOB_SIZE
|
||||
size_t max_blob_len = FDB_TSDB_FIXED_BLOB_SIZE;
|
||||
#else
|
||||
size_t max_blob_len = db->max_len;
|
||||
#endif
|
||||
|
||||
size_t sec_size = db_sec_size(db) - SECTOR_HDR_DATA_SIZE;
|
||||
size_t blob_size = LOG_IDX_DATA_SIZE + FDB_WG_ALIGN(max_blob_len);
|
||||
size_t n_sec = db_max_size(db) / db_sec_size(db);
|
||||
|
||||
return n_sec * (sec_size / blob_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the TSL status.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user