Coder Social home page Coder Social logo

immutable-chunkmap's People

Contributors

eric-stokes-architect avatar estokes avatar mwcampbell avatar n8ta avatar waywardmonkeys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

immutable-chunkmap's Issues

Add a way to remove multiple keys at once

Following the availability of insert/update many it would be nice to also have something like remove_many.
Alternatively (or also) retain function (like in btree map) could be added to support such (and other) use-cases, though that one traverses the whole tree, so it could be too costly if removed set of keys is much smaller than overall keys in the tree.

In my specific use-case I actually need to remove a range of keys, which I imagine might have a fast specialized implementation possible, but I suppose this could as well be a specific scenario possible to exploit in remove_many (as docs mention insert_many being faster on sorted entries).

And thanks for this lib, it looks pretty solid and performs very well!

Removing multiple keys for MapM with >= 1024 entries panics

I found a scenario of initializing map content and updating it (just removals) that causes panic, the repo scenario is here:
https://github.com/kskalski/snippets/blob/master/immutable_chunklist_bug/src/main.rs

roughly the code like that:

fn main() {
    let initial: Vec<(u64, _)> = vec![(695931000000, 344), ...];
    let mut update = vec! [(1933094000000, 0), ...];
    println!("init {:?}, update {:?}", initial.len(), update.len());
    let mut map = immutable_chunkmap::map::MapM::from_iter(initial.into_iter());
    map.update_many(update, |_, _, _| {
            None
    });
}

ends up with

     Running `target/debug/immutable_chunklist_bug`
init 1024, update 16
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/nazgul/.cargo/registry/src/github.com-1ecc6299db9ec823/immutable-chunkmap-1.0.4/src/avl.rs:672:53
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:48:5
   3: core::option::Option<T>::unwrap
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/option.rs:775:21
   4: immutable_chunkmap::avl::Tree<K,V,_>::create
             at /home/nazgul/.cargo/registry/src/github.com-1ecc6299db9ec823/immutable-chunkmap-1.0.4/src/avl.rs:672:34
   5: immutable_chunkmap::avl::Tree<K,V,_>::update_chunk
             at /home/nazgul/.cargo/registry/src/github.com-1ecc6299db9ec823/immutable-chunkmap-1.0.4/src/avl.rs:792:17
   6: immutable_chunkmap::avl::Tree<K,V,_>::update_chunk
             at /home/nazgul/.cargo/registry/src/github.com-1ecc6299db9ec823/immutable-chunkmap-1.0.4/src/avl.rs:826:33
   7: immutable_chunkmap::avl::Tree<K,V,_>::update_chunk
             at /home/nazgul/.cargo/registry/src/github.com-1ecc6299db9ec823/immutable-chunkmap-1.0.4/src/avl.rs:826:33
   8: immutable_chunkmap::avl::Tree<K,V,_>::update_many
             at /home/nazgul/.cargo/registry/src/github.com-1ecc6299db9ec823/immutable-chunkmap-1.0.4/src/avl.rs:861:17
   9: immutable_chunkmap::map::Map<K,V,_>::update_many
             at /home/nazgul/.cargo/registry/src/github.com-1ecc6299db9ec823/immutable-chunkmap-1.0.4/src/map.rs:376:13
  10: immutable_chunklist_bug::main
             at ./src/main.rs:6:5
  11: core::ops::function::FnOnce::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

feeding it with any shorter initial set or update list or modifying the keys widely seem to no longer cause the panic.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.