You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture/encoding.md
+34-35Lines changed: 34 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Key/Value Encoding
2
2
3
3
The key/value store uses binary `Vec<u8>` keys and values, so we need an encoding scheme to
4
-
translate between Rust in-memory data structures and the on-disk binary data. This is provided by
4
+
translate between in-memory Rust data structures and the on-disk binary data. This is provided by
5
5
the [`encoding`](https://github.com/erikgrinaker/toydb/tree/213e5c02b09f1a3cac6a8bbd0a81773462f367f5/src/encoding)
6
6
module, with separate schemes for key and value encoding.
7
7
@@ -15,18 +15,19 @@ data type. But we could also have chosen e.g. [JSON](https://en.wikipedia.org/wi
15
15
We won't dwell on the actual binary format here, see the [Bincode specification](https://github.com/bincode-org/bincode/blob/trunk/docs/spec.md)
16
16
for details.
17
17
18
-
To use a consistent configuration for all encoding and decoding, we provide helper functions using
19
-
`bincode::config::standard()` in the [`encoding::bincode`](https://github.com/erikgrinaker/toydb/blob/213e5c02b09f1a3cac6a8bbd0a81773462f367f5/src/encoding/bincode.rs)
20
-
module:
18
+
To use a consistent configuration for all encoding and decoding, we provide helper functions in
19
+
the [`encoding::bincode`](https://github.com/erikgrinaker/toydb/blob/213e5c02b09f1a3cac6a8bbd0a81773462f367f5/src/encoding/bincode.rs)
module. It is implemented as a [Serde](https://serde.rs) (de)serializer, which
84
-
requires a lot of boilerplate code, but we'll just focus on the actual encoding.
81
+
toyDB provides an order-preserving encoding called "Keycode" in the[`encoding::keycode`](https://github.com/erikgrinaker/toydb/blob/213e5c02b09f1a3cac6a8bbd0a81773462f367f5/src/encoding/keycode.rs)
82
+
module. Like Bincode, the Keycode encoding is not self-describing: the binary data does not say what
83
+
the data type is, the caller must provide a type to decode into. It only supports a handful of
84
+
primitive data types, and only needs to order values of the same type.
85
85
86
-
Keycode only supports a handful of primary data types, and just needs to order values of the same
87
-
type:
86
+
Keycode is implemented as a [Serde](https://serde.rs) (de)serializer, which requires a lot of
87
+
boilerplate code to satisfy the trait, but we'll just focus on the actual encoding. The encoding
0 commit comments