forked from apache/calcite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)
- Loading branch information
1 parent
5bbc501
commit d59b639
Showing
525 changed files
with
7,983 additions
and
10,608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.