MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / count_table_entries

Function count_table_entries

atomic-repository/src/redb_change_store/mod.rs:460–471  ·  view source on GitHub ↗

Count entries in a redb table by iterating (redb tables don't have a len() method).

(
    txn: &redb::ReadTransaction,
    table_def: TableDefinition<K, V>,
)

Source from the content-addressed store, hash-verified

458
459/// Count entries in a redb table by iterating (redb tables don't have a len() method).
460pub(crate) fn count_table_entries<K: redb::Key + 'static, V: redb::Value + 'static>(
461 txn: &redb::ReadTransaction,
462 table_def: TableDefinition<K, V>,
463) -> RedbStoreResult<u64> {
464 let table = txn.open_table(table_def)?;
465 let mut count = 0u64;
466 let iter = table.iter()?;
467 for _ in iter {
468 count += 1;
469 }
470 Ok(count)
471}
472
473#[cfg(test)]
474#[path = "tests.rs"]

Callers 1

statsMethod · 0.85

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected