descendingArraysEqual compares two descending arrays, considering empty arrays and arrays of all false values as equivalent for constraint-based indexes.
(desc1, desc2 []bool)
| 837 | // descendingArraysEqual compares two descending arrays, considering empty arrays |
| 838 | // and arrays of all false values as equivalent for constraint-based indexes. |
| 839 | func descendingArraysEqual(desc1, desc2 []bool) bool { |
| 840 | // Helper function to check if an array is effectively "all false" |
| 841 | // (either empty or contains only false values) |
| 842 | isEffectivelyAllFalse := func(arr []bool) bool { |
| 843 | if len(arr) == 0 { |
| 844 | return true // Empty array means no descending columns |
| 845 | } |
| 846 | for _, val := range arr { |
| 847 | if val { |
| 848 | return false // Found a true value, so not all false |
| 849 | } |
| 850 | } |
| 851 | return true // All values are false |
| 852 | } |
| 853 | |
| 854 | // If both arrays are effectively "all false", they are equal |
| 855 | if isEffectivelyAllFalse(desc1) && isEffectivelyAllFalse(desc2) { |
| 856 | return true |
| 857 | } |
| 858 | |
| 859 | // If lengths don't match and neither is empty, do exact comparison |
| 860 | if len(desc1) != len(desc2) { |
| 861 | return false |
| 862 | } |
| 863 | |
| 864 | // Do element-by-element comparison |
| 865 | for i, val1 := range desc1 { |
| 866 | if i >= len(desc2) || val1 != desc2[i] { |
| 867 | return false |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | return true |
| 872 | } |
| 873 | |
| 874 | // spatialConfigsEqual checks if two spatial index configurations are equal. |
| 875 | func spatialConfigsEqual(cfg1, cfg2 *storepb.SpatialIndexConfig) bool { |