Skip to content

Commit 4804df2

Browse files
committed
Rename KeyCode to Keycode
1 parent ae321c4 commit 4804df2

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ SQL table scans) and has a couple of important implications:
125125
* Keys should use an order-preserving byte encoding, to allow range scans.
126126

127127
The engine itself does not care what keys contain, but the storage module offers
128-
an order-preserving key encoding called [KeyCode](https://github.com/erikgrinaker/toydb/blob/main/src/encoding/keycode.rs)
128+
an order-preserving key encoding called [Keycode](https://github.com/erikgrinaker/toydb/blob/main/src/encoding/keycode.rs)
129129
for use by higher layers. These storage layers often use composite keys made up
130130
of several possibly variable-length values (e.g. an index key consists of table,
131131
column, and value), and the natural ordering of each segment must be preserved,

src/encoding/keycode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! KeyCode is a lexicographical order-preserving binary encoding for use with
1+
//! Keycode is a lexicographical order-preserving binary encoding for use with
22
//! keys. It is designed for simplicity, not efficiency (i.e. it does not use
33
//! varints or other compression methods).
44
//!
@@ -10,7 +10,7 @@
1010
//! The encoding is not self-describing: the caller must provide a concrete type
1111
//! to decode into, and the binary key must conform to its structure.
1212
//!
13-
//! KeyCode supports a subset of primitive data types, encoded as follows:
13+
//! Keycode supports a subset of primitive data types, encoded as follows:
1414
//!
1515
//! * [`bool`]: `0x00` for `false`, `0x01` for `true`.
1616
//! * [`u64`]: big-endian binary representation.
@@ -48,7 +48,7 @@ use serde::ser::{Impossible, Serialize, SerializeSeq, SerializeTuple, SerializeT
4848
use crate::errdata;
4949
use crate::error::{Error, Result};
5050

51-
/// Serializes a key to a binary KeyCode representation.
51+
/// Serializes a key to a binary Keycode representation.
5252
///
5353
/// In the common case, the encoded key is borrowed for a storage engine call
5454
/// and then thrown away. We could avoid a bunch of allocations by taking a
@@ -62,7 +62,7 @@ pub fn serialize<T: Serialize>(key: &T) -> Vec<u8> {
6262
serializer.output
6363
}
6464

65-
/// Deserializes a key from a binary KeyCode representation.
65+
/// Deserializes a key from a binary Keycode representation.
6666
pub fn deserialize<'a, T: Deserialize<'a>>(input: &'a [u8]) -> Result<T> {
6767
let mut deserializer = Deserializer::from_bytes(input);
6868
let t = T::deserialize(&mut deserializer)?;
@@ -381,7 +381,7 @@ impl<'de> serde::de::Deserializer<'de> for &mut Deserializer<'de> {
381381
type Error = Error;
382382

383383
fn deserialize_any<V: Visitor<'de>>(self, _: V) -> Result<V::Value> {
384-
panic!("must provide type, KeyCode is not self-describing")
384+
panic!("must provide type, Keycode is not self-describing")
385385
}
386386

387387
fn deserialize_bool<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value> {

src/sql/engine/local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl<E: storage::Engine> Catalog for Transaction<E> {
382382
}
383383
}
384384

385-
/// SQL engine keys, using the KeyCode order-preserving encoding. For
385+
/// SQL engine keys, using the Keycode order-preserving encoding. For
386386
/// simplicity, table and column names are used directly as identifiers in
387387
/// keys, instead of e.g. numberic IDs. It is not possible to change
388388
/// table/column names, so this is fine.

src/storage/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::error::Result;
1111
/// have a common key prefix), or to scan the tail of the Raft log (after a
1212
/// given log entry index).
1313
///
14-
/// Keys should use the KeyCode order-preserving encoding, see
14+
/// Keys should use the Keycode order-preserving encoding, see
1515
/// [`crate::encoding::keycode`].
1616
///
1717
/// Writes are only guaranteed durable after calling [`Engine::flush()`].

src/storage/mvcc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub type Version = u64;
159159

160160
impl encoding::Value for Version {}
161161

162-
/// MVCC keys, using the KeyCode encoding which preserves the ordering and
162+
/// MVCC keys, using the Keycode encoding which preserves the ordering and
163163
/// grouping of keys.
164164
///
165165
/// Cow byte slices allow encoding borrowed values and decoding owned values.
@@ -600,7 +600,7 @@ impl<E: Engine> Transaction<E> {
600600
pub fn scan_prefix(&self, prefix: &[u8]) -> ScanIterator<E> {
601601
// Normally, KeyPrefix::Version will only match all versions of the
602602
// exact given key. We want all keys maching the prefix, so we chop off
603-
// the KeyCode byte slice terminator 0x0000 at the end.
603+
// the Keycode byte slice terminator 0x0000 at the end.
604604
let mut prefix = KeyPrefix::Version(prefix.into()).encode();
605605
prefix.truncate(prefix.len() - 2);
606606
let range = keycode::prefix_range(&prefix);

0 commit comments

Comments
 (0)