Skip to main content

compute_common

Function compute_common 

Source
pub fn compute_common(
    base: &[BTreeMap<String, Value>],
) -> (BTreeMap<String, Value>, Vec<BTreeMap<String, Value>>)
Expand description

Extract keys common to ALL base entries.

Returns (common_keys, remaining_per_object_entries) where:

  • common_keys: keys present in ALL entries with identical CBOR values
  • remaining: per-object entries with only the varying keys

The _reserved_ key is excluded from common computation (it’s library-managed and varies per object due to ndim/shape/strides/dtype).

Edge cases:

  • 0 entries: returns (empty, empty vec)
  • 1 entry: all keys (except _reserved_) are common, remaining is empty

NaN handling: CBOR Float(NaN) values use IEEE 754 equality (NaN != NaN), so a key whose value is NaN in all entries will NOT be classified as common. This is conservative — no data is lost, the key simply appears per-object rather than in the common set.