Respect directive order when writing trees

korrat
Dec 17, 2022, 10:16 AM
X6YJF46GPT3KOVC3MJPJRPWLW6PEECFXFJLMFHDFOADYJGX3EXUQC

Dependencies

  • [2] 2NYDNXH7 Use OS dependent path separator when constructing paths in tree writer
  • [3] MG46NYAC enable deserialization of configuration for common utilities
  • [4] D6UTHZA4 add a simple writer for saving a set of directives to a tree of files
  • [5] 2JBFREZG enable additional warnings

Change contents

  • replacement in common/beancount-tree-writer/src/lib.rs at line 15
    [3.342][3.342:364]()
    use dashmap::DashMap;
    [3.238]
    [2.16]
    use itertools::Itertools as _;
  • replacement in common/beancount-tree-writer/src/lib.rs at line 55
    [3.538][3.1462:1533](),[3.1462][3.1462:1533](),[3.1533][3.1533:1774]()
    let accounts = DashMap::<_, Vec<_>>::new();
    directives
    .into_par_iter()
    .for_each_with(&accounts, |directives, directive| {
    let index = (&directive).try_into().unwrap();
    directives.entry(index).or_default().push(directive);
    });
    [3.538]
    [3.1774]
    let accounts = directives
    .into_iter()
    .into_group_map_by(|directive| DirectiveIndex::try_from(directive).unwrap());
  • replacement in common/beancount-tree-writer/src/lib.rs at line 80
    [2.290][3.2397:2450](),[3.805][3.2397:2450](),[3.2397][3.2397:2450]()
    directives.par_sort_by_key(Directive::date);
    [2.290]
    [3.2450]
    directives.par_sort_by(|left, right| {
    left.timestamp().zip(right.timestamp()).map_or_else(
    || left.date().cmp(&right.date()),
    |(left, right)| left.cmp(&right),
    )
    });