Commit 999ec13
[SPARK-22570][SQL] Avoid to create a lot of global variables by using a local variable with allocation of an object in generated code
## What changes were proposed in this pull request?
This PR reduces # of global variables in generated code by replacing a global variable with a local variable with an allocation of an object every time. When a lot of global variables were generated, the generated code may meet 64K constant pool limit.
This PR reduces # of generated global variables in the following three operations:
* `Cast` with String to primitive byte/short/int/long
* `RegExpReplace`
* `CreateArray`
I intentionally leave [this part](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala#L595-L603). This is because this variable keeps a class that is dynamically generated. In other word, it is not possible to reuse one class.
## How was this patch tested?
Added test cases
Author: Kazuaki Ishizaki <ishizaki@jp.ibm.com>
Closes #19797 from kiszk/SPARK-22570.1 parent 932bd09 commit 999ec13
File tree
6 files changed
+61
-33
lines changed- sql/catalyst/src
- main/scala/org/apache/spark/sql/catalyst/expressions
- test/scala/org/apache/spark/sql/catalyst
- expressions
- optimizer
6 files changed
+61
-33
lines changedLines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
799 | 799 | | |
800 | 800 | | |
801 | 801 | | |
802 | | - | |
803 | | - | |
804 | | - | |
| 802 | + | |
805 | 803 | | |
806 | 804 | | |
| 805 | + | |
807 | 806 | | |
808 | 807 | | |
809 | 808 | | |
810 | 809 | | |
811 | 810 | | |
| 811 | + | |
812 | 812 | | |
813 | 813 | | |
814 | 814 | | |
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
830 | | - | |
831 | | - | |
| 829 | + | |
832 | 830 | | |
833 | 831 | | |
| 832 | + | |
834 | 833 | | |
835 | 834 | | |
836 | 835 | | |
837 | 836 | | |
838 | 837 | | |
| 838 | + | |
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
| |||
851 | 851 | | |
852 | 852 | | |
853 | 853 | | |
854 | | - | |
855 | | - | |
856 | | - | |
| 854 | + | |
857 | 855 | | |
858 | 856 | | |
| 857 | + | |
859 | 858 | | |
860 | 859 | | |
861 | 860 | | |
862 | 861 | | |
863 | 862 | | |
| 863 | + | |
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
| |||
876 | 876 | | |
877 | 877 | | |
878 | 878 | | |
879 | | - | |
880 | | - | |
881 | | - | |
| 879 | + | |
882 | 880 | | |
883 | 881 | | |
884 | 882 | | |
| 883 | + | |
885 | 884 | | |
886 | 885 | | |
887 | 886 | | |
888 | 887 | | |
889 | 888 | | |
| 889 | + | |
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
| |||
Lines changed: 21 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
94 | 93 | | |
| 94 | + | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | 96 | | |
99 | 97 | | |
100 | 98 | | |
| |||
110 | 108 | | |
111 | 109 | | |
112 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | | - | |
115 | | - | |
| 116 | + | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| 121 | + | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | | - | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
143 | | - | |
| 149 | + | |
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
147 | | - | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
216 | 222 | | |
217 | 223 | | |
218 | 224 | | |
219 | | - | |
| 225 | + | |
220 | 226 | | |
221 | 227 | | |
222 | | - | |
| 228 | + | |
223 | 229 | | |
224 | 230 | | |
225 | 231 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
325 | | - | |
| 324 | + | |
326 | 325 | | |
327 | 326 | | |
328 | 327 | | |
| |||
334 | 333 | | |
335 | 334 | | |
336 | 335 | | |
337 | | - | |
338 | | - | |
339 | 336 | | |
340 | 337 | | |
341 | 338 | | |
| |||
355 | 352 | | |
356 | 353 | | |
357 | 354 | | |
358 | | - | |
| 355 | + | |
359 | 356 | | |
360 | 357 | | |
361 | 358 | | |
362 | 359 | | |
363 | 360 | | |
364 | 361 | | |
365 | 362 | | |
| 363 | + | |
366 | 364 | | |
367 | 365 | | |
368 | 366 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
845 | 846 | | |
846 | 847 | | |
847 | 848 | | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
848 | 856 | | |
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
181 | 190 | | |
182 | 191 | | |
183 | 192 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| |||
0 commit comments