Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Oct 17, 2024
1 parent 0718692 commit 6a389da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
11 changes: 2 additions & 9 deletions crates/polars-row/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,20 +371,13 @@ fn allocate_rows_buf(
for opt_val in iter {
unsafe {
lengths.push_unchecked(
row_size_fixed
+ crate::variable::encoded_len(
opt_val,
&field,
),
row_size_fixed + crate::variable::encoded_len(opt_val, &field),
);
}
}
} else {
for (opt_val, row_length) in iter.zip(lengths.iter_mut()) {
*row_length += crate::variable::encoded_len(
opt_val,
&field,
)
*row_length += crate::variable::encoded_len(opt_val, &field)
}
}
processed_count += 1;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-row/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
//!
//! This approach is loosely inspired by [COBS] encoding, and chosen over more traditional
//! [byte stuffing] as it is more amenable to vectorisation, in particular AVX-256.
//!
//!
//! For the unordered row encoding we use a simpler scheme, we prepend the length
//! encoded as 4 bytes followed by the raw data, with nulls being marked with a
//! length of u32::MAX.
Expand Down
11 changes: 5 additions & 6 deletions crates/polars-row/src/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,12 @@ unsafe fn decode_binary_unordered(rows: &mut [&[u8]]) -> BinaryArray<i64> {
}
}

let validity = has_nulls.then(||
let validity = has_nulls.then(|| {
Bitmap::from_trusted_len_iter_unchecked(
rows.iter()
.map(|row| decoded_len_unordered(row).is_none())
rows.iter().map(|row| decoded_len_unordered(row).is_none()),
)
);
});

let mut values = Vec::with_capacity(total_len);
let mut offsets = Vec::with_capacity(rows.len() + 1);
offsets.push(0);
Expand All @@ -274,7 +273,7 @@ unsafe fn decode_binview_unordered(rows: &mut [&[u8]]) -> BinaryViewArray {
let mut mutable = MutableBinaryViewArray::with_capacity(rows.len());
for row in rows.iter_mut() {
if let Some(len) = decoded_len_unordered(row) {
mutable.push_value(row.get_unchecked(4.. 4 + len as usize));
mutable.push_value(row.get_unchecked(4..4 + len as usize));
*row = row.get_unchecked(4 + len as usize..);
} else {
mutable.push_null();
Expand Down

0 comments on commit 6a389da

Please sign in to comment.