Skip to content

Commit

Permalink
Generalize ReadItem type
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmcsherry committed Dec 23, 2023
1 parent dc2003b commit 73a2a83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/trace/implementations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub trait Layout {
type UpdContainer:
for<'a> BatchContainer<PushItem=(<Self::Target as Update>::Time, <Self::Target as Update>::Diff), ReadItem<'a> = &'a (<Self::Target as Update>::Time, <Self::Target as Update>::Diff)>;
/// Container for offsets.
type OffsetContainer: for<'a> BatchContainer<PushItem=usize, ReadItem<'a>=Wrapper<usize>>;
type OffsetContainer: BatchContainer<PushItem=usize>;
}

/// A layout that uses vectors
Expand Down
10 changes: 5 additions & 5 deletions src/trace/implementations/ord_neu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ mod val_batch {
impl<L: Layout> OrdValStorage<L> {
/// Lower and upper bounds in `self.vals` corresponding to the key at `index`.
fn values_for_key(&self, index: usize) -> (usize, usize) {
(*self.keys_offs.index(index), *self.keys_offs.index(index+1))
(self.keys_offs.index(index).into_owned(), self.keys_offs.index(index+1).into_owned())
}
/// Lower and upper bounds in `self.updates` corresponding to the value at `index`.
fn updates_for_value(&self, index: usize) -> (usize, usize) {
let mut lower = *self.vals_offs.index(index);
let upper = *self.vals_offs.index(index+1);
let mut lower = self.vals_offs.index(index).into_owned();
let upper = self.vals_offs.index(index+1).into_owned();
// We use equal lower and upper to encode "singleton update; just before here".
// It should only apply when there is a prior element, so `lower` should be greater than zero.
if lower == upper {
Expand Down Expand Up @@ -665,8 +665,8 @@ mod key_batch {
impl<L: Layout> OrdKeyStorage<L> {
/// Lower and upper bounds in `self.vals` corresponding to the key at `index`.
fn updates_for_key(&self, index: usize) -> (usize, usize) {
let mut lower = *self.keys_offs.index(index);
let upper = *self.keys_offs.index(index+1);
let mut lower = self.keys_offs.index(index).into_owned();
let upper = self.keys_offs.index(index+1).into_owned();
// We use equal lower and upper to encode "singleton update; just before here".
// It should only apply when there is a prior element, so `lower` should be greater than zero.
if lower == upper {
Expand Down
10 changes: 5 additions & 5 deletions src/trace/implementations/rhh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ mod val_batch {
{
/// Lower and upper bounds in `self.vals` corresponding to the key at `index`.
fn values_for_key(&self, index: usize) -> (usize, usize) {
let lower = *self.keys_offs.index(index);
let upper = *self.keys_offs.index(index+1);
let lower = self.keys_offs.index(index).into_owned();
let upper = self.keys_offs.index(index+1).into_owned();
// Looking up values for an invalid key indicates something is wrong.
assert!(lower < upper, "{:?} v {:?} at {:?}", lower, upper, index);
(lower, upper)
}
/// Lower and upper bounds in `self.updates` corresponding to the value at `index`.
fn updates_for_value(&self, index: usize) -> (usize, usize) {
let mut lower = *self.vals_offs.index(index);
let upper = *self.vals_offs.index(index+1);
let mut lower = self.vals_offs.index(index).into_owned();
let upper = self.vals_offs.index(index+1).into_owned();
// We use equal lower and upper to encode "singleton update; just before here".
// It should only apply when there is a prior element, so `lower` should be greater than zero.
if lower == upper {
Expand All @@ -178,7 +178,7 @@ mod val_batch {
// push additional blank entries in.
while self.keys.len() < desired {
// We insert a default (dummy) key and repeat the offset to indicate this.
let current_offset = *self.keys_offs.index(self.keys.len());
let current_offset = self.keys_offs.index(self.keys.len()).into_owned();
self.keys.push(Default::default());
self.keys_offs.push(current_offset);
}
Expand Down

0 comments on commit 73a2a83

Please sign in to comment.