diff options
author | Volodymyr Vysotskyi <vvovyk@gmail.com> | 2018-04-23 11:38:39 +0300 |
---|---|---|
committer | Volodymyr Vysotskyi <vvovyk@gmail.com> | 2018-08-28 20:04:25 +0300 |
commit | 44e63bd0deda72af726f51e0ff78fc2b636c64eb (patch) | |
tree | 6729d28338ead5c071a1c23f2cbcabe1e340387f /common/src/main | |
parent | d8f9fb6a5cf22a01fa3f48bd40e7dbeb3cb6e4e4 (diff) |
DRILL-6422: Update guava to 23.0 and shade it
- Fix compilation errors for new version of Guava.
- Remove usage of deprecated API
- Shade guava and add dependencies to the shaded version
- Ban unshaded package
- Introduce drill-shaded module and move guava-shaded under it
- Add methods to convert shaded guava lists to the unshaded ones
- Add instruction for publishing artifacts to the Apache repository
Diffstat (limited to 'common/src/main')
-rw-r--r-- | common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java | 2 | ||||
-rw-r--r-- | common/src/main/java/org/apache/drill/common/util/GuavaUtils.java | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java b/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java index 343c9473b..4d6d09001 100644 --- a/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java +++ b/common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java @@ -41,6 +41,6 @@ public class DrillFileUtils { } public static String getResourceAsString(String fileName) throws IOException { - return Files.toString(getResourceAsFile(fileName), Charsets.UTF_8); + return Files.asCharSource(getResourceAsFile(fileName), Charsets.UTF_8).read(); } } diff --git a/common/src/main/java/org/apache/drill/common/util/GuavaUtils.java b/common/src/main/java/org/apache/drill/common/util/GuavaUtils.java new file mode 100644 index 000000000..5bfbed866 --- /dev/null +++ b/common/src/main/java/org/apache/drill/common/util/GuavaUtils.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.common.util; + +import java.util.List; + +/** + * Utility class which contain methods for conversion guava and shaded guava classes. + * Once outer libraries API remove usage of these classes, these methods should be removed. + */ +public class GuavaUtils { + + /** + * Transforms specified list of lists into {@link com.google.common.collect.ImmutableList} of + * {@link com.google.common.collect.ImmutableList} lists to pass it into the methods from other libraries. + * @param tuples list to be transformed + * @return transformed list + */ + public static <T> com.google.common.collect.ImmutableList + <com.google.common.collect.ImmutableList<T>> convertToNestedUnshadedImmutableList(List<? extends List<T>> tuples) { + com.google.common.collect.ImmutableList.Builder<com.google.common.collect.ImmutableList<T>> immutableListBuilder = + com.google.common.collect.ImmutableList.builder(); + for (List<T> tuple : tuples) { + immutableListBuilder.add(convertToUnshadedImmutableList(tuple)); + } + return immutableListBuilder.build(); + } + + public static <T> com.google.common.collect.ImmutableList<T> convertToUnshadedImmutableList(List<? extends T> source) { + return com.google.common.collect.ImmutableList.copyOf(source); + } +} |