-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
new sstable format #1943
Merged
Merged
new sstable format #1943
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
117c60a
document a new sstable format
trinity-1686a bdec47e
use a different convention to describe sstable format
trinity-1686a b5666e8
add support for changing target block size
trinity-1686a 44a353c
use new format for sstable index
trinity-1686a 7b285b5
handle sstable version errror
trinity-1686a 194c80a
use very small blocks for proptests
trinity-1686a e8996c0
fix size of sstable in colunmar tests
trinity-1686a 403ceea
fix typos and spelling
trinity-1686a 81d871f
add a footer structure
trinity-1686a File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use std::io::{self, Read, Write}; | ||
|
||
use crate::BinarySerializable; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
#[repr(u32)] | ||
pub enum DictionaryKind { | ||
Fst = 1, | ||
SSTable = 2, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct DictionaryFooter { | ||
pub kind: DictionaryKind, | ||
pub version: u32, | ||
} | ||
|
||
impl DictionaryFooter { | ||
pub fn verify_equal(&self, other: &DictionaryFooter) -> io::Result<()> { | ||
if self.kind != other.kind { | ||
return Err(io::Error::new( | ||
io::ErrorKind::Other, | ||
format!( | ||
"Invalid dictionary type, expected {:?}, found {:?}", | ||
self.kind, other.kind | ||
), | ||
)); | ||
} | ||
if self.version != other.version { | ||
return Err(io::Error::new( | ||
io::ErrorKind::Other, | ||
format!( | ||
"Unsuported dictionary version, expected {}, found {}", | ||
self.version, other.version | ||
), | ||
)); | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl BinarySerializable for DictionaryFooter { | ||
fn serialize<W: Write + ?Sized>(&self, writer: &mut W) -> io::Result<()> { | ||
self.version.serialize(writer)?; | ||
(self.kind as u32).serialize(writer) | ||
} | ||
fn deserialize<R: Read>(reader: &mut R) -> io::Result<Self> { | ||
let version = u32::deserialize(reader)?; | ||
let kind = u32::deserialize(reader)?; | ||
let kind = match kind { | ||
1 => DictionaryKind::Fst, | ||
2 => DictionaryKind::SSTable, | ||
_ => { | ||
return Err(io::Error::new( | ||
io::ErrorKind::Other, | ||
format!("invalid dictionary kind: {kind}"), | ||
)) | ||
} | ||
}; | ||
|
||
Ok(DictionaryFooter { kind, version }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Great comment. This also implies that we do not support redundant keys. Is it written somewhere in this document?
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 think it is, this could be rephrased as
to include that information
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.
oups, I forgot to add that before merging. I'll add it in the compression PR, or as an independent PR if it compression end up not making it