Skip to content
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

Rust and Go implementations #9

Open
davebryson opened this issue Sep 14, 2018 · 8 comments
Open

Rust and Go implementations #9

davebryson opened this issue Sep 14, 2018 · 8 comments

Comments

@davebryson
Copy link

For anyone interested, Go and Rust implementations are in the works here:
Rust version . (primary focus)
Go version

Goal is to provide both a file based store and a key/value store as an alternative

@chjj
Copy link
Contributor

chjj commented Sep 30, 2018

Wow, totally awesome! Now we just need a C implementation and we have all the bases covered. :)

@chjj
Copy link
Contributor

chjj commented Oct 1, 2018

I noticed you added flags as a member of the node struct in the rust impl. That flags field probably isn't as necessary for rust. In node.js it's just meant to keep heat off of the javascript GC (having one field packed into bits is smaller than having multiple properties on the object). Rust probably has the luxury of making things a lot cleaner since it has no GC overhead.

@adrianbrink
Copy link

adrianbrink commented Oct 1, 2018

It is possible to export a C api from the Rust implementation. That way we don't have to maintain an extra implementation. Even for other languages we can simply write thin wrappers around the C implementation.

Rust FFI
Rust FFI Examples

@davebryson
Copy link
Author

I noticed you added flags as a member of the node struct in the rust impl. That flags field probably isn't as necessary for rust.

Ahhh, ok. I need to work through that a bit more. I actually have some uncommitted refactoring and updates I'll add that to.

@davebryson
Copy link
Author

It is possible to export a C api from the Rust implementation. That way we don't have to maintain an extra implementation. Even for other languages we can simply write thin wrappers around the C implementation.

Haven't really thought about that much. Am trying to see how far I can get with a "safe" implementation.

@adrianbrink
Copy link

Exposing methods to C is still safe. It only means that the Rust compiler does the memory layout in a way which is compatible with C. This is arguably the best part of the Rust FFI. It allows you to gradually replace old unsafe C code with safe Rust code.

@davebryson
Copy link
Author

@chjj Regarding flags, I can't seem to find any where in the code base where the setter node.leaf = ... is actually used. It appears flag values come solely from the node.pos setter, is that correct? Part of my confusion here is probably coming from me trying to grok the low level storage layout/format

@davebryson
Copy link
Author

In case there's any interest, the latest Rust version now has the initial file store working:
ukel-trie. Not complete, but getting there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants