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

getdozer / dozer / 4116183752

pending completion
4116183752

push

github

GitHub
refactor: Make `LmdbRoCache` and `LmdbRwCache` `Send` and `Sync` (#821)

790 of 790 new or added lines in 44 files covered. (100.0%)

23005 of 33842 relevant lines covered (67.98%)

56312.85 hits per line

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

96.97
/dozer-cache/src/cache/lmdb/tests/read_write.rs
1
use crate::cache::expression::{FilterExpression, Operator, QueryExpression};
2
use crate::cache::lmdb::{CacheCommonOptions, CacheWriteOptions};
3
use crate::cache::{
4
    lmdb::tests::utils as lmdb_utils, test_utils, LmdbRoCache, LmdbRwCache, RoCache, RwCache,
5
};
6
use dozer_types::serde_json::Value;
7
use dozer_types::types::Field;
8
use tempdir::TempDir;
×
9
#[test]
1✔
10
fn read_and_write() {
1✔
11
    let path = TempDir::new("dozer").unwrap();
1✔
12
    let path = (path.path().to_path_buf(), "cache".to_string());
1✔
13

1✔
14
    // write and read from cache from two different threads.
1✔
15

1✔
16
    let cache_writer = LmdbRwCache::new(
1✔
17
        CacheCommonOptions {
1✔
18
            max_readers: 1,
1✔
19
            max_db_size: 100,
1✔
20
            path: Some(path.clone()),
1✔
21
            intersection_chunk_size: 1,
1✔
22
        },
1✔
23
        CacheWriteOptions {
1✔
24
            max_size: 1024 * 1024,
1✔
25
        },
1✔
26
    )
1✔
27
    .unwrap();
1✔
28

1✔
29
    let (schema, secondary_indexes) = test_utils::schema_1();
1✔
30

1✔
31
    cache_writer
1✔
32
        .insert_schema("sample", &schema, &secondary_indexes)
1✔
33
        .unwrap();
1✔
34
    let items = vec![
1✔
35
        (1, Some("a".to_string()), Some(521)),
1✔
36
        (2, Some("a".to_string()), None),
1✔
37
        (3, None, Some(521)),
1✔
38
        (4, None, None),
1✔
39
    ];
1✔
40

×
41
    for val in items.clone() {
4✔
42
        lmdb_utils::insert_rec_1(&cache_writer, &schema, val.clone());
4✔
43
    }
4✔
44
    cache_writer.commit().unwrap();
1✔
45

1✔
46
    let read_options = CacheCommonOptions {
1✔
47
        path: Some(path),
1✔
48
        ..Default::default()
1✔
49
    };
1✔
50
    let cache_reader = LmdbRoCache::new(read_options).unwrap();
1✔
51
    for (a, b, c) in items {
5✔
52
        let rec = cache_reader.get(&Field::Int(a).encode()).unwrap();
4✔
53
        let values = vec![
4✔
54
            Field::Int(a),
4✔
55
            b.map_or(Field::Null, Field::String),
4✔
56
            c.map_or(Field::Null, Field::Int),
4✔
57
        ];
4✔
58
        assert_eq!(rec.values, values, "should be equal");
4✔
59
    }
60
    let records = cache_reader
1✔
61
        .query(
1✔
62
            "sample",
1✔
63
            &QueryExpression {
1✔
64
                filter: Some(FilterExpression::Simple(
1✔
65
                    "a".to_string(),
1✔
66
                    Operator::EQ,
1✔
67
                    Value::from(1),
1✔
68
                )),
1✔
69
                ..Default::default()
1✔
70
            },
1✔
71
        )
1✔
72
        .unwrap();
1✔
73
    assert_eq!(records.len(), 1);
1✔
74
}
1✔
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

© 2026 Coveralls, Inc