summaryrefslogtreecommitdiffstats
path: root/examples/lib-dfscq-log/src/main2.rs
blob: 9db235dede58b340d191790e916bc883eb78e669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
fn main() {
    let solver = Solver::new();
    let output = Output::new();

    let blue_transaction_len = 5;

    let blue_block = Block::builder().color(blue);
    let dark_gray_block = Block::builder().color(dark_gray);

    let log_layer = Layer::builder()
        .name("LogAPI")
        .push_entry(
            Entry::builder()
                .label("activeTxn: ")
                .content(
                    Blocks::builder()
                        .push(blue_transaction_len, blue_block.build())
                        .build(),
                )
                .build(),
        )
        .build();

    let other_transactions = [2, 7, 4];

    let group_commit_layer = Layer::builder()
        .name("GroupCommit")
        .push_entry(
            Entry::builder()
                .label("commitedTxn: ")
                .content(
                    BlockList::builder()
                        .append(
                            other_transactions
                                .iter()
                                // TODO: need collect?
                                .map(|len| Blocks::builder().push(len, dark_gray_block.build())),
                        )
                        .push(Blocks::builder().push(blue_transaction_len, blue_block.build()))
                        .build(),
                )
                .build(),
        )
        .build();

    let disk_log_layer = todo!();

    let applier_layer = todo!();

    let layers = &[
        &log_layer,
        &group_commit_layer,
        &disk_log_layer,
        &applier_layer,
    ];
    constraints::distribute_vertically(solver, layers);
    constraints::align_left(solver, layers);

    solver.solve();
    output.write_to_stdout(Output::Format::SVG);
}