Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 committed Dec 13, 2024
1 parent f137c51 commit a11f2a2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions encodings/runend/src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ fn runend_encode_primitive<T: NativePType>(elements: &[T]) -> (Vec<u64>, Vec<T>)
}

// Run-end encode the values
let mut last = elements[0];
let mut prev = elements[0];
let mut end = 1;
for &e in elements.iter().skip(1) {
if e != last {
if e != prev {
ends.push(end);
values.push(last);
values.push(prev);
}
last = e;
prev = e;
end += 1;
}
ends.push(end);
values.push(last);
values.push(prev);

(ends, values)
}
Expand All @@ -91,40 +91,40 @@ fn runend_encode_nullable_primitive<T: NativePType>(
}

// Run-end encode the values
let mut last = element_validity.value(0).then(|| elements[0]);
let mut prev = element_validity.value(0).then(|| elements[0]);
let mut end = 1;
for e in elements
.iter()
.zip(element_validity.iter())
.map(|(&e, is_valid)| is_valid.then_some(e))
.skip(1)
{
if e != last {
if e != prev {
ends.push(end);
match last {
match prev {
None => {
validity.append(false);
values.push(T::default());
}
Some(l) => {
Some(p) => {
validity.append(true);
values.push(l);
values.push(p);
}
}
}
last = e;
prev = e;
end += 1;
}
ends.push(end);

match last {
match prev {
None => {
validity.append(false);
values.push(T::default());
}
Some(l) => {
Some(p) => {
validity.append(true);
values.push(l);
values.push(p);
}
}

Expand Down

0 comments on commit a11f2a2

Please sign in to comment.