-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: dynamic rather than static parameters #105
base: master
Are you sure you want to change the base?
Conversation
Some comments from an From a user's perspective, I think this is probably a good idea. It reduces "needless" generics and therefore overall complexity of the API, and it seems easier to work with and enables changing settings at runtime. What's the reason for the improvement in the benchmarks? I'd have expected static parameters not to be slower than runtime parameters... I'm concerned about the let params = Params::default() //could also be Params::new()
.with_max_size(my_max_size)
.with_reinsertion_count(2);
// we omit .with_min_size which leaves it the default |
Oh, and, perhaps you consider not implementing |
I haven't looked at the code changes yet; does this PR remove the insertion strategy altogether? I had been thinking I might try to dabble with an implementation of STR insertion strategy for static trees for data partitioning. |
This PR currently addresses two concerns: (1) supporting dynamic params; (2) simplifying the Reg. dynamic params, the current trait does indeed not support it, and it was probably designed to statically verify the fact that the sizes in the params do not change. Instead, we could change it to: pub trait RTreeParams: Send + Sync {
fn min_size(&self) -> usize;
fn max_size(&self) -> usize;
fn reinsertion_count(&self) -> usize;
type DefaultInsertionStrategy: InsertionStrategy;
} We can then implement this trait on the Or we could make the function into something like This way, we maintain the current generics and we can decide on dropping that independently. @msalib would you be able to try this in this PR? |
/// maintain a good tree quality. Must be smaller than `MAX_SIZE` - `MIN_SIZE`. | ||
/// Larger values will improve query times but increase insertion time. | ||
const REINSERTION_COUNT: usize; | ||
/// hi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi
rstar/CHANGELOG.md
if knowledge of this change could be valuable to users.Hi! This PR makes
RTree
parameters a single struct, namedParams
instead of a trait that clients have to provide as part of the type signature. I need that functionality for a project I'm working where the parameters have to be supplied externally and can't be baked into code statically -- we're experimenting with using RTrees for partitioning rather than lookups.This change produces a 3%-15% improvement on benchmarks.
Along the way, I've moved some checks into
Params::new
or into a static assert (in the case of the point dimension greater than 1 check).Although I made this PR to provide more flexibility to clients and although it has improved benchmarks, I think this change has made the API simpler as well.
Params
is just a single struct with a constructor. You don't have to deal with weird type magic.RTree<T>
has a single generic parameter,T
. In earlier versions of this PR, I made the insertion strategy another generic parameter forRTree
with a default value, but then dropped it because it cluttered up the code significantly; this crate is almost 5 years old and has only ever had one insertion strategy, so I didn't see the benefit in adding another generic parameter to support genericity that we haven't needed and are unlikely to need in the future.Tests and benchmarks pass but I still need to clean up the docs.