MCPcopy Create free account
hub / github.com/erans/pgsqlite / count_dimensions

Function count_dimensions

src/functions/array_functions.rs:778–805  ·  view source on GitHub ↗

Helper function to count array dimensions

(value: &JsonValue)

Source from the content-addressed store, hash-verified

776
777/// Helper function to count array dimensions
778fn count_dimensions(value: &JsonValue) -> i32 {
779 match value {
780 JsonValue::Array(arr) => {
781 if arr.is_empty() {
782 1
783 } else {
784 // Check if any element is an array
785 let max_sub_dimensions = arr.iter()
786 .filter_map(|v| {
787 if matches!(v, JsonValue::Array(_)) {
788 Some(count_dimensions(v))
789 } else {
790 None
791 }
792 })
793 .max()
794 .unwrap_or(0);
795
796 if max_sub_dimensions > 0 {
797 1 + max_sub_dimensions
798 } else {
799 1
800 }
801 }
802 }
803 _ => 0,
804 }
805}
806
807
808

Callers 1

register_array_ndimsFunction · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected