Hacker Newsnew | past | comments | ask | show | jobs | submit | dcb18's commentslogin

This is incorrect, only reads from the current Raft master are guaranteed to not be stale. In the case of InfluxDB, I think caching is safe because the shard metadata is immutable.


Where are you seeing that cluster metadata is immutable? I don't even know how that would work. Surely nodes, databases, shards, users, permissions, etc. all can change?


Yep, you're right.


A trait is a type, but the type does not have a size, which is the reason it is not possible to store a trait instance directly in a Vec (or any other place needing a sized type). It is possible to store a pointer to a trait object in a Vec, which would look like Vec<Box<CanineTrait>>.


Ah, my mistake. So would I be correct in saying that a trait is a type, but it does not necessarily implement the Sized trait, and if it does not, then it cannot be allocated directly on the stack?

Also, I've been wondering something about dereferencing a Box where the inner type is just a trait. If I dereference a Box<CanineTrait> and call "bark," how is the correct implementation found at runtime? Is there a vtable or something analogous?


Trait object pointers are "fat"- they consist of both a pointer to the object and a vtable pointer (much like Go interfaces if you've used those). Other DSTs are similar- pointers to slices consist of both a pointer to the elements and a count.


> If I dereference a Box<CanineTrait> and call "bark," how is the correct implementation found at runtime? Is there a vtable or something analogous?

I think a vtable. It's my understanding that "trait objects" (boxed traits) are how you implement dynamic dispatch in rust. If instead you were talking about a `fn foo<T: CanineTrait>(x: T) { ... }` trait bound (the more common case), there will be monomorphization and static dispatch.

Source: http://doc.rust-lang.org/1.0.0-beta/book/static-and-dynamic-...


After the beta landed, I re-did the TOC for the book, and so this information will be at http://doc.rust-lang.org/nightly/book/trait-objects.html in the future. (where nightly = 1.0.0, of course)


checkout `ssh -A`


I am in a similar situation, my answer is to take as much of the Stanford db class over the break as possible, and take the alternate at school. Although the deadline for all the exercises have passed you can still watch the videos and do the exercises / quizzes. http://www.db-class.org


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: