More removing ImmutableMap#of()
This commit is contained in:
parent
bd2202bf21
commit
a9d59024b9
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.action.admin.cluster.node.info;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.elasticsearch.Build;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
|
||||
|
@ -75,7 +76,7 @@ public class NodeInfo extends BaseNodeResponse {
|
|||
NodeInfo() {
|
||||
}
|
||||
|
||||
public NodeInfo(Version version, Build build, DiscoveryNode node, @Nullable ImmutableMap<String, String> serviceAttributes, @Nullable Settings settings,
|
||||
public NodeInfo(Version version, Build build, DiscoveryNode node, @Nullable Map<String, String> serviceAttributes, @Nullable Settings settings,
|
||||
@Nullable OsInfo os, @Nullable ProcessInfo process, @Nullable JvmInfo jvm, @Nullable ThreadPoolInfo threadPool,
|
||||
@Nullable TransportInfo transport, @Nullable HttpInfo http, @Nullable PluginsInfo plugins) {
|
||||
super(node);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.cluster.routing;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
|
@ -39,6 +38,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
/**
|
||||
* {@link IndexShardRoutingTable} encapsulates all instances of a single shard.
|
||||
* Each Elasticsearch index consists of multiple shards, each shard encapsulates
|
||||
|
@ -60,6 +61,10 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
|||
final static List<ShardRouting> NO_SHARDS = Collections.emptyList();
|
||||
final boolean allShardsStarted;
|
||||
|
||||
private volatile Map<AttributesKey, AttributesRoutings> activeShardsByAttributes = emptyMap();
|
||||
private volatile Map<AttributesKey, AttributesRoutings> initializingShardsByAttributes = emptyMap();
|
||||
private final Object shardsByAttributeMutex = new Object();
|
||||
|
||||
/**
|
||||
* The initializing list, including ones that are initializing on a target node because of relocation.
|
||||
* If we can come up with a better variable name, it would be nice...
|
||||
|
@ -476,10 +481,6 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
|||
}
|
||||
}
|
||||
|
||||
private volatile Map<AttributesKey, AttributesRoutings> activeShardsByAttributes = ImmutableMap.of();
|
||||
private volatile Map<AttributesKey, AttributesRoutings> initializingShardsByAttributes = ImmutableMap.of();
|
||||
private final Object shardsByAttributeMutex = new Object();
|
||||
|
||||
private AttributesRoutings getActiveAttribute(AttributesKey key, DiscoveryNodes nodes) {
|
||||
AttributesRoutings shardRoutings = activeShardsByAttributes.get(key);
|
||||
if (shardRoutings == null) {
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject.assistedinject;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
|
@ -42,6 +40,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
|
@ -223,7 +222,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
|||
}
|
||||
|
||||
if (constructors.isEmpty()) {
|
||||
return ImmutableMap.of();
|
||||
return emptyMap();
|
||||
}
|
||||
|
||||
Method[] factoryMethods = factoryType.getRawType().getMethods();
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.common.settings;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -30,20 +28,40 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import org.elasticsearch.common.property.PropertyPlaceholder;
|
||||
import org.elasticsearch.common.settings.loader.SettingsLoader;
|
||||
import org.elasticsearch.common.settings.loader.SettingsLoaderFactory;
|
||||
import org.elasticsearch.common.unit.*;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.MemorySizeValue;
|
||||
import org.elasticsearch.common.unit.RatioValue;
|
||||
import org.elasticsearch.common.unit.SizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.unmodifiableMap;
|
||||
import static org.elasticsearch.common.Strings.toCamelCase;
|
||||
import static org.elasticsearch.common.unit.ByteSizeValue.parseBytesSizeValue;
|
||||
import static org.elasticsearch.common.unit.SizeValue.parseSizeValue;
|
||||
|
@ -70,8 +88,8 @@ public final class Settings implements ToXContent {
|
|||
return settingsRequireUnits;
|
||||
}
|
||||
|
||||
private final Map<String, String> forcedUnderscoreSettings;
|
||||
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()
|
||||
|
@ -86,7 +104,7 @@ public final class Settings implements ToXContent {
|
|||
forcedUnderscoreSettings.put(toUnderscoreCase, entry.getValue());
|
||||
}
|
||||
}
|
||||
this.forcedUnderscoreSettings = forcedUnderscoreSettings == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(forcedUnderscoreSettings);
|
||||
this.forcedUnderscoreSettings = forcedUnderscoreSettings == null ? emptyMap() : unmodifiableMap(forcedUnderscoreSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.mapper;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.search.DocIdSet;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
|
@ -70,6 +69,8 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -85,7 +86,7 @@ public class DocumentMapper implements ToXContent {
|
|||
|
||||
private final RootObjectMapper rootObjectMapper;
|
||||
|
||||
private ImmutableMap<String, Object> meta = ImmutableMap.of();
|
||||
private Map<String, Object> meta = emptyMap();
|
||||
|
||||
private final Mapper.BuilderContext builderContext;
|
||||
|
||||
|
@ -115,7 +116,7 @@ public class DocumentMapper implements ToXContent {
|
|||
this.rootMappers.put(FieldNamesFieldMapper.class, new FieldNamesFieldMapper(indexSettings, mapperService.fullName(FieldNamesFieldMapper.NAME)));
|
||||
}
|
||||
|
||||
public Builder meta(ImmutableMap<String, Object> meta) {
|
||||
public Builder meta(Map<String, Object> meta) {
|
||||
this.meta = meta;
|
||||
return this;
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ public class DocumentMapper implements ToXContent {
|
|||
|
||||
public DocumentMapper(MapperService mapperService, @Nullable Settings indexSettings, DocumentMapperParser docMapperParser,
|
||||
RootObjectMapper rootObjectMapper,
|
||||
ImmutableMap<String, Object> meta,
|
||||
Map<String, Object> meta,
|
||||
Map<Class<? extends MetadataFieldMapper>, MetadataFieldMapper> rootMappers,
|
||||
List<SourceTransform> sourceTransforms,
|
||||
ReentrantReadWriteLock mappingLock) {
|
||||
|
@ -234,7 +235,7 @@ public class DocumentMapper implements ToXContent {
|
|||
return this.typeText;
|
||||
}
|
||||
|
||||
public ImmutableMap<String, Object> meta() {
|
||||
public Map<String, Object> meta() {
|
||||
return mapping.meta;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.index.mapper;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
|
@ -35,10 +36,33 @@ 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.*;
|
||||
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.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.*;
|
||||
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.ip.IpFieldMapper;
|
||||
import org.elasticsearch.index.mapper.object.ObjectMapper;
|
||||
import org.elasticsearch.index.mapper.object.RootObjectMapper;
|
||||
|
@ -47,8 +71,15 @@ import org.elasticsearch.index.similarity.SimilarityLookupService;
|
|||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static java.util.Collections.unmodifiableMap;
|
||||
import static org.elasticsearch.index.mapper.MapperBuilders.doc;
|
||||
|
||||
public class DocumentMapperParser {
|
||||
|
@ -240,11 +271,12 @@ public class DocumentMapperParser {
|
|||
}
|
||||
}
|
||||
|
||||
ImmutableMap<String, Object> attributes = ImmutableMap.of();
|
||||
if (mapping.containsKey("_meta")) {
|
||||
attributes = ImmutableMap.copyOf((Map<String, Object>) mapping.remove("_meta"));
|
||||
Map<String, Object> meta = (Map<String, Object>) mapping.remove("_meta");
|
||||
if (meta != null) {
|
||||
// It may not be required to copy meta here to maintain immutability
|
||||
// but the cost is pretty low here.
|
||||
docBuilder.meta(unmodifiableMap(new HashMap<>(meta)));
|
||||
}
|
||||
docBuilder.meta(attributes);
|
||||
|
||||
checkNoRemainingFields(mapping, parserContext.indexVersionCreated(), "Root mapping definition has unsupported parameters: ");
|
||||
|
||||
|
|
|
@ -59,9 +59,9 @@ public final class Mapping implements ToXContent {
|
|||
final MetadataFieldMapper[] metadataMappers;
|
||||
final ImmutableMap<Class<? extends MetadataFieldMapper>, MetadataFieldMapper> rootMappersMap;
|
||||
final SourceTransform[] sourceTransforms;
|
||||
volatile ImmutableMap<String, Object> meta;
|
||||
volatile Map<String, Object> meta;
|
||||
|
||||
public Mapping(Version indexCreated, RootObjectMapper rootObjectMapper, MetadataFieldMapper[] metadataMappers, SourceTransform[] sourceTransforms, ImmutableMap<String, Object> meta) {
|
||||
public Mapping(Version indexCreated, RootObjectMapper rootObjectMapper, MetadataFieldMapper[] metadataMappers, SourceTransform[] sourceTransforms, Map<String, Object> meta) {
|
||||
this.indexCreated = indexCreated;
|
||||
this.root = rootObjectMapper;
|
||||
this.metadataMappers = metadataMappers;
|
||||
|
@ -119,7 +119,7 @@ public final class Mapping implements ToXContent {
|
|||
meta = mergeWith.meta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
root.toXContent(builder, params, new ToXContent() {
|
||||
|
|
|
@ -19,22 +19,31 @@
|
|||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
/**
|
||||
* The result of parsing a query.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ParsedQuery {
|
||||
|
||||
private final Query query;
|
||||
private final ImmutableMap<String, Query> namedFilters;
|
||||
private final Map<String, Query> namedFilters;
|
||||
|
||||
public ParsedQuery(Query query, ImmutableMap<String, Query> namedFilters) {
|
||||
/**
|
||||
* Store the query and filters.
|
||||
*
|
||||
* @param query
|
||||
* the query
|
||||
* @param namedFilters
|
||||
* an immutable Map containing the named filters. Good callers
|
||||
* use emptyMap or unmodifiableMap and copy the source to make
|
||||
* sure this is immutable.
|
||||
*/
|
||||
public ParsedQuery(Query query, Map<String, Query> namedFilters) {
|
||||
this.query = query;
|
||||
this.namedFilters = namedFilters;
|
||||
}
|
||||
|
@ -46,7 +55,7 @@ public class ParsedQuery {
|
|||
|
||||
public ParsedQuery(Query query) {
|
||||
this.query = query;
|
||||
this.namedFilters = ImmutableMap.of();
|
||||
this.namedFilters = emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,11 +65,11 @@ public class ParsedQuery {
|
|||
return this.query;
|
||||
}
|
||||
|
||||
public ImmutableMap<String, Query> namedFilters() {
|
||||
return this.namedFilters;
|
||||
public Map<String, Query> namedFilters() {
|
||||
return namedFilters;
|
||||
}
|
||||
|
||||
public static ParsedQuery parsedMatchAllQuery() {
|
||||
return new ParsedQuery(Queries.newMatchAllQuery(), ImmutableMap.<String, Query>of());
|
||||
return new ParsedQuery(Queries.newMatchAllQuery(), emptyMap());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
||||
import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder;
|
||||
|
@ -121,8 +122,8 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
|||
private final NodeEnvironment nodeEnv;
|
||||
private final TimeValue shardsClosedTimeout;
|
||||
|
||||
private volatile Map<String, IndexServiceInjectorPair> indices = ImmutableMap.of();
|
||||
|
||||
private volatile Map<String, IndexServiceInjectorPair> indices = emptyMap();
|
||||
|
||||
static class IndexServiceInjectorPair {
|
||||
private final IndexService indexService;
|
||||
private final Injector injector;
|
||||
|
@ -140,7 +141,7 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
|||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final Map<Index, List<PendingDelete>> pendingDeletes = new HashMap<>();
|
||||
|
||||
private final OldShardsStats oldShardsStats = new OldShardsStats();
|
||||
|
@ -347,7 +348,7 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
|||
modules.add(new MapperServiceModule());
|
||||
modules.add(new IndexAliasesServiceModule());
|
||||
modules.add(new IndexModule(indexSettings));
|
||||
|
||||
|
||||
pluginsService.processModules(modules);
|
||||
|
||||
Injector indexInjector;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.node.service;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.elasticsearch.Build;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
|
@ -44,6 +42,8 @@ import org.elasticsearch.transport.TransportService;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class NodeService extends AbstractComponent {
|
||||
|
@ -59,7 +59,7 @@ public class NodeService extends AbstractComponent {
|
|||
@Nullable
|
||||
private HttpServer httpServer;
|
||||
|
||||
private volatile ImmutableMap<String, String> serviceAttributes = ImmutableMap.of();
|
||||
private volatile Map<String, String> serviceAttributes = emptyMap();
|
||||
|
||||
private final Version version;
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.search.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.apache.lucene.search.Explanation;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
|
@ -54,6 +52,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static java.util.Collections.unmodifiableMap;
|
||||
import static org.elasticsearch.common.lucene.Lucene.readExplanation;
|
||||
import static org.elasticsearch.common.lucene.Lucene.writeExplanation;
|
||||
import static org.elasticsearch.search.SearchShardTarget.readSearchShardTarget;
|
||||
|
@ -317,10 +317,7 @@ public class InternalSearchHit implements SearchHit {
|
|||
|
||||
@Override
|
||||
public Map<String, HighlightField> highlightFields() {
|
||||
if (highlightFields == null) {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
return this.highlightFields;
|
||||
return highlightFields == null ? emptyMap() : highlightFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -573,69 +570,32 @@ public class InternalSearchHit implements SearchHit {
|
|||
}
|
||||
int size = in.readVInt();
|
||||
if (size == 0) {
|
||||
fields = ImmutableMap.of();
|
||||
fields = emptyMap();
|
||||
} else if (size == 1) {
|
||||
SearchHitField hitField = readSearchHitField(in);
|
||||
fields = ImmutableMap.of(hitField.name(), hitField);
|
||||
} else if (size == 2) {
|
||||
SearchHitField hitField1 = readSearchHitField(in);
|
||||
SearchHitField hitField2 = readSearchHitField(in);
|
||||
fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2);
|
||||
} else if (size == 3) {
|
||||
SearchHitField hitField1 = readSearchHitField(in);
|
||||
SearchHitField hitField2 = readSearchHitField(in);
|
||||
SearchHitField hitField3 = readSearchHitField(in);
|
||||
fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2, hitField3.name(), hitField3);
|
||||
} else if (size == 4) {
|
||||
SearchHitField hitField1 = readSearchHitField(in);
|
||||
SearchHitField hitField2 = readSearchHitField(in);
|
||||
SearchHitField hitField3 = readSearchHitField(in);
|
||||
SearchHitField hitField4 = readSearchHitField(in);
|
||||
fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2, hitField3.name(), hitField3, hitField4.name(), hitField4);
|
||||
} else if (size == 5) {
|
||||
SearchHitField hitField1 = readSearchHitField(in);
|
||||
SearchHitField hitField2 = readSearchHitField(in);
|
||||
SearchHitField hitField3 = readSearchHitField(in);
|
||||
SearchHitField hitField4 = readSearchHitField(in);
|
||||
SearchHitField hitField5 = readSearchHitField(in);
|
||||
fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2, hitField3.name(), hitField3, hitField4.name(), hitField4, hitField5.name(), hitField5);
|
||||
fields = singletonMap(hitField.name(), hitField);
|
||||
} else {
|
||||
ImmutableMap.Builder<String, SearchHitField> builder = ImmutableMap.builder();
|
||||
Map<String, SearchHitField> fields = new HashMap<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
SearchHitField hitField = readSearchHitField(in);
|
||||
builder.put(hitField.name(), hitField);
|
||||
fields.put(hitField.name(), hitField);
|
||||
}
|
||||
fields = builder.build();
|
||||
this.fields = unmodifiableMap(fields);
|
||||
}
|
||||
|
||||
size = in.readVInt();
|
||||
if (size == 0) {
|
||||
highlightFields = ImmutableMap.of();
|
||||
highlightFields = emptyMap();
|
||||
} else if (size == 1) {
|
||||
HighlightField field = readHighlightField(in);
|
||||
highlightFields = ImmutableMap.of(field.name(), field);
|
||||
} else if (size == 2) {
|
||||
HighlightField field1 = readHighlightField(in);
|
||||
HighlightField field2 = readHighlightField(in);
|
||||
highlightFields = ImmutableMap.of(field1.name(), field1, field2.name(), field2);
|
||||
} else if (size == 3) {
|
||||
HighlightField field1 = readHighlightField(in);
|
||||
HighlightField field2 = readHighlightField(in);
|
||||
HighlightField field3 = readHighlightField(in);
|
||||
highlightFields = ImmutableMap.of(field1.name(), field1, field2.name(), field2, field3.name(), field3);
|
||||
} else if (size == 4) {
|
||||
HighlightField field1 = readHighlightField(in);
|
||||
HighlightField field2 = readHighlightField(in);
|
||||
HighlightField field3 = readHighlightField(in);
|
||||
HighlightField field4 = readHighlightField(in);
|
||||
highlightFields = ImmutableMap.of(field1.name(), field1, field2.name(), field2, field3.name(), field3, field4.name(), field4);
|
||||
highlightFields = singletonMap(field.name(), field);
|
||||
} else {
|
||||
ImmutableMap.Builder<String, HighlightField> builder = ImmutableMap.builder();
|
||||
Map<String, HighlightField> highlightFields = new HashMap<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
HighlightField field = readHighlightField(in);
|
||||
builder.put(field.name(), field);
|
||||
highlightFields.put(field.name(), field);
|
||||
}
|
||||
highlightFields = builder.build();
|
||||
this.highlightFields = unmodifiableMap(highlightFields);
|
||||
}
|
||||
|
||||
size = in.readVInt();
|
||||
|
|
|
@ -90,6 +90,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_CREATION_DATE;
|
||||
|
@ -232,7 +233,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
|||
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
|
||||
ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
|
||||
RoutingTable.Builder rtBuilder = RoutingTable.builder(currentState.routingTable());
|
||||
final ImmutableMap<ShardId, RestoreInProgress.ShardRestoreStatus> shards;
|
||||
Map<ShardId, RestoreInProgress.ShardRestoreStatus> shards;
|
||||
Set<String> aliases = new HashSet<>();
|
||||
if (!renamedIndices.isEmpty()) {
|
||||
// We have some indices to restore
|
||||
|
@ -311,7 +312,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
|||
RestoreInProgress.Entry restoreEntry = new RestoreInProgress.Entry(snapshotId, RestoreInProgress.State.INIT, Collections.unmodifiableList(new ArrayList<>(renamedIndices.keySet())), shards);
|
||||
builder.putCustom(RestoreInProgress.TYPE, new RestoreInProgress(restoreEntry));
|
||||
} else {
|
||||
shards = ImmutableMap.of();
|
||||
shards = emptyMap();
|
||||
}
|
||||
|
||||
checkAliasNameConflicts(renamedIndices, aliases);
|
||||
|
|
Loading…
Reference in New Issue