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

getdozer / dozer / 4392484403

pending completion
4392484403

push

github

GitHub
feat: Asynchoronous indexing (#1206)

270 of 270 new or added lines in 13 files covered. (100.0%)

28714 of 38777 relevant lines covered (74.05%)

89484.24 hits per line

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

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

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

1✔
15
    let schema = test_utils::schema_1();
1✔
16
    let mut indexing_thread_pool = IndexingThreadPool::new(1);
1✔
17
    let cache_writer = LmdbRwCache::new(
1✔
18
        Some(&schema),
1✔
19
        &CacheCommonOptions {
1✔
20
            max_readers: 1,
1✔
21
            max_db_size: 100,
1✔
22
            path: Some(path.clone()),
1✔
23
            intersection_chunk_size: 1,
1✔
24
        },
1✔
25
        CacheWriteOptions {
1✔
26
            max_size: 1024 * 1024,
1✔
27
        },
1✔
28
        &mut indexing_thread_pool,
1✔
29
    )
1✔
30
    .unwrap();
1✔
31

1✔
32
    let items = vec![
1✔
33
        (1, Some("a".to_string()), Some(521)),
1✔
34
        (2, Some("a".to_string()), None),
1✔
35
        (3, None, Some(521)),
1✔
36
        (4, None, None),
1✔
37
    ];
1✔
38

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

1✔
44
    indexing_thread_pool.wait_until_catchup();
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.record.values, values, "should be equal");
4✔
59
    }
×
60
    let records = cache_reader
1✔
61
        .query(&QueryExpression {
1✔
62
            filter: Some(FilterExpression::Simple(
1✔
63
                "a".to_string(),
1✔
64
                Operator::EQ,
1✔
65
                Value::from(1),
1✔
66
            )),
1✔
67
            ..Default::default()
1✔
68
        })
1✔
69
        .unwrap();
1✔
70
    assert_eq!(records.len(), 1);
1✔
71
}
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