github.com/solo-io/cue@v0.4.7/cue/testdata/benchmarks/mergeddisjunction.txtar (about) 1 // Here one comprehension creates a number of distinct values, each of which 2 // with a disjunction, then another comprehension maps them back to the 3 // same value, creating a large number of disjunctions. 4 // 5 // The disjunctions cannot be identified as equal in the general case. If no 6 // care is taken, disjunction elimination will be exponential, causing over 7 // a billion disjuncts to process in the below example. With the proper 8 // optimizations, there is a small, constant number of disjunction ops per 9 // disjunct. 10 // 11 // Issue #651 12 -- in.cue -- 13 list: [ 14 0, 1, 2, 3, 4, 5, 6, 7, 8, 15 9, 10, 11, 12, 13, 14, 15, 16, 16 17, 18, 19, 20, 21, 22, 23, 24, 17 25, 26, 27, 28, 29, 30, 18 ] 19 a: [X=string]: text: *"default" | string 20 21 a: { 22 for i in list { 23 "\(i)": text: string 24 } 25 } 26 27 b: { 28 for x in a { 29 "\(x.text)": { text: x.text } 30 } 31 } 32 -- out/eval -- 33 (struct){ 34 list: (#list){ 35 0: (int){ 0 } 36 1: (int){ 1 } 37 2: (int){ 2 } 38 3: (int){ 3 } 39 4: (int){ 4 } 40 5: (int){ 5 } 41 6: (int){ 6 } 42 7: (int){ 7 } 43 8: (int){ 8 } 44 9: (int){ 9 } 45 10: (int){ 10 } 46 11: (int){ 11 } 47 12: (int){ 12 } 48 13: (int){ 13 } 49 14: (int){ 14 } 50 15: (int){ 15 } 51 16: (int){ 16 } 52 17: (int){ 17 } 53 18: (int){ 18 } 54 19: (int){ 19 } 55 20: (int){ 20 } 56 21: (int){ 21 } 57 22: (int){ 22 } 58 23: (int){ 23 } 59 24: (int){ 24 } 60 25: (int){ 25 } 61 26: (int){ 26 } 62 27: (int){ 27 } 63 28: (int){ 28 } 64 29: (int){ 29 } 65 30: (int){ 30 } 66 } 67 a: (struct){ 68 "0": (struct){ 69 text: (string){ |(*(string){ "default" }, (string){ string }) } 70 } 71 "1": (struct){ 72 text: (string){ |(*(string){ "default" }, (string){ string }) } 73 } 74 "2": (struct){ 75 text: (string){ |(*(string){ "default" }, (string){ string }) } 76 } 77 "3": (struct){ 78 text: (string){ |(*(string){ "default" }, (string){ string }) } 79 } 80 "4": (struct){ 81 text: (string){ |(*(string){ "default" }, (string){ string }) } 82 } 83 "5": (struct){ 84 text: (string){ |(*(string){ "default" }, (string){ string }) } 85 } 86 "6": (struct){ 87 text: (string){ |(*(string){ "default" }, (string){ string }) } 88 } 89 "7": (struct){ 90 text: (string){ |(*(string){ "default" }, (string){ string }) } 91 } 92 "8": (struct){ 93 text: (string){ |(*(string){ "default" }, (string){ string }) } 94 } 95 "9": (struct){ 96 text: (string){ |(*(string){ "default" }, (string){ string }) } 97 } 98 "10": (struct){ 99 text: (string){ |(*(string){ "default" }, (string){ string }) } 100 } 101 "11": (struct){ 102 text: (string){ |(*(string){ "default" }, (string){ string }) } 103 } 104 "12": (struct){ 105 text: (string){ |(*(string){ "default" }, (string){ string }) } 106 } 107 "13": (struct){ 108 text: (string){ |(*(string){ "default" }, (string){ string }) } 109 } 110 "14": (struct){ 111 text: (string){ |(*(string){ "default" }, (string){ string }) } 112 } 113 "15": (struct){ 114 text: (string){ |(*(string){ "default" }, (string){ string }) } 115 } 116 "16": (struct){ 117 text: (string){ |(*(string){ "default" }, (string){ string }) } 118 } 119 "17": (struct){ 120 text: (string){ |(*(string){ "default" }, (string){ string }) } 121 } 122 "18": (struct){ 123 text: (string){ |(*(string){ "default" }, (string){ string }) } 124 } 125 "19": (struct){ 126 text: (string){ |(*(string){ "default" }, (string){ string }) } 127 } 128 "20": (struct){ 129 text: (string){ |(*(string){ "default" }, (string){ string }) } 130 } 131 "21": (struct){ 132 text: (string){ |(*(string){ "default" }, (string){ string }) } 133 } 134 "22": (struct){ 135 text: (string){ |(*(string){ "default" }, (string){ string }) } 136 } 137 "23": (struct){ 138 text: (string){ |(*(string){ "default" }, (string){ string }) } 139 } 140 "24": (struct){ 141 text: (string){ |(*(string){ "default" }, (string){ string }) } 142 } 143 "25": (struct){ 144 text: (string){ |(*(string){ "default" }, (string){ string }) } 145 } 146 "26": (struct){ 147 text: (string){ |(*(string){ "default" }, (string){ string }) } 148 } 149 "27": (struct){ 150 text: (string){ |(*(string){ "default" }, (string){ string }) } 151 } 152 "28": (struct){ 153 text: (string){ |(*(string){ "default" }, (string){ string }) } 154 } 155 "29": (struct){ 156 text: (string){ |(*(string){ "default" }, (string){ string }) } 157 } 158 "30": (struct){ 159 text: (string){ |(*(string){ "default" }, (string){ string }) } 160 } 161 } 162 b: (struct){ 163 default: (struct){ 164 text: (string){ |(*(string){ "default" }, (string){ string }) } 165 } 166 } 167 } 168 -- out/compile -- 169 --- in.cue 170 { 171 list: [ 172 0, 173 1, 174 2, 175 3, 176 4, 177 5, 178 6, 179 7, 180 8, 181 9, 182 10, 183 11, 184 12, 185 13, 186 14, 187 15, 188 16, 189 17, 190 18, 191 19, 192 20, 193 21, 194 22, 195 23, 196 24, 197 25, 198 26, 199 27, 200 28, 201 29, 202 30, 203 ] 204 a: { 205 [string]: { 206 text: (*"default"|string) 207 } 208 } 209 a: { 210 for _, i in 〈1;list〉 { 211 "\(〈1;i〉)": { 212 text: string 213 } 214 } 215 } 216 b: { 217 for _, x in 〈1;a〉 { 218 "\(〈1;x〉.text)": { 219 text: 〈2;x〉.text 220 } 221 } 222 } 223 }