Commit d59b639
committed
[CALCITE-2259] Allow Java 8 syntax
In summary: use lambdas where possible, switch from Guava function
types to Java function types or lambdas, but continue to use Guava
components (such as immutable collections and cache) that have no
equivalent in the Java runtime.
1. Change single-abstract-method (SAM) classes to lambdas. Preserve
formatting wherever possible.
2. Change AssertQuery.returns argument type from Guava Function to Java
Consumer. If you are using a lambda and see 'returns is deprecated',
remove the 'return null;' line, and the lambda will become a Consumer
(whose return is void).
3. Change RelOptRuleOperand and RelOptRule.operand methods to take Java
Predicate rather than Guava Predicate.
4. Change the argument of Hook.add and .addThread from Guava Function to
Java Consumer.
5. Change 'list.toArray(new T[list.size()])' to 'list.toArray(new T[0])'
because the latter is simpler, and just as efficient on recent Java
versions.
6. Resource references; change "try (Closeable ignore = foo())" to "try
(foo())", especially uses of TryThreadLocal and Hook.Closeable.
7. Convert linq4j Function1 to java Function, Function2 to java BiFunction
8. Fix occurrences of Intellij's "Explicit type can be replaced with
<>" inspection. (Occurs for "List<String> list = new
ArrayList<String>();".)
9. Change Guava Preconditions.checkNotNull to Java
Objects.requireNonNull. (Kevin Risden)
10. Break out anonymous classes and fix dependency problems.
11. Use CacheLoader.of(Function) where possible.
12. Replace sub-classes of ThreadLocal with ThreadLocal.withInitial().
13. Replace Guava collection methods with calls to Java collection types,
for example replace Lists.newArrayList() with new ArrayList<>(),
Maps.newHashSet() with new HashSet<>(), similarly Sets.
14. Replace Guava Joiner with String.join.
15. Replace Collections.emptyList() with ImmutableList.of() in a few
places.
For backwards compatibility, we preserved (and deprecated) the old
methods that used Guava types. In a few cases where new and old have
the same signature (after erasure), we could not add a method with the
same name, so we gave the new method a "J" suffix. Examples include
Hook.property and .propertyJ, RelOptRule.operand and .operandJ.
In test code, we have not slavishly ensured backwards compatibility.
We do not intend to remove uses of Guava's immutable collections.
We have ignored Intellij's "Pseudo functional style code" inspection
most of the time, but in a few cases have converted Lists.transform(),
Iterables.transform(), and Iterables.filter() into Java streams. Use
the Util.toImmutableList() collector if the result is to be an
immutable list. Use Util.transform() rather than Lists.transform()
if you have a Java function rather than a Guava function or lambda.
Not covered in this change (might be done in future):
* Convert Collections.sort(list) to list.sort.
* Review uses of 'for (Map.Entry<K, V> e : map.entrySet())' and see
whether it makes sense to convert to 'map.forEach((k, v) ->
...)'. Intellij inspection is called 'Replace with Map.forEach'.
Breaking changes:
* LatticeStatisticProvider.Factory, result of RexUtil.notFun(), and
arguments to Mappings.target() are Function (was Guava, now Java)
* Argument to SqlSpecialOperator.TokenSequence.parser() is Predicate
(was Guava, now Java)
* AggregateNode.AccumulatorFactory extends Supplier (was Guava, now Java)1 parent 5bbc501 commit d59b639
File tree
525 files changed
+7983
-10608
lines changed- cassandra/src/main/java/org/apache/calcite/adapter/cassandra
- core/src
- main
- codegen/templates
- java/org/apache/calcite
- adapter
- clone
- elasticsearch
- enumerable
- impl
- jdbc
- config
- interpreter
- jdbc
- materialize
- plan
- hep
- volcano
- prepare
- profile
- rel
- convert
- core
- logical
- metadata
- mutable
- rel2sql
- rules
- stream
- type
- rex
- runtime
- schema
- impl
- sql2rel
- sql
- advise
- dialect
- fun
- parser
- pretty
- type
- util
- validate
- tools
- util
- graph
- javac
- mapping
- trace
- test/java/org/apache/calcite
- jdbc
- plan
- volcano
- prepare
- profile
- rel
- rel2sql
- rules
- rex
- runtime
- sql
- parser
- test
- type
- test
- concurrent
- tools
- util
- graph
- mapping
- druid/src
- main/java/org/apache/calcite/adapter/druid
- test/java/org/apache/calcite
- adapter/druid
- test
- elasticsearch2
- src
- main/java/org/apache/calcite/adapter/elasticsearch2
- test/java/org/apache/calcite
- adapter/elasticsearch2
- test
- elasticsearch5
- src
- main/java/org/apache/calcite/adapter/elasticsearch5
- test/java/org/apache/calcite
- adapter/elasticsearch5
- test
- example
- csv/src
- main/java/org/apache/calcite/adapter/csv
- test/java/org/apache/calcite/test
- function/src/main/java/org/apache/calcite/example/maze
- file/src
- main/java/org/apache/calcite/adapter/file
- test/java/org/apache/calcite/adapter/file
- geode/src
- main/java/org/apache/calcite/adapter/geode
- rel
- util
- test/java/org/apache/calcite/adapter/geode/rel
- linq4j/src
- main/java/org/apache/calcite/linq4j
- function
- tree
- test/java
- com/example
- org/apache/calcite/linq4j
- function
- test
- mongodb/src
- main/java/org/apache/calcite/adapter/mongodb
- test/java/org/apache/calcite
- adapter/mongodb
- test
- piglet/src
- main
- javacc
- java/org/apache/calcite/piglet
- test/java/org/apache/calcite/test
- pig/src
- main/java/org/apache/calcite/adapter/pig
- test/java/org/apache/calcite/test
- plus/src
- main/java/org/apache/calcite
- adapter
- os
- tpcds
- chinook
- test/java/org/apache/calcite/adapter
- os
- tpcds
- tpch
- server/src/main
- codegen/includes
- java/org/apache/calcite/sql/ddl
- site
- spark/src/main/java/org/apache/calcite/adapter/spark
- splunk/src/test/java/org/apache/calcite/test
- src/main/config/forbidden-apis
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
525 files changed
+7983
-10608
lines changedLines changed: 14 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 45 | | |
50 | 46 | | |
51 | 47 | | |
| 48 | + | |
52 | 49 | | |
53 | 50 | | |
54 | 51 | | |
| |||
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
98 | | - | |
| 95 | + | |
99 | 96 | | |
100 | 97 | | |
101 | 98 | | |
| |||
113 | 110 | | |
114 | 111 | | |
115 | 112 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
123 | 116 | | |
124 | 117 | | |
125 | 118 | | |
| |||
268 | 261 | | |
269 | 262 | | |
270 | 263 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 264 | + | |
285 | 265 | | |
286 | 266 | | |
287 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
288 | 270 | | |
289 | 271 | | |
290 | 272 | | |
291 | 273 | | |
292 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
293 | 279 | | |
294 | 280 | | |
295 | 281 | | |
| |||
Lines changed: 8 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | | - | |
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
| |||
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 114 | + | |
| 115 | + | |
121 | 116 | | |
122 | 117 | | |
123 | 118 | | |
| |||
177 | 172 | | |
178 | 173 | | |
179 | 174 | | |
180 | | - | |
| 175 | + | |
181 | 176 | | |
182 | 177 | | |
183 | 178 | | |
184 | 179 | | |
185 | 180 | | |
186 | | - | |
| 181 | + | |
187 | 182 | | |
188 | 183 | | |
189 | 184 | | |
190 | 185 | | |
191 | | - | |
192 | | - | |
| 186 | + | |
| 187 | + | |
193 | 188 | | |
194 | 189 | | |
195 | 190 | | |
| |||
205 | 200 | | |
206 | 201 | | |
207 | 202 | | |
208 | | - | |
| 203 | + | |
209 | 204 | | |
210 | 205 | | |
211 | 206 | | |
| |||
237 | 232 | | |
238 | 233 | | |
239 | 234 | | |
240 | | - | |
| 235 | + | |
241 | 236 | | |
242 | 237 | | |
243 | 238 | | |
| |||
Lines changed: 24 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | | - | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 100 | + | |
| 101 | + | |
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
| |||
118 | 117 | | |
119 | 118 | | |
120 | 119 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
127 | 126 | | |
128 | 127 | | |
129 | 128 | | |
| |||
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
150 | 148 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
155 | 153 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
160 | 158 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
166 | 163 | | |
167 | 164 | | |
168 | 165 | | |
| |||
Lines changed: 1 addition & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
| |||
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 146 | + | |
153 | 147 | | |
154 | 148 | | |
155 | 149 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
| |||
1010 | 1008 | | |
1011 | 1009 | | |
1012 | 1010 | | |
1013 | | - | |
| 1011 | + | |
1014 | 1012 | | |
1015 | 1013 | | |
1016 | 1014 | | |
| |||
1261 | 1259 | | |
1262 | 1260 | | |
1263 | 1261 | | |
1264 | | - | |
| 1262 | + | |
1265 | 1263 | | |
1266 | 1264 | | |
1267 | 1265 | | |
| |||
1290 | 1288 | | |
1291 | 1289 | | |
1292 | 1290 | | |
1293 | | - | |
| 1291 | + | |
1294 | 1292 | | |
1295 | 1293 | | |
1296 | 1294 | | |
| |||
1498 | 1496 | | |
1499 | 1497 | | |
1500 | 1498 | | |
1501 | | - | |
| 1499 | + | |
1502 | 1500 | | |
1503 | 1501 | | |
1504 | 1502 | | |
| |||
1981 | 1979 | | |
1982 | 1980 | | |
1983 | 1981 | | |
1984 | | - | |
| 1982 | + | |
1985 | 1983 | | |
1986 | 1984 | | |
1987 | 1985 | | |
| |||
2205 | 2203 | | |
2206 | 2204 | | |
2207 | 2205 | | |
2208 | | - | |
| 2206 | + | |
2209 | 2207 | | |
2210 | 2208 | | |
2211 | 2209 | | |
| |||
2221 | 2219 | | |
2222 | 2220 | | |
2223 | 2221 | | |
2224 | | - | |
| 2222 | + | |
2225 | 2223 | | |
2226 | 2224 | | |
2227 | 2225 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
816 | 816 | | |
817 | 817 | | |
818 | 818 | | |
819 | | - | |
| 819 | + | |
820 | 820 | | |
821 | 821 | | |
822 | 822 | | |
| |||
0 commit comments