From 9974a463274c111c948df72a1579123bb0f7ef12 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 11 Feb 2024 15:59:33 +0900 Subject: [PATCH] index: clarify parent entries are global positions I'm going to add change id overflow table whose elements are of LocalPosition type. Let's make sure that the serialization code would break if we changed the underlying data type. --- lib/src/default_index/mutable.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/src/default_index/mutable.rs b/lib/src/default_index/mutable.rs index d5e6a7987..26c1dd623 100644 --- a/lib/src/default_index/mutable.rs +++ b/lib/src/default_index/mutable.rs @@ -203,16 +203,16 @@ impl MutableIndexSegment { buf.extend((!0_u32).to_le_bytes()); buf.extend((!0_u32).to_le_bytes()); } - [pos1] => { - assert!(pos1.0 < OVERFLOW_FLAG); - buf.extend(pos1.0.to_le_bytes()); + [IndexPosition(pos1)] => { + assert!(*pos1 < OVERFLOW_FLAG); + buf.extend(pos1.to_le_bytes()); buf.extend((!0_u32).to_le_bytes()); } - [pos1, pos2] => { - assert!(pos1.0 < OVERFLOW_FLAG); - assert!(pos2.0 < OVERFLOW_FLAG); - buf.extend(pos1.0.to_le_bytes()); - buf.extend(pos2.0.to_le_bytes()); + [IndexPosition(pos1), IndexPosition(pos2)] => { + assert!(*pos1 < OVERFLOW_FLAG); + assert!(*pos2 < OVERFLOW_FLAG); + buf.extend(pos1.to_le_bytes()); + buf.extend(pos2.to_le_bytes()); } positions => { let overflow_pos = u32::try_from(parent_overflow.len()).unwrap(); @@ -237,10 +237,10 @@ impl MutableIndexSegment { buf.extend(pos.to_le_bytes()); } - buf[parent_overflow_offset..][..4] - .copy_from_slice(&u32::try_from(parent_overflow.len()).unwrap().to_le_bytes()); - for parent_pos in parent_overflow { - buf.extend(parent_pos.0.to_le_bytes()); + let num_parent_overflow = u32::try_from(parent_overflow.len()).unwrap(); + buf[parent_overflow_offset..][..4].copy_from_slice(&num_parent_overflow.to_le_bytes()); + for IndexPosition(pos) in parent_overflow { + buf.extend(pos.to_le_bytes()); } }