Skip to content
This repository was archived by the owner on Jul 3, 2023. It is now read-only.

Commit 8b925a0

Browse files
committed
Commit WIP.
1 parent 900f868 commit 8b925a0

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

src/trace/persistent/cursor.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ where
8686
B::Val: Ord + Encode + Decode,
8787
B::R: Encode + Decode,
8888
{
89-
type Storage = PersistentTrace<B>;
90-
9189
#[inline]
9290
fn key_valid(&self) -> bool {
9391
self.cur_key_weight.is_some()
@@ -116,6 +114,10 @@ where
116114
unimplemented!()
117115
}
118116

117+
fn map_times_through<L: FnMut(&B::Time, &B::R)>(&mut self, logic: L, upper: &B::Time) {
118+
unimplemented!()
119+
}
120+
119121
#[inline]
120122
fn weight(&mut self) -> B::R
121123
where
@@ -145,6 +147,11 @@ where
145147
}
146148
}
147149

150+
/// Returns the last key in the cursor or `None` if the cursor is empty.
151+
fn last_key(&mut self) -> Option<&B::Key> {
152+
None
153+
}
154+
148155
#[inline]
149156
fn seek_key(&mut self, key: &B::Key) {
150157
self.valid = true;
@@ -187,16 +194,6 @@ where
187194
#[inline]
188195
fn seek_val(&mut self, val: &B::Val) {}
189196

190-
#[inline]
191-
fn values<'a>(&mut self, vals: &mut Vec<(&'a B::Val, B::R)>)
192-
where
193-
's: 'a,
194-
{
195-
// It's technically ok to call this on a batch with value type `()`, but
196-
// shouldn't happen in practice.
197-
unimplemented!();
198-
}
199-
200197
#[inline]
201198
fn rewind_keys(&mut self) {
202199
self.cursor_upper_bound = None;

src/trace/persistent/tests.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,13 @@ fn keys<K: Arbitrary + Clone>(range: Range<usize>) -> impl Strategy<Value = Vec<
181181
prop::collection::vec(any::<K>(), range)
182182
}
183183

184-
/* Does a random cursor walk test for a generic Batch `B`.
184+
// Does a random cursor walk test for a generic Batch `B`.
185+
/*
185186
fn random_cursor_walk<B>(
186187
mut ks: Vec<(B::Key, B::Val, B::R)>,
187188
ops: Vec<CursorAction<B::Key, B::Val>>,
188189
) where
189-
B: Batch + 'static,
190+
B: Batch<Item = (<B as BatchReader>::Key, <B as BatchReader>::Val)> + 'static,
190191
B::Key: Arbitrary + Ord + Clone + Encode + Decode,
191192
B::Val: Arbitrary + Ord + Clone + Encode + Decode,
192193
B::R: Arbitrary + Ord + Clone + MonoidValue + Encode + Decode,
@@ -199,7 +200,7 @@ fn random_cursor_walk<B>(
199200
// Instantiate a regular OrdZSet
200201
let mut batch_builder = B::Builder::new(B::Time::default());
201202
for (key, val, r) in ks.iter() {
202-
batch_builder.push((key.clone(), val.clone(), r.clone()));
203+
batch_builder.push(((key.clone(), val.clone()), r.clone()));
203204
}
204205
let batch = batch_builder.done();
205206
@@ -300,7 +301,7 @@ fn random_cursor_walk<B>(
300301
}
301302
}
302303
}
303-
}*/
304+
} */
304305

305306
proptest! {
306307
// Verify that our [`Cursor`] implementation for the persistent [`OrdZSet`]
@@ -313,7 +314,7 @@ proptest! {
313314
// Instantiate a regular OrdZSet
314315
let mut zset_builder = OrdZSetBuilder::new(());
315316
for key in ks.iter() {
316-
zset_builder.push((key.clone(), (), 0));
317+
zset_builder.push((key.clone(), 0));
317318
}
318319
let zset = zset_builder.done();
319320

@@ -407,10 +408,10 @@ proptest! {
407408
#[test]
408409
fn ordzset_insert_simple() {
409410
let mut zset_builder = ord::zset_batch::OrdZSetBuilder::new(());
410-
zset_builder.push((1, (), 9));
411-
zset_builder.push((2, (), 4));
412-
zset_builder.push((3, (), 8));
413-
zset_builder.push((4, (), 4));
411+
zset_builder.push((1, 9));
412+
zset_builder.push((2, 4));
413+
zset_builder.push((3, 8));
414+
zset_builder.push((4, 4));
414415
let zset = zset_builder.done();
415416
println!("ZSET: {}", zset);
416417

@@ -428,11 +429,11 @@ fn ordzset_insert_simple() {
428429
#[test]
429430
fn val_insert_simple() {
430431
let mut val_builder = ord::val_batch::OrdValBuilder::new(4);
431-
val_builder.push((1, 10, 9));
432-
val_builder.push((1, 12, 12));
433-
val_builder.push((2, 11, 7));
434-
val_builder.push((3, 12, 8));
435-
val_builder.push((4, 13, 9));
432+
val_builder.push(((1, 10), 9));
433+
val_builder.push(((1, 12), 12));
434+
val_builder.push(((2, 11), 7));
435+
val_builder.push(((3, 12), 8));
436+
val_builder.push(((4, 13), 9));
436437
let vset = val_builder.done();
437438
//println!("vset: {:?}", vset);
438439

@@ -442,11 +443,11 @@ fn val_insert_simple() {
442443
println!("SPINE: {}", spine);
443444

444445
let mut val_builder = ord::val_batch::OrdValBuilder::new(99);
445-
val_builder.push((1, 10, 108));
446-
val_builder.push((1, 12, 12));
447-
val_builder.push((2, 11, 7));
448-
val_builder.push((3, 12, 8));
449-
val_builder.push((4, 13, 9));
446+
val_builder.push(((1, 10), 108));
447+
val_builder.push(((1, 12), 12));
448+
val_builder.push(((2, 11), 7));
449+
val_builder.push(((3, 12), 8));
450+
val_builder.push(((4, 13), 9));
450451
let vset = val_builder.done();
451452
println!("vset: {:?}", vset);
452453

src/trace/persistent/trace.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ where
144144

145145
type Cursor<'s> = PersistentTraceCursor<'s, B>;
146146

147+
/// The number of keys in the batch.
148+
fn key_count(&self) -> usize {
149+
self.keys
150+
}
151+
152+
/// The number of updates in the batch.
147153
fn len(&self) -> usize {
148154
self.keys
149155
}

0 commit comments

Comments
 (0)