sdd/kiddo

chunk_length <= capacity

Closed this issue · 12 comments

I'm failing this assertion and I can't guess what it means.

I'm calling ImmutableKdTree::new_from_slice on kiddo 4.0.0.

Any pointers?

KdTree::from works fine with the same input

Same issue here. I'm calling ImmutableKdTree::new_from_slice on a Vec<[f64; 2]> of size 34132.

sdd commented

Hi Mike and David,

It looks like you've uncovered a bug in the logic for the immutable tree construction.

Are either of you able to share a reproducible example with some data that triggers this? If so I will work on a fix. The standard float tree should work in the meantime.

Thanks for reporting!

Thanks for looking into this @sdd. This is what caused the issue for me (if KdTree is replaced with ImmutableKdTree in main.rs).
Also, here's the data that I'm passing to ImmutableKdTree::new_from_slice, serialized with rkyv, if that helps: coords_list.zip

Any update on this? Seeing this as well.

sdd commented

Hi all. I've been a bit short of time recently but I'll be looking to get this fixed over the next week or so.

sdd commented

@dkter Do you have a link to the original dataset that was used to build the table? I've tried running the code in the link you sent against the coords_list.bin but I get a LayoutError from Rkyv on line 35

ah, sorry, the code in the readme is unrelated. The data in coords_list.bin is a Vec<[f64; 2]> that is being passed directly to ImmutableKdTree. You can test it out like this

fn main() {
    let args: Vec<_> = std::env::args().collect();
    let fpath = &args[1];
    let path = Path::new(&fpath);

    let mut file = File::open(&path).unwrap();
    let mut bytes = vec![];
    file.read_to_end(&mut bytes).unwrap();
    let coords = unsafe {
        rkyv::from_bytes_unchecked::<Vec<[f64; 2]>>(&bytes)
            .expect("Failed to deserialize KdTree")
    };
    let _ = ImmutableKdTree::new_from_slice(&coords);
}

Alternatively, the program in src/main.rs is what generates the dataset, and if you replace KdTree with ImmutableKdTree in that file and run it you should see the same issue

sdd commented

Great, thanks 👍🏼

sdd commented

image

I've got a fix for this now. Just merged to master, will release shortly.

sdd commented

Fix released in v4.2.0

Thank you!