-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add raw entries interface to ledger for getting slices as [u8] #1465
Conversation
src/ledger.rs
Outdated
file.seek(SeekFrom::Start(at))?; | ||
|
||
let len = deserialize_from(file.take(SIZEOF_U64)).map_err(err_bincode_to_io)?; | ||
trace!("entry_at({}) len: {}", at, len); | ||
let len_size = size_of::<u64>(); |
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.
I think you'd have less code if you used the index file to add up all the lengths first...
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.
yea.. thought of that. It's some extra reads but probably insignificant.
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.
a lot less math and deserialization, too
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.
Well I wrote it using the index, it didn't come out a lot better, mostly because I couldn't think of an elegant way to handle the last entry which you don't know the length of using the next one because there is no next one.
f1331c7
to
8d0b423
Compare
8d0b423
to
cf1c5e8
Compare
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.
I don't need to hold this up, the ledger is unlikely to stick in its current format for more than another few weeks, I fear.
My apologies for not being more clear: I was suggesting the index file could be used to get the first entry and last entry offsets from the index file (2 index reads). Then you'd read the length of the last entry from the data file, then you read from first offset to last offset + last length. 4 reads total no matter how many entries.
No description provided.