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

[optimization] Change SSTable serialized layout to enable varint and integer compression #308

Open
rajatkb opened this issue Oct 23, 2024 · 0 comments

Comments

@rajatkb
Copy link
Contributor

rajatkb commented Oct 23, 2024

The current SSTable layout works like the following : ref

	//  Then we have key-value pairs with length prefix
	//  ╭─────────┬────────────────┬────────────┬──────────────────╮
	//  │keyLength│ key            │ valueLength│ value            │
	//  ├─────────┼────────────────┼────────────┼──────────────────┤ ... repeat key-value pairs
	//  │4 bytes  │ keyLength bytes│ 4 bytes    │ valueLength bytes│
	//  ╰─────────┴────────────────┴────────────┴──────────────────╯
	//  Then we have 'index' which maps each key to its offset in the above key-value pairs
	//  SSTable.indexOffset refers to this point where 'index' begins

Suggestion to change the layout to the following

╭――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――╮
│key_length_byte_count (4byte)     │  <len 1 , len 2 .... >          │                                      
│value_length_byte_count (4byte)   │ <len 1 , len 2 .... >           │ 
│<key1 , key2 , key3 , key4 ....>  │ <value1 , value2 , value3 ...>  │
╰――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――╯

This would allow for

  • Use a combination of varint + run length encoding on both the key and value length data which were static 4 bytes prior
  • for both keys and values if they have a specific data type with certain kind of redundancy, e.g keys with prefixes or repeated null values we can employ some form of compression to handle redundant data.
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

No branches or pull requests

1 participant