From e01066772217145f889c620087346794772babd1 Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Tue, 12 Apr 2022 16:42:34 +0800 Subject: [PATCH] fixing bad comparator --- src/definition.rs | 2 +- src/storage.rs | 4 ++-- src/value.rs | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/definition.rs b/src/definition.rs index 37f254fe..6740daac 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -546,7 +546,7 @@ mod tests { let mut eval = Evaluator::new("_path_for_rocksdb_storagex".to_string()).unwrap(); eval.build_table(parsed).unwrap(); eval.restore_metadata().unwrap(); - eval.storage.delete().unwrap(); + // eval.storage.delete().unwrap(); println!("{:#?}", eval.s_envs.resolve("Person")); println!("{:#?}", eval.s_envs.resolve("Friend")); } diff --git a/src/storage.rs b/src/storage.rs index 17acb882..45a4c176 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -18,8 +18,8 @@ impl Storage { options.create_if_missing(true); options.set_comparator("cozo_comparator_v1", cozo_comparator_v1); - let temp_cf = ColumnFamilyDescriptor::new("temp", options.clone()); - let db = DB::open_cf_descriptors(&options, &path, vec![temp_cf])?; + // let temp_cf = ColumnFamilyDescriptor::new("temp", options.clone()); + let db = DB::open(&options, &path)?; Ok(Storage { db: Some(db), options, path }) } diff --git a/src/value.rs b/src/value.rs index aa6b14c8..4f281352 100644 --- a/src/value.rs +++ b/src/value.rs @@ -71,7 +71,7 @@ pub enum Value<'a> { Dict(Box, Value<'a>>>), } -impl <'a> Value<'a> { +impl<'a> Value<'a> { pub fn get_list(self) -> Option> { match self { Value::List(v) => Some(*v), @@ -250,7 +250,7 @@ impl<'a> ByteArrayParser<'a> { #[inline] pub fn compare_string(&mut self, other: &mut Self) -> Ordering { let len_a = self.parse_varint().expect("Failed to get String length when comparing"); - let len_b = self.parse_varint().expect("Failed to get String length when comparing"); + let len_b = other.parse_varint().expect("Failed to get String length when comparing"); for _ in 0..min(len_a, len_b) { let byte_a = self.advance(1).expect("Unexpected end of String when comparing")[0]; let byte_b = other.advance(1).expect("Unexpected end of String when comparing")[0]; @@ -471,7 +471,8 @@ impl ByteArrayBuilder { pub fn cozo_comparator_v1(a: &[u8], b: &[u8]) -> Ordering { cmp_data(&mut ByteArrayParser { bytes: a, current: 0 }, - &mut ByteArrayParser { bytes: b, current: 0 }) + &mut ByteArrayParser { bytes: b, current: 0 }) + } pub fn cmp_data<'a>(pa: &mut ByteArrayParser<'a>, pb: &mut ByteArrayParser<'a>) -> Ordering {