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

add page_sort and fix bugs #7

Closed
wants to merge 10 commits into from

Conversation

Keniis0712
Copy link
Contributor

No description provided.

}

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)
Copy link
Owner

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>{
Copy link
Owner

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;
Copy link
Owner

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;
Copy link
Owner

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch

@Codetector1374
Copy link
Owner

This looks like src/bin/tablespace_sort.rs already implemented this, so I will close the PR for now.

if bytes_read == 0 {
break;
}
destination.seek(std::io::SeekFrom::Start(destination_offset))?;
Copy link
Owner

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"

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

Successfully merging this pull request may close these issues.

2 participants