-
Notifications
You must be signed in to change notification settings - Fork 10
Index generic over hash function #75
Comments
We should also support two modes of operation for the library:
|
This is a very interesting idea |
Maybe we can implement Check out |
@tareknaser When we finish #90 and move the code to ark-rust repo, is it a good idea to split "secure" and "fast" indexes into separate crates? This way we could create optimized index structure without counting collisions when we use secure hash functions. I also imagine creating something like |
I thought about this as well but couldn't find a straightforward solution. Ideally, I would prefer to decouple the index entirely from the resource ID computations, but this isn't feasible because we need to track collisions with non-cryptographic hash functions. Once this PR is merged alongside #87, I plan to dedicate some time to exploring options for conditionally compiling the collision resolution functionality. for example, we could do #[derive(PartialEq, Clone, Debug)]
pub struct ResourceIndex {
pub id2path: HashMap<ResourceId, CanonicalPathBuf>,
pub path2id: HashMap<CanonicalPathBuf, IndexEntry>,
#[cfg(feature = "non-cryptographic")]
pub collisions: HashMap<ResourceId, usize>,
root: PathBuf,
} but I would dive deeper into it when we settle on the API for |
@tareknaser I like how conditional compilation looks in your example.
If it'll have same ergonomics all over the crate, then we could stick to it. Single index implementation should be better. Although it might be a bit more complicated to maintain.
This
Not sure about this part. In fact, |
Actually, we already have such a crate: https://github.com/ARK-Builders/ark-rust/blob/main/data-resource |
Once the API in issue #91 is finalized, we'll likely simplify it. Additionally, some tests in Simplifying the API and including only essential unit tests related to
It may not be feasible at the moment, but there's an ongoing discussion about it. See rust-lang/cargo#2980 (comment) Maybe that could work as an integration test. We could create a simple shell script that uses
It's not coupled per se but if we're using a non-cryptographic |
We can abstract
ResourceIndex
over the id type and, consequently, over hashing function.This way, we can use cryptographic hash functions to test index in simpler cases, when no collisions are present. This can simplify development and debugging. We could also use fake hash functions for testing only collisions.
Cryptographic hash function can also be used for apps where safety is more important than performance. The fast hash functions will be used in experimental "fast mode", it's the most useful for file browser apps.
The text was updated successfully, but these errors were encountered: