From 6d4176549d4e302bb64dbef59718f0b621954cd0 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 23 Aug 2024 16:34:06 +0100 Subject: [PATCH] Fix range queries and flaky tests (#4597) --- core/src/key/database/ac.rs | 4 ++-- core/src/key/database/access/gr.rs | 4 ++-- core/src/key/database/az.rs | 4 ++-- core/src/key/database/fc.rs | 4 ++-- core/src/key/database/ml.rs | 4 ++-- core/src/key/database/pa.rs | 4 ++-- core/src/key/database/tb.rs | 4 ++-- core/src/key/database/ts.rs | 8 ++++---- core/src/key/database/us.rs | 4 ++-- core/src/key/namespace/ac.rs | 4 ++-- core/src/key/namespace/access/gr.rs | 4 ++-- core/src/key/namespace/db.rs | 4 ++-- core/src/key/namespace/us.rs | 4 ++-- core/src/key/node/lq.rs | 6 +++--- core/src/key/root/ac.rs | 4 ++-- core/src/key/root/access/gr.rs | 4 ++-- core/src/key/root/nd.rs | 6 +++--- core/src/key/root/ns.rs | 4 ++-- core/src/key/root/us.rs | 4 ++-- core/src/key/table/ev.rs | 4 ++-- core/src/key/table/fd.rs | 4 ++-- core/src/key/table/ft.rs | 4 ++-- core/src/key/table/ix.rs | 4 ++-- core/src/key/table/lq.rs | 6 +++--- core/src/key/thing/mod.rs | 4 ++-- 25 files changed, 55 insertions(+), 55 deletions(-) diff --git a/core/src/key/database/ac.rs b/core/src/key/database/ac.rs index 7b991ad1..da191e9f 100644 --- a/core/src/key/database/ac.rs +++ b/core/src/key/database/ac.rs @@ -24,13 +24,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, ac: &'a str) -> Ac<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = crate::key::database::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'c', 0x00]); + k.extend_from_slice(b"!ac\x00"); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = crate::key::database::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'c', 0xff]); + k.extend_from_slice(b"!ac\xff"); k } diff --git a/core/src/key/database/access/gr.rs b/core/src/key/database/access/gr.rs index dc6473f4..c2070725 100644 --- a/core/src/key/database/access/gr.rs +++ b/core/src/key/database/access/gr.rs @@ -26,13 +26,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, ac: &'a str, gr: &'a str) -> Gr<'a> { pub fn prefix(ns: &str, db: &str, ac: &str) -> Vec { let mut k = super::all::new(ns, db, ac).encode().unwrap(); - k.extend_from_slice(&[b'!', b'g', b'r', 0x00]); + k.extend_from_slice(b"!gr\x00"); k } pub fn suffix(ns: &str, db: &str, ac: &str) -> Vec { let mut k = super::all::new(ns, db, ac).encode().unwrap(); - k.extend_from_slice(&[b'!', b'g', b'r', 0xff]); + k.extend_from_slice(b"!gr\xff"); k } diff --git a/core/src/key/database/az.rs b/core/src/key/database/az.rs index 131d8717..1303fdac 100644 --- a/core/src/key/database/az.rs +++ b/core/src/key/database/az.rs @@ -24,13 +24,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Az<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'z', 0x00]); + k.extend_from_slice(b"!az\x00"); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'z', 0xff]); + k.extend_from_slice(b"!az\xff"); k } diff --git a/core/src/key/database/fc.rs b/core/src/key/database/fc.rs index 5aeddd3c..de9e9d8c 100644 --- a/core/src/key/database/fc.rs +++ b/core/src/key/database/fc.rs @@ -24,13 +24,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, fc: &'a str) -> Fc<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'f', b'n', 0x00]); + k.extend_from_slice(b"!fn\x00"); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'f', b'n', 0xff]); + k.extend_from_slice(b"!fn\xff"); k } diff --git a/core/src/key/database/ml.rs b/core/src/key/database/ml.rs index e662056b..7481ed99 100644 --- a/core/src/key/database/ml.rs +++ b/core/src/key/database/ml.rs @@ -25,13 +25,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, ml: &'a str, vn: &'a str) -> Ml<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'm', b'l', 0x00]); + k.extend_from_slice(b"!ml\x00"); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'm', b'l', 0xff]); + k.extend_from_slice(b"!ml\xff"); k } diff --git a/core/src/key/database/pa.rs b/core/src/key/database/pa.rs index 6164f99d..e2ecc6f5 100644 --- a/core/src/key/database/pa.rs +++ b/core/src/key/database/pa.rs @@ -24,13 +24,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, pa: &'a str) -> Pa<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'p', b'a', 0x00]); + k.extend_from_slice(b"!pa\x00"); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'p', b'a', 0xff]); + k.extend_from_slice(b"!pa\xff"); k } diff --git a/core/src/key/database/tb.rs b/core/src/key/database/tb.rs index 924ca8d9..b6b1a0c7 100644 --- a/core/src/key/database/tb.rs +++ b/core/src/key/database/tb.rs @@ -24,13 +24,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Tb<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b't', b'b', 0x00]); + k.extend_from_slice(b"!tb\x00"); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b't', b'b', 0xff]); + k.extend_from_slice(b"!tb\xff"); k } diff --git a/core/src/key/database/ts.rs b/core/src/key/database/ts.rs index ec45e263..930da4f5 100644 --- a/core/src/key/database/ts.rs +++ b/core/src/key/database/ts.rs @@ -27,15 +27,15 @@ pub fn new<'a>(ns: &'a str, db: &'a str, ts: u64) -> Ts<'a> { /// Returns the prefix for the whole database timestamps pub fn prefix(ns: &str, db: &str) -> Vec { - let mut k = crate::key::database::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(b"!ts"); + let mut k = super::all::new(ns, db).encode().unwrap(); + k.extend_from_slice(b"!ts\x00"); k } /// Returns the prefix for the whole database timestamps pub fn suffix(ns: &str, db: &str) -> Vec { - let mut k = prefix(ns, db); - k.extend_from_slice(&[0xff]); + let mut k = super::all::new(ns, db).encode().unwrap(); + k.extend_from_slice(b"!ts\xff"); k } diff --git a/core/src/key/database/us.rs b/core/src/key/database/us.rs index 4b48ba5e..43f4a1d0 100644 --- a/core/src/key/database/us.rs +++ b/core/src/key/database/us.rs @@ -24,13 +24,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, user: &'a str) -> Us<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'u', b's', 0x00]); + k.extend_from_slice(b"!us\x00"); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::all::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[b'!', b'u', b's', 0xff]); + k.extend_from_slice(b"!us\xff"); k } diff --git a/core/src/key/namespace/ac.rs b/core/src/key/namespace/ac.rs index 7d7d5d44..4e3f6ffd 100644 --- a/core/src/key/namespace/ac.rs +++ b/core/src/key/namespace/ac.rs @@ -22,13 +22,13 @@ pub fn new<'a>(ns: &'a str, ac: &'a str) -> Ac<'a> { pub fn prefix(ns: &str) -> Vec { let mut k = crate::key::namespace::all::new(ns).encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'c', 0x00]); + k.extend_from_slice(b"!ac\x00"); k } pub fn suffix(ns: &str) -> Vec { let mut k = crate::key::namespace::all::new(ns).encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'c', 0xff]); + k.extend_from_slice(b"!ac\xff"); k } diff --git a/core/src/key/namespace/access/gr.rs b/core/src/key/namespace/access/gr.rs index 449bd983..3ea6c9c6 100644 --- a/core/src/key/namespace/access/gr.rs +++ b/core/src/key/namespace/access/gr.rs @@ -24,13 +24,13 @@ pub fn new<'a>(ns: &'a str, ac: &'a str, gr: &'a str) -> Gr<'a> { pub fn prefix(ns: &str, ac: &str) -> Vec { let mut k = super::all::new(ns, ac).encode().unwrap(); - k.extend_from_slice(&[b'!', b'g', b'r', 0x00]); + k.extend_from_slice(b"!gr\x00"); k } pub fn suffix(ns: &str, ac: &str) -> Vec { let mut k = super::all::new(ns, ac).encode().unwrap(); - k.extend_from_slice(&[b'!', b'g', b'r', 0xff]); + k.extend_from_slice(b"!gr\xff"); k } diff --git a/core/src/key/namespace/db.rs b/core/src/key/namespace/db.rs index 03632dda..7aa0bb3f 100644 --- a/core/src/key/namespace/db.rs +++ b/core/src/key/namespace/db.rs @@ -22,13 +22,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str) -> Db<'a> { pub fn prefix(ns: &str) -> Vec { let mut k = super::all::new(ns).encode().unwrap(); - k.extend_from_slice(&[b'!', b'd', b'b', 0x00]); + k.extend_from_slice(b"!db\x00"); k } pub fn suffix(ns: &str) -> Vec { let mut k = super::all::new(ns).encode().unwrap(); - k.extend_from_slice(&[b'!', b'd', b'b', 0xff]); + k.extend_from_slice(b"!db\xff"); k } diff --git a/core/src/key/namespace/us.rs b/core/src/key/namespace/us.rs index 1b0b4bd0..0b4782e6 100644 --- a/core/src/key/namespace/us.rs +++ b/core/src/key/namespace/us.rs @@ -22,13 +22,13 @@ pub fn new<'a>(ns: &'a str, user: &'a str) -> Us<'a> { pub fn prefix(ns: &str) -> Vec { let mut k = super::all::new(ns).encode().unwrap(); - k.extend_from_slice(&[b'!', b'u', b's', 0x00]); + k.extend_from_slice(b"!us\x00"); k } pub fn suffix(ns: &str) -> Vec { let mut k = super::all::new(ns).encode().unwrap(); - k.extend_from_slice(&[b'!', b'u', b's', 0xff]); + k.extend_from_slice(b"!us\xff"); k } diff --git a/core/src/key/node/lq.rs b/core/src/key/node/lq.rs index 300fd33a..a8ff47a5 100644 --- a/core/src/key/node/lq.rs +++ b/core/src/key/node/lq.rs @@ -30,13 +30,13 @@ pub fn new(nd: Uuid, lq: Uuid) -> Lq { pub fn prefix(nd: Uuid) -> Vec { let mut k = super::all::new(nd).encode().unwrap(); - k.extend_from_slice(&[b'!', b'l', b'q', 0x00]); + k.extend_from_slice(b"!lq\x00"); k } pub fn suffix(nd: Uuid) -> Vec { let mut k = super::all::new(nd).encode().unwrap(); - k.extend_from_slice(&[b'!', b'l', b'q', 0xff]); + k.extend_from_slice(b"!lq\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00"); k } @@ -103,7 +103,7 @@ mod tests { assert_eq!( val, b"/$\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\ - !lq\xff" + !lq\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00" ); } } diff --git a/core/src/key/root/ac.rs b/core/src/key/root/ac.rs index 49bce3f2..dd9c59e3 100644 --- a/core/src/key/root/ac.rs +++ b/core/src/key/root/ac.rs @@ -20,13 +20,13 @@ pub fn new(ac: &str) -> Ac<'_> { pub fn prefix() -> Vec { let mut k = crate::key::root::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'c', 0x00]); + k.extend_from_slice(b"!ac\x00"); k } pub fn suffix() -> Vec { let mut k = crate::key::root::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'a', b'c', 0xff]); + k.extend_from_slice(b"!ac\xff"); k } diff --git a/core/src/key/root/access/gr.rs b/core/src/key/root/access/gr.rs index d48f1f4c..a80b20ac 100644 --- a/core/src/key/root/access/gr.rs +++ b/core/src/key/root/access/gr.rs @@ -22,13 +22,13 @@ pub fn new<'a>(ac: &'a str, gr: &'a str) -> Gr<'a> { pub fn prefix(ac: &str) -> Vec { let mut k = super::all::new(ac).encode().unwrap(); - k.extend_from_slice(&[b'!', b'g', b'r', 0x00]); + k.extend_from_slice(b"!gr\x00"); k } pub fn suffix(ac: &str) -> Vec { let mut k = super::all::new(ac).encode().unwrap(); - k.extend_from_slice(&[b'!', b'g', b'r', 0xff]); + k.extend_from_slice(b"!gr\xff"); k } diff --git a/core/src/key/root/nd.rs b/core/src/key/root/nd.rs index ee89f12e..c9f72d21 100644 --- a/core/src/key/root/nd.rs +++ b/core/src/key/root/nd.rs @@ -24,13 +24,13 @@ pub fn new(nd: Uuid) -> Nd { pub fn prefix() -> Vec { let mut k = crate::key::root::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'n', b'd', 0x00]); + k.extend_from_slice(b"!nd\x00"); k } pub fn suffix() -> Vec { let mut k = crate::key::root::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'n', b'd', 0xff]); + k.extend_from_slice(b"!nd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00"); k } @@ -72,6 +72,6 @@ mod tests { #[test] fn test_suffix() { let val = super::suffix(); - assert_eq!(val, b"/!nd\xff") + assert_eq!(val, b"/!nd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00") } } diff --git a/core/src/key/root/ns.rs b/core/src/key/root/ns.rs index aed59a1e..c60aee22 100644 --- a/core/src/key/root/ns.rs +++ b/core/src/key/root/ns.rs @@ -20,13 +20,13 @@ pub fn new(ns: &str) -> Ns<'_> { pub fn prefix() -> Vec { let mut k = super::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'n', b's', 0x00]); + k.extend_from_slice(b"!ns\x00"); k } pub fn suffix() -> Vec { let mut k = super::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'n', b's', 0xff]); + k.extend_from_slice(b"!ns\xff"); k } diff --git a/core/src/key/root/us.rs b/core/src/key/root/us.rs index d5b7679f..4c48487b 100644 --- a/core/src/key/root/us.rs +++ b/core/src/key/root/us.rs @@ -20,13 +20,13 @@ pub fn new(user: &str) -> Us<'_> { pub fn prefix() -> Vec { let mut k = super::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'u', b's', 0x00]); + k.extend_from_slice(b"!us\x00"); k } pub fn suffix() -> Vec { let mut k = super::all::new().encode().unwrap(); - k.extend_from_slice(&[b'!', b'u', b's', 0xff]); + k.extend_from_slice(b"!us\xff"); k } diff --git a/core/src/key/table/ev.rs b/core/src/key/table/ev.rs index b5b5d2a4..08797091 100644 --- a/core/src/key/table/ev.rs +++ b/core/src/key/table/ev.rs @@ -26,13 +26,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ev: &'a str) -> Ev<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'e', b'v', 0x00]); + k.extend_from_slice(b"!ev\x00"); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'e', b'v', 0xff]); + k.extend_from_slice(b"!ev\xff"); k } diff --git a/core/src/key/table/fd.rs b/core/src/key/table/fd.rs index 3a269ea5..ca6cd249 100644 --- a/core/src/key/table/fd.rs +++ b/core/src/key/table/fd.rs @@ -26,13 +26,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, fd: &'a str) -> Fd<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'f', b'd', 0x00]); + k.extend_from_slice(b"!fd\x00"); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'f', b'd', 0xff]); + k.extend_from_slice(b"!fd\xff"); k } diff --git a/core/src/key/table/ft.rs b/core/src/key/table/ft.rs index 13b85f66..d00b72d3 100644 --- a/core/src/key/table/ft.rs +++ b/core/src/key/table/ft.rs @@ -26,13 +26,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ft: &'a str) -> Ft<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'f', b't', 0x00]); + k.extend_from_slice(b"!ft\x00"); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'f', b't', 0xff]); + k.extend_from_slice(b"!ft\xff"); k } diff --git a/core/src/key/table/ix.rs b/core/src/key/table/ix.rs index def868fd..ae3de691 100644 --- a/core/src/key/table/ix.rs +++ b/core/src/key/table/ix.rs @@ -26,13 +26,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ix: &'a str) -> Ix<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'i', b'x', 0x00]); + k.extend_from_slice(b"!ix\x00"); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'!', b'i', b'x', 0xff]); + k.extend_from_slice(b"!ix\xff"); k } diff --git a/core/src/key/table/lq.rs b/core/src/key/table/lq.rs index 9d40103a..b3883e0d 100644 --- a/core/src/key/table/lq.rs +++ b/core/src/key/table/lq.rs @@ -32,13 +32,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, lq: Uuid) -> Lq<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(b"!lq\0"); + k.extend_from_slice(b"!lq\x00"); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(b"!lq\xff"); + k.extend_from_slice(b"!lq\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00"); k } @@ -93,6 +93,6 @@ mod tests { #[test] fn suffix() { let val = super::suffix("testns", "testdb", "testtb"); - assert_eq!(val, b"/*testns\x00*testdb\x00*testtb\x00!lq\xff") + assert_eq!(val, b"/*testns\x00*testdb\x00*testtb\x00!lq\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00") } } diff --git a/core/src/key/thing/mod.rs b/core/src/key/thing/mod.rs index 3559f23c..163e5ca7 100644 --- a/core/src/key/thing/mod.rs +++ b/core/src/key/thing/mod.rs @@ -25,13 +25,13 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, id: &Id) -> Thing<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = crate::key::table::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'*', 0x00]); + k.extend_from_slice(b"*\x00"); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = crate::key::table::all::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[b'*', 0xff]); + k.extend_from_slice(b"*\xff"); k }