Skip to content

Commit

Permalink
Merge branch 'main' into emilk/improve-video-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Oct 11, 2024
2 parents 3de34d7 + b69be17 commit 9c2434d
Show file tree
Hide file tree
Showing 14 changed files with 465 additions and 354 deletions.
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5134,7 +5134,6 @@ dependencies = [
"anyhow",
"itertools 0.13.0",
"nohash-hasher",
"parking_lot",
"re_arrow2",
"re_chunk",
"re_chunk_store",
Expand Down
22 changes: 22 additions & 0 deletions crates/store/re_chunk/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ use itertools::Itertools;

// ---

/// Returns true if the given `list_array` is semantically empty.
///
/// Semantic emptiness is defined as either one of these:
/// * The list is physically empty (literally no data).
/// * The list only contains null entries, or empty arrays, or a mix of both.
pub fn is_list_array_semantically_empty(list_array: &ArrowListArray<i32>) -> bool {
let is_physically_empty = || list_array.is_empty();

let is_all_nulls = || {
list_array
.validity()
.map_or(false, |bitmap| bitmap.unset_bits() == list_array.len())
};

let is_all_empties = || list_array.offsets().lengths().all(|len| len == 0);

let is_a_mix_of_nulls_and_empties =
|| list_array.iter().flatten().all(|array| array.is_empty());

is_physically_empty() || is_all_nulls() || is_all_empties() || is_a_mix_of_nulls_and_empties()
}

/// Create a sparse list-array out of an array of arrays.
///
/// All arrays must have the same datatype.
Expand Down
Loading

0 comments on commit 9c2434d

Please sign in to comment.