Remove and forbid use of com.google.common.collect.ImmutableSortedMap
This commit removes and now forbids all uses of com.google.common.collect.ImmutableSortedMap across the codebase. This is one of many steps in the eventual removal of Guava as a dependency. Relates #13224
This commit is contained in:
parent
39ca45050a
commit
d6d8d30d47
|
@ -21,7 +21,6 @@ package org.elasticsearch.common.settings;
|
|||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -71,13 +70,12 @@ public final class Settings implements ToXContent {
|
|||
return settingsRequireUnits;
|
||||
}
|
||||
|
||||
private ImmutableMap<String, String> settings;
|
||||
private SortedMap<String, String> settings;
|
||||
private final ImmutableMap<String, String> forcedUnderscoreSettings;
|
||||
|
||||
Settings(Map<String, String> settings) {
|
||||
// we use a sorted map for consistent serialization when using getAsMap()
|
||||
// TODO: use Collections.unmodifiableMap with a TreeMap
|
||||
this.settings = ImmutableSortedMap.copyOf(settings);
|
||||
this.settings = Collections.unmodifiableSortedMap(new TreeMap<>(settings));
|
||||
Map<String, String> forcedUnderscoreSettings = null;
|
||||
for (Map.Entry<String, String> entry : settings.entrySet()) {
|
||||
String toUnderscoreCase = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.index.mapper;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
|
@ -36,33 +35,10 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
|||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.core.BinaryFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.ByteFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.CompletionFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.FloatFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.IntegerFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.ShortFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.TokenCountFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.TypeParsers;
|
||||
import org.elasticsearch.index.mapper.core.*;
|
||||
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.FieldNamesFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.IdFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.IndexFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.ParentFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.RoutingFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.SourceFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.TTLFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.TypeFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.VersionFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.*;
|
||||
import org.elasticsearch.index.mapper.ip.IpFieldMapper;
|
||||
import org.elasticsearch.index.mapper.object.ObjectMapper;
|
||||
import org.elasticsearch.index.mapper.object.RootObjectMapper;
|
||||
|
@ -71,11 +47,7 @@ import org.elasticsearch.index.similarity.SimilarityLookupService;
|
|||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static org.elasticsearch.index.mapper.MapperBuilders.doc;
|
||||
|
||||
|
@ -96,7 +68,7 @@ public class DocumentMapperParser {
|
|||
|
||||
private volatile ImmutableMap<String, Mapper.TypeParser> typeParsers;
|
||||
private volatile ImmutableMap<String, Mapper.TypeParser> rootTypeParsers;
|
||||
private volatile ImmutableMap<String, Mapper.TypeParser> additionalRootMappers;
|
||||
private volatile SortedMap<String, Mapper.TypeParser> additionalRootMappers;
|
||||
|
||||
public DocumentMapperParser(@IndexSettings Settings indexSettings, MapperService mapperService, AnalysisService analysisService,
|
||||
SimilarityLookupService similarityLookupService, ScriptService scriptService) {
|
||||
|
@ -145,7 +117,7 @@ public class DocumentMapperParser {
|
|||
.put(IdFieldMapper.NAME, new IdFieldMapper.TypeParser())
|
||||
.put(FieldNamesFieldMapper.NAME, new FieldNamesFieldMapper.TypeParser())
|
||||
.immutableMap();
|
||||
additionalRootMappers = ImmutableSortedMap.<String, Mapper.TypeParser>of();
|
||||
additionalRootMappers = Collections.emptySortedMap();
|
||||
indexVersionCreated = Version.indexCreated(indexSettings);
|
||||
}
|
||||
|
||||
|
@ -162,10 +134,10 @@ public class DocumentMapperParser {
|
|||
rootTypeParsers = new MapBuilder<>(rootTypeParsers)
|
||||
.put(type, typeParser)
|
||||
.immutableMap();
|
||||
additionalRootMappers = ImmutableSortedMap.<String, Mapper.TypeParser>naturalOrder()
|
||||
.putAll(additionalRootMappers)
|
||||
.put(type, typeParser)
|
||||
.build();
|
||||
SortedMap<String, Mapper.TypeParser> newAdditionalRootMappers = new TreeMap<>();
|
||||
newAdditionalRootMappers.putAll(additionalRootMappers);
|
||||
newAdditionalRootMappers.put(type, typeParser);
|
||||
additionalRootMappers = Collections.unmodifiableSortedMap(newAdditionalRootMappers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,3 +106,4 @@ com.google.common.util.concurrent.ListenableFuture
|
|||
com.google.common.util.concurrent.SettableFuture
|
||||
com.google.common.util.concurrent.Futures
|
||||
com.google.common.util.concurrent.MoreExecutors
|
||||
com.google.common.collect.ImmutableSortedMap
|
||||
|
|
Loading…
Reference in New Issue