SOLR-14676: Update commons-collections to 4.4 and use it in Solr

This commit is contained in:
Erick Erickson 2020-07-23 17:09:15 -04:00
parent 03a03b34a4
commit 67da34ac3b
20 changed files with 37 additions and 40 deletions

View File

@ -126,7 +126,8 @@ org.apache.calcite.version = 1.18.0
/org.apache.calcite/calcite-core = ${org.apache.calcite.version}
/org.apache.calcite/calcite-linq4j = ${org.apache.calcite.version}
/org.apache.commons/commons-collections4 = 4.2
org.apache.commons.commons-collections4-rev = 4.4
/org.apache.commons/commons-collections4 = ${org.apache.commons.commons-collections4-rev}
/org.apache.commons/commons-compress = 1.19
/org.apache.commons/commons-configuration2 = 2.1.1
/org.apache.commons/commons-csv = 1.7

View File

@ -158,6 +158,8 @@ Other Changes
* SOLR-14637: Update CloudSolrClient examples to remove deprecated method. (Andras Salamon via Eric Pugh)
* SOLR-14676: Update commons-collections to 4.4 and use it in Solr (Erick Erickson)
================== 8.6.0 ==================
Consult the lucene/CHANGES.txt file for additional, low level, changes in this release.

View File

@ -59,6 +59,7 @@ dependencies {
api 'commons-cli:commons-cli'
api 'commons-codec:commons-codec'
api 'commons-collections:commons-collections'
api 'org.apache.commons:commons-collections4'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile'

View File

@ -39,6 +39,7 @@
<dependency org="commons-io" name="commons-io" rev="${/commons-io/commons-io}" conf="compile"/>
<dependency org="org.apache.commons" name="commons-exec" rev="${/org.apache.commons/commons-exec}" conf="compile"/>
<dependency org="commons-cli" name="commons-cli" rev="${/commons-cli/commons-cli}" conf="compile"/>
<dependency org="org.apache.commons" name="commons-collections4" rev="${org.apache.commons.commons-collections4-rev}" conf="compile"/>
<dependency org="org.apache.commons" name="commons-text" rev="${/org.apache.commons/commons-text}" conf="compile"/>
<dependency org="com.google.guava" name="guava" rev="${/com.google.guava/guava}" conf="compile"/>
<dependency org="org.locationtech.spatial4j" name="spatial4j" rev="${/org.locationtech.spatial4j/spatial4j}" conf="compile"/>

View File

@ -33,7 +33,8 @@ import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections.map.MultiValueMap;
import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.beans.PluginMeta;
import org.apache.solr.common.NavigableObject;
@ -141,12 +142,13 @@ public class PackageManager implements Closeable {
* Get a list of packages that have their plugins deployed as cluster level plugins.
* The returned packages also contain the "pluginMeta" from "clusterprops.json" as custom data.
*/
@SuppressWarnings("unchecked")
public Map<String, SolrPackageInstance> getPackagesDeployedAsClusterLevelPlugins() {
Map<String, String> packageVersions = new HashMap<String, String>();
MultiValueMap packagePlugins = new MultiValueMap(); // map of package name to multiple values of pluginMeta (Map<String, String>)
Map<String, Object> result = (Map<String, Object>) Utils.executeGET(solrClient.getHttpClient(),
Map<String, String> packageVersions = new HashMap<>();
MultiValuedMap<String, PluginMeta> packagePlugins = new HashSetValuedHashMap<>(); // map of package name to multiple values of pluginMeta (Map<String, String>)
@SuppressWarnings({"unchecked"})
Map<String, Object> result = (Map<String, Object>)Utils.executeGET(solrClient.getHttpClient(),
solrBaseUrl + PackageUtils.CLUSTERPROPS_PATH, Utils.JSONCONSUMER);
@SuppressWarnings({"unchecked"})
Map<String, Object> clusterPlugins = (Map<String, Object>) result.getOrDefault("plugin", Collections.emptyMap());
for (String key: clusterPlugins.keySet()) {
// Map<String, String> pluginMeta = (Map<String, String>) clusterPlugins.get(key);
@ -167,7 +169,7 @@ public class PackageManager implements Closeable {
if (Strings.isNullOrEmpty(packageName) == false && // There can be an empty key, storing the version here
packageVersions.get(packageName) != null) { // null means the package was undeployed from this package before
ret.put(packageName, getPackageInstance(packageName, packageVersions.get(packageName)));
ret.get(packageName).setCustomData(packagePlugins.getCollection(packageName));
ret.get(packageName).setCustomData(packagePlugins.get(packageName));
}
}
return ret;

View File

@ -26,7 +26,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.lucene.index.ExitableDirectoryReader;
import org.apache.lucene.index.IndexableField;
@ -104,8 +104,7 @@ public class Grouping {
private Query query;
private DocSet filter;
private Filter luceneFilter;
@SuppressWarnings({"rawtypes"})
private NamedList grouped = new SimpleOrderedMap();
private NamedList<Object> grouped = new SimpleOrderedMap<>();
private Set<Integer> idSet = new LinkedHashSet<>(); // used for tracking unique docs when we need a doclist
private int maxMatches; // max number of matches from any grouping command
private float maxScore = Float.NaN; // max score seen in any doclist

View File

@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import java.util.function.Supplier;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;

View File

@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
@ -68,8 +68,7 @@ public class GroupedEndResultTransformer implements EndResultTransformer {
command.add("ngroups", totalGroupCount);
}
@SuppressWarnings({"rawtypes"})
List<NamedList> groups = new ArrayList<>();
List<NamedList<Object>> groups = new ArrayList<>();
SchemaField groupField = searcher.getSchema().getField(entry.getKey());
FieldType groupFieldType = groupField.getType();
for (GroupDocs<BytesRef> group : topGroups.groups) {

View File

@ -52,7 +52,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.commons.collections4.map.CaseInsensitiveMap;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.hadoop.classification.InterfaceAudience;
@ -1489,8 +1489,7 @@ public class FileUtil {
Path targetDir,
Map<String, String> callerEnv) throws IOException {
// Replace environment variables, case-insensitive on Windows
@SuppressWarnings("unchecked")
Map<String, String> env = Shell.WINDOWS ? new CaseInsensitiveMap(callerEnv) :
Map<String, String> env = Shell.WINDOWS ? new CaseInsensitiveMap<>(callerEnv) :
callerEnv;
String[] classPathEntries = inputClassPath.split(File.pathSeparator);
for (int i = 0; i < classPathEntries.length; ++i) {

View File

@ -21,7 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.zookeeper.KeeperException;

View File

@ -25,7 +25,7 @@ import java.util.Map;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import org.apache.commons.collections.IteratorUtils;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.Test;
import org.mockito.stubbing.Answer;
@ -37,7 +37,6 @@ import static org.mockito.Mockito.when;
public class TestHttpServletCarrier extends SolrTestCaseJ4 {
@Test
@SuppressWarnings({"unchecked"})
public void test() {
SolrTestCaseJ4.assumeWorkingMockito();
HttpServletRequest req = mock(HttpServletRequest.class);

View File

@ -1 +0,0 @@
54ebea0a5b653d3c680131e73fe807bb8f78c4ed

View File

@ -0,0 +1 @@
62ebe7544cb7164d87e0637a2a6a2bdc981395e8

View File

@ -319,13 +319,11 @@ public class SignificantTermsStream extends TupleStream implements Expressible{
}
}
@SuppressWarnings({"rawtypes"})
List<Map> maps = new ArrayList<>();
List<Map<String, Object>> maps = new ArrayList<>();
for(Map.Entry<String, int[]> entry : mergeFreqs.entrySet()) {
int[] freqs = entry.getValue();
@SuppressWarnings({"rawtypes"})
Map map = new HashMap();
Map<String, Object> map = new HashMap<>();
map.put("term", entry.getKey());
map.put("background", freqs[0]);
map.put("foreground", freqs[1]);
@ -338,7 +336,7 @@ public class SignificantTermsStream extends TupleStream implements Expressible{
Collections.sort(maps, new ScoreComp());
List<Tuple> tuples = new ArrayList<>();
for (@SuppressWarnings({"rawtypes"})Map map : maps) {
for (Map<String, Object> map : maps) {
if (tuples.size() == numTerms) break;
tuples.add(new Tuple(map));
}

View File

@ -21,7 +21,7 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.solr.client.solrj.io.Tuple;
import org.apache.solr.client.solrj.io.eval.ConversionEvaluator;
import org.apache.solr.client.solrj.io.eval.RawValueEvaluator;
@ -42,14 +42,13 @@ public class ConversionEvaluatorsTest {
StreamFactory factory;
Map<String, Object> values;
@SuppressWarnings({"unchecked"})
public ConversionEvaluatorsTest() {
super();
factory = new StreamFactory();
factory.withFunctionName("convert", ConversionEvaluator.class).withFunctionName("raw", RawValueEvaluator.class);
values = new HashedMap();
values = new HashedMap<>();
}
@Test

View File

@ -30,7 +30,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.solr.client.solrj.io.Tuple;
import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
import org.apache.solr.client.solrj.io.eval.TemporalEvaluatorDay;
@ -63,7 +63,6 @@ public class TemporalEvaluatorsTest {
StreamFactory factory;
Map<String, Object> values;
@SuppressWarnings({"unchecked"})
public TemporalEvaluatorsTest() {
super();
@ -81,7 +80,7 @@ public class TemporalEvaluatorsTest {
factory.withFunctionName(TemporalEvaluatorQuarter.FUNCTION_NAME, TemporalEvaluatorQuarter.class);
factory.withFunctionName(TemporalEvaluatorDayOfQuarter.FUNCTION_NAME, TemporalEvaluatorDayOfQuarter.class);
values = new HashedMap();
values = new HashedMap<>();
}
@Test

View File

@ -20,7 +20,7 @@ import java.util.Map;
import junit.framework.Assert;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.solr.SolrTestCase;
import org.apache.solr.client.solrj.io.Tuple;
import org.apache.solr.client.solrj.io.ops.ConcatOperation;
@ -37,13 +37,12 @@ public class ConcatOperationTest extends SolrTestCase {
StreamFactory factory;
Map<String, Object> values;
@SuppressWarnings({"unchecked"})
public ConcatOperationTest() {
super();
factory = new StreamFactory()
.withFunctionName("concat", ConcatOperation.class);
values = new HashedMap();
values = new HashedMap<>();
}
@Test

View File

@ -20,7 +20,7 @@ import java.util.Map;
import junit.framework.Assert;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.solr.SolrTestCase;
import org.apache.solr.client.solrj.io.Tuple;
import org.apache.solr.client.solrj.io.ops.ReplaceOperation;
@ -37,13 +37,12 @@ public class OperationsTest extends SolrTestCase {
StreamFactory factory;
Map<String, Object> values;
@SuppressWarnings({"unchecked"})
public OperationsTest() {
super();
factory = new StreamFactory()
.withFunctionName("replace", ReplaceOperation.class);
values = new HashedMap();
values = new HashedMap<>();
}
@Test

View File

@ -91,7 +91,7 @@ org.antlr:antlr4-runtime:4.5.1-1 (1 constraints: 6a05b240)
org.apache.calcite:calcite-core:1.18.0 (1 constraints: 3c05413b)
org.apache.calcite:calcite-linq4j:1.18.0 (1 constraints: 3c05413b)
org.apache.calcite.avatica:avatica-core:1.13.0 (1 constraints: 3705323b)
org.apache.commons:commons-collections4:4.2 (1 constraints: aa04252c)
org.apache.commons:commons-collections4:4.4 (1 constraints: ac04272c)
org.apache.commons:commons-compress:1.19 (1 constraints: df04fa30)
org.apache.commons:commons-configuration2:2.1.1 (1 constraints: 0605f935)
org.apache.commons:commons-csv:1.7 (1 constraints: ac04212c)

View File

@ -49,7 +49,7 @@ net.thisptr:jackson-jq=0.0.8
org.antlr:antlr4-runtime=4.5.1-1
org.apache.calcite.avatica:avatica-core=1.13.0
org.apache.calcite:*=1.18.0
org.apache.commons:commons-collections4=4.2
org.apache.commons:commons-collections4=4.4
org.apache.commons:commons-compress=1.19
org.apache.commons:commons-configuration2=2.1.1
org.apache.commons:commons-csv=1.7