Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "zudb-node"
version = "0.0.1"
edition = "2024"
rust-version = "1.97"
rust-version = "1.98"
license = "Apache-2.0"
repository = "https://github.com/tamnd/zu-node"
authors = ["Tam Nguyen <tamnd87@gmail.com>"]
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# a different build of the same code. Held to the version in
# tamnd/zu's toolchains.toml.
[toolchain]
channel = "1.97.1"
channel = "1.98.0"
components = ["rustfmt", "clippy"]
27 changes: 21 additions & 6 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,33 @@ impl Bytes {
/// what the words mean is the layout's business and does not change
/// on the way.
fn extend(&mut self, raw: &[u8]) {
// `as_chunks` hands back arrays rather than slices, so the width
// is in the type and the conversion that used to sit in the
// middle of each line is gone along with the panic it carried.
// A remainder is bytes that are not a whole element, which is a
// caller handing over something that is not this column, and
// dropping it is what `chunks_exact` did too.
match self {
Bytes::Eight(v) => v.extend(
raw.chunks_exact(8)
.map(|word| u64::from_ne_bytes(word.try_into().expect("eight bytes"))),
raw.as_chunks::<8>()
.0
.iter()
.copied()
.map(u64::from_ne_bytes),
),
Bytes::Four(v) => v.extend(
raw.chunks_exact(4)
.map(|word| u32::from_ne_bytes(word.try_into().expect("four bytes"))),
raw.as_chunks::<4>()
.0
.iter()
.copied()
.map(u32::from_ne_bytes),
),
Bytes::Two(v) => v.extend(
raw.chunks_exact(2)
.map(|word| u16::from_ne_bytes(word.try_into().expect("two bytes"))),
raw.as_chunks::<2>()
.0
.iter()
.copied()
.map(u16::from_ne_bytes),
),
Bytes::One(v) => v.extend_from_slice(raw),
Bytes::Offsets(_) => {}
Expand Down
7 changes: 5 additions & 2 deletions src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,12 @@ fn pairs(env: &Env, options: &Object<'_>, rows: u64) -> Result<Vec<(u32, u32)>>
flat.len()
)));
}
// A pair is a pair in the type, so the two indexes below are not
// indexes any more and the odd tail `as_chunks` would hand back
// is already refused above.
let mut pairs = Vec::with_capacity(flat.len() / 2);
for (at, edge) in flat.chunks_exact(2).enumerate() {
pairs.push((within(at, edge[0])?, within(at, edge[1])?));
for (at, &[from, to]) in flat.as_chunks::<2>().0.iter().enumerate() {
pairs.push((within(at, from)?, within(at, to)?));
}
return Ok(pairs);
}
Expand Down
Loading