• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4112409903

pending completion
4112409903

Pull #818

github

GitHub
Merge 0e6d61bff into c160ec41f
Pull Request #818: chore: fix dag issues

212 of 212 new or added lines in 23 files covered. (100.0%)

23352 of 37718 relevant lines covered (61.91%)

31647.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.14
/dozer-cache/src/cache/lmdb/query/helper.rs
1
use crate::errors::{CacheError, QueryError};
2
use dozer_types::{bincode, serde};
3
use lmdb::{Database, Transaction};
4
use lmdb_sys as ffi;
5
use std::{cmp::Ordering, ffi::c_void};
6
pub fn get<T>(txn: &impl Transaction, db: Database, id: &[u8]) -> Result<T, CacheError>
489,996✔
7
where
489,996✔
8
    T: for<'a> serde::de::Deserialize<'a>,
489,996✔
9
{
489,996✔
10
    let rec = txn
489,996✔
11
        .get(db, &id)
489,996✔
12
        .map_err(|e| CacheError::QueryError(QueryError::GetValue(e)))?;
489,996✔
13
    bincode::deserialize(rec).map_err(CacheError::map_deserialization_error)
489,989✔
14
}
489,996✔
15

16
pub fn lmdb_cmp<T: Transaction>(txn: &T, db: Database, a: &[u8], b: &[u8]) -> Ordering {
797,092✔
17
    let a: ffi::MDB_val = ffi::MDB_val {
797,092✔
18
        mv_size: a.len(),
797,092✔
19
        mv_data: a.as_ptr() as *mut c_void,
797,092✔
20
    };
797,092✔
21
    let b: ffi::MDB_val = ffi::MDB_val {
797,092✔
22
        mv_size: b.len(),
797,092✔
23
        mv_data: b.as_ptr() as *mut c_void,
797,092✔
24
    };
797,092✔
25
    let result = unsafe { lmdb_sys::mdb_cmp(txn.txn(), db.dbi(), &a, &b) };
797,092✔
26
    result.cmp(&0)
797,092✔
27
}
797,092✔
28

29
pub fn lmdb_stat<T: Transaction>(txn: &T, db: Database) -> Result<ffi::MDB_stat, lmdb::Error> {
8,688✔
30
    let mut stat = ffi::MDB_stat {
8,688✔
31
        ms_psize: 0,
8,688✔
32
        ms_depth: 0,
8,688✔
33
        ms_branch_pages: 0,
8,688✔
34
        ms_leaf_pages: 0,
8,688✔
35
        ms_overflow_pages: 0,
8,688✔
36
        ms_entries: 0,
8,688✔
37
    };
8,688✔
38
    let code = unsafe { lmdb_sys::mdb_stat(txn.txn(), db.dbi(), &mut stat) };
8,688✔
39
    if code == ffi::MDB_SUCCESS {
8,688✔
40
        Ok(stat)
8,688✔
41
    } else {
42
        Err(lmdb::Error::from_err_code(code))
×
43
    }
44
}
8,688✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc