-
Notifications
You must be signed in to change notification settings - Fork 5
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 page_sort and fix bugs #7
Conversation
} | ||
|
||
fn arr2int(buf:&[u8; 4]) -> u32{ | ||
((buf[0] as u32) << 24) | ((buf[1] as u32) << 16) | ((buf[2] as u32) << 8) | (buf[3] as u32) |
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.
better to use u32::from_bytes_be
instead of re-implementing
((buf[0] as u32) << 24) | ((buf[1] as u32) << 16) | ((buf[2] as u32) << 8) | (buf[3] as u32) | ||
} | ||
|
||
fn get_page_number(pages: &mut File, offset: u64) -> Result<u64, Error>{ |
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.
Realistically we already have innodb::page::Page
probably use that.
} | ||
|
||
fn main(){ | ||
const PAGE_SIZE: usize = 16384; |
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.
Again, FIL_PAGE_SIZE
is already defined in innodb::page::FIL_PAGE_SIZE
let mut input_file = File::open(args.input).expect("Failed to open input file"); | ||
|
||
let total_bytes = input_file.seek(std::io::SeekFrom::End(0)).expect("Failed to get input file size"); | ||
let total_pages = total_bytes / PAGE_SIZE as 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.
Really you could just read until there is no more pages any more.
@@ -165,7 +165,7 @@ impl<'a> Row<'a> { | |||
let node = LobIndexEntry::try_from_bytes(buf)?; | |||
trace!("Index Node: {:#?}", node); | |||
|
|||
let mut bytes_read = 0usize; | |||
let bytes_read; |
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.
nice catch
This looks like |
if bytes_read == 0 { | ||
break; | ||
} | ||
destination.seek(std::io::SeekFrom::Start(destination_offset))?; |
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.
By the way, seeking beyond EOF is not guaranteed behavior, so we probably should handle this better than just "skipping"
No description provided.