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

agate: refactor for memtable impl #37

Merged
merged 20 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format
Signed-off-by: Alex Chi <[email protected]>
  • Loading branch information
skyzh committed Nov 4, 2020
commit 8b72bb1074cc94f0864517dd98772a037865b412
1 change: 1 addition & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ where
i
}

/// Fill a file with 0.
pub fn fill_file(file: &mut impl std::io::Write, mut size: u64) -> Result<()> {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just file.set_len(size)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll try

Copy link
Member Author

Choose a reason for hiding this comment

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

This function has been removed for now. We will directly call set_len on File, instead of creating this new function to handle that.

let buf = vec![0; 4096];
let buf_len = buf.len() as u64;
Expand Down
4 changes: 4 additions & 0 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub const VALUE_MERGE_ENTRY: u8 = 1 << 3;
pub const VALUE_TXN: u8 = 1 << 6;
pub const VALUE_FIN_TXN: u8 = 1 << 7;

/// Value of a kv pair is packed into `Value` struct with extra information.
#[derive(Default, Debug, Clone)]
pub struct Value {
pub meta: u8,
Expand Down Expand Up @@ -135,16 +136,19 @@ impl Value {
}
}

/// A request contains multiple entries to be written into LSM tree.
pub struct Request {
pub entries: Vec<Entry>,
}

/// `ValuePointer` records the position of value saved in value log.
pub struct ValuePointer {
pub file_id: u32,
pub len: u32,
pub offset: u32,
}

/// `EntryReader` reads entries from `BufReader`.
pub struct EntryReader {
key: Vec<u8>,
value: Vec<u8>,
Expand Down