Remove and forbid use of com.google.common.collect.Maps

This commit removes and now forbids all uses of
com.google.common.collect.Maps across the codebase. This is one of many
steps in the eventual removal of Guava as a dependency.

Relates 
This commit is contained in:
Jason Tedor 2015-09-09 14:14:48 -04:00
parent 9e6115b066
commit 2a5412ebf0
155 changed files with 730 additions and 550 deletions
core/src/main/java/org/elasticsearch
action
cluster
common
discovery/zen/publish
gateway
index
indices
repositories
rest/action
script
search

@ -19,7 +19,6 @@
package org.elasticsearch.action;
import com.google.common.collect.Maps;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction;
import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction;
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsAction;
@ -193,6 +192,7 @@ import org.elasticsearch.common.inject.multibindings.MapBinder;
import org.elasticsearch.common.inject.multibindings.Multibinder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -201,7 +201,7 @@ import java.util.Map;
*/
public class ActionModule extends AbstractModule {
private final Map<String, ActionEntry> actions = Maps.newHashMap();
private final Map<String, ActionEntry> actions = new HashMap<>();
private final List<Class<? extends ActionFilter>> actionFilters = new ArrayList<>();
static class ActionEntry<Request extends ActionRequest, Response extends ActionResponse> {

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.health;
import com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.ClusterState;
@ -39,6 +38,7 @@ import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -67,7 +67,7 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
boolean timedOut = false;
ClusterHealthStatus status = ClusterHealthStatus.RED;
private List<String> validationFailures;
Map<String, ClusterIndexHealth> indices = Maps.newHashMap();
Map<String, ClusterIndexHealth> indices = new HashMap<>();
ClusterHealthResponse() {
}

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.health;
import com.google.common.collect.Maps;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
@ -32,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -62,7 +62,7 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
private ClusterHealthStatus status = ClusterHealthStatus.RED;
private final Map<Integer, ClusterShardHealth> shards = Maps.newHashMap();
private final Map<Integer, ClusterShardHealth> shards = new HashMap<>();
private List<String> validationFailures;

@ -25,11 +25,11 @@ import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.SnapshotId;
import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -43,11 +43,11 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Sets.newHashSet;
/**
@ -146,7 +146,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
if (nodeSnapshotStatuses != null) {
nodeSnapshotStatusMap = nodeSnapshotStatuses.getNodesMap();
} else {
nodeSnapshotStatusMap = newHashMap();
nodeSnapshotStatusMap = new HashMap<>();
}
for (SnapshotsInProgress.Entry entry : currentSnapshots) {

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.create;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest;
@ -28,11 +27,10 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.transport.TransportMessage;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
/**
* Cluster state update request that allows to create an index
*/
@ -47,11 +45,11 @@ public class CreateIndexClusterStateUpdateRequest extends ClusterStateUpdateRequ
private Settings settings = Settings.Builder.EMPTY_SETTINGS;
private final Map<String, String> mappings = Maps.newHashMap();
private final Map<String, String> mappings = new HashMap<>();
private final Set<Alias> aliases = Sets.newHashSet();
private final Map<String, IndexMetaData.Custom> customs = newHashMap();
private final Map<String, IndexMetaData.Custom> customs = new HashMap<>();
private final Set<ClusterBlock> blocks = Sets.newHashSet();

@ -37,13 +37,17 @@ import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
import static org.elasticsearch.action.ValidateActions.addValidationError;
import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
import static org.elasticsearch.common.settings.Settings.readSettingsFromStream;
@ -66,11 +70,11 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
private Settings settings = EMPTY_SETTINGS;
private final Map<String, String> mappings = newHashMap();
private final Map<String, String> mappings = new HashMap<>();
private final Set<Alias> aliases = Sets.newHashSet();
private final Map<String, IndexMetaData.Custom> customs = newHashMap();
private final Map<String, IndexMetaData.Custom> customs = new HashMap<>();
private boolean updateAllTypes = false;

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.recovery;
import com.google.common.collect.Maps;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction;
@ -42,6 +41,7 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -70,7 +70,7 @@ public class TransportRecoveryAction extends TransportBroadcastByNodeAction<Reco
@Override
protected RecoveryResponse newResponse(RecoveryRequest request, int totalShards, int successfulShards, int failedShards, List<RecoveryState> responses, List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
Map<String, List<RecoveryState>> shardResponses = Maps.newHashMap();
Map<String, List<RecoveryState>> shardResponses = new HashMap<>();
for (RecoveryState recoveryState : responses) {
if (recoveryState == null) {
continue;

@ -19,9 +19,8 @@
package org.elasticsearch.action.admin.indices.segments;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -35,7 +34,7 @@ public class IndexSegments implements Iterable<IndexShardSegments> {
IndexSegments(String index, ShardSegments[] shards) {
this.index = index;
Map<Integer, List<ShardSegments>> tmpIndexShards = Maps.newHashMap();
Map<Integer, List<ShardSegments>> tmpIndexShards = new HashMap<>();
for (ShardSegments shard : shards) {
List<ShardSegments> lst = tmpIndexShards.get(shard.getShardRouting().id());
if (lst == null) {
@ -44,7 +43,7 @@ public class IndexSegments implements Iterable<IndexShardSegments> {
}
lst.add(shard);
}
indexShards = Maps.newHashMap();
indexShards = new HashMap<>();
for (Map.Entry<Integer, List<ShardSegments>> entry : tmpIndexShards.entrySet()) {
indexShards.put(entry.getKey(), new IndexShardSegments(entry.getValue().get(0).getShardRouting().shardId(), entry.getValue().toArray(new ShardSegments[entry.getValue().size()])));
}

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.segments;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.lucene.util.Accountable;
import org.elasticsearch.action.ShardOperationFailedException;
@ -35,6 +34,7 @@ import org.elasticsearch.index.engine.Segment;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -58,7 +58,7 @@ public class IndicesSegmentResponse extends BroadcastResponse implements ToXCont
if (indicesSegments != null) {
return indicesSegments;
}
Map<String, IndexSegments> indicesSegments = Maps.newHashMap();
Map<String, IndexSegments> indicesSegments = new HashMap<>();
Set<String> indices = Sets.newHashSet();
for (ShardSegments shard : shards) {

@ -19,9 +19,8 @@
package org.elasticsearch.action.admin.indices.stats;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -53,7 +52,7 @@ public class IndexStats implements Iterable<IndexShardStats> {
if (indexShards != null) {
return indexShards;
}
Map<Integer, List<ShardStats>> tmpIndexShards = Maps.newHashMap();
Map<Integer, List<ShardStats>> tmpIndexShards = new HashMap<>();
for (ShardStats shard : shards) {
List<ShardStats> lst = tmpIndexShards.get(shard.getShardRouting().id());
if (lst == null) {
@ -62,7 +61,7 @@ public class IndexStats implements Iterable<IndexShardStats> {
}
lst.add(shard);
}
indexShards = Maps.newHashMap();
indexShards = new HashMap<>();
for (Map.Entry<Integer, List<ShardStats>> entry : tmpIndexShards.entrySet()) {
indexShards.put(entry.getKey(), new IndexShardStats(entry.getValue().get(0).getShardRouting().shardId(), entry.getValue().toArray(new ShardStats[entry.getValue().size()])));
}

@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.stats;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
@ -34,6 +33,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -85,7 +85,7 @@ public class IndicesStatsResponse extends BroadcastResponse implements ToXConten
if (indicesStats != null) {
return indicesStats;
}
Map<String, IndexStats> indicesStats = Maps.newHashMap();
Map<String, IndexStats> indicesStats = new HashMap<>();
Set<String> indices = Sets.newHashSet();
for (ShardStats shard : shards) {

@ -33,14 +33,18 @@ import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Sets.newHashSet;
import static org.elasticsearch.action.ValidateActions.addValidationError;
import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
@ -64,11 +68,11 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
private Settings settings = EMPTY_SETTINGS;
private Map<String, String> mappings = newHashMap();
private Map<String, String> mappings = new HashMap<>();
private final Set<Alias> aliases = newHashSet();
private Map<String, IndexMetaData.Custom> customs = newHashMap();
private Map<String, IndexMetaData.Custom> customs = new HashMap<>();
PutIndexTemplateRequest() {
}

@ -19,9 +19,8 @@
package org.elasticsearch.action.admin.indices.upgrade.get;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -35,7 +34,7 @@ public class IndexUpgradeStatus implements Iterable<IndexShardUpgradeStatus> {
IndexUpgradeStatus(String index, ShardUpgradeStatus[] shards) {
this.index = index;
Map<Integer, List<ShardUpgradeStatus>> tmpIndexShards = Maps.newHashMap();
Map<Integer, List<ShardUpgradeStatus>> tmpIndexShards = new HashMap<>();
for (ShardUpgradeStatus shard : shards) {
List<ShardUpgradeStatus> lst = tmpIndexShards.get(shard.getShardRouting().id());
if (lst == null) {
@ -44,7 +43,7 @@ public class IndexUpgradeStatus implements Iterable<IndexShardUpgradeStatus> {
}
lst.add(shard);
}
indexShards = Maps.newHashMap();
indexShards = new HashMap<>();
for (Map.Entry<Integer, List<ShardUpgradeStatus>> entry : tmpIndexShards.entrySet()) {
indexShards.put(entry.getKey(), new IndexShardUpgradeStatus(entry.getValue().get(0).getShardRouting().shardId(), entry.getValue().toArray(new ShardUpgradeStatus[entry.getValue().size()])));
}

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.upgrade.get;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
@ -31,6 +30,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -52,7 +52,7 @@ public class UpgradeStatusResponse extends BroadcastResponse implements ToXConte
if (indicesUpgradeStatus != null) {
return indicesUpgradeStatus;
}
Map<String, IndexUpgradeStatus> indicesUpgradeStats = Maps.newHashMap();
Map<String, IndexUpgradeStatus> indicesUpgradeStats = new HashMap<>();
Set<String> indices = Sets.newHashSet();
for (ShardUpgradeStatus shard : shards) {

@ -45,11 +45,11 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Sets.newHashSet;
/**
@ -72,8 +72,8 @@ public class TransportUpgradeAction extends TransportBroadcastByNodeAction<Upgra
@Override
protected UpgradeResponse newResponse(UpgradeRequest request, int totalShards, int successfulShards, int failedShards, List<ShardUpgradeResult> shardUpgradeResults, List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
Map<String, Integer> successfulPrimaryShards = newHashMap();
Map<String, Tuple<Version, org.apache.lucene.util.Version>> versions = newHashMap();
Map<String, Integer> successfulPrimaryShards = new HashMap<>();
Map<String, Tuple<Version, org.apache.lucene.util.Version>> versions = new HashMap<>();
for (ShardUpgradeResult result : shardUpgradeResults) {
successfulShards++;
String index = result.getShardId().getIndex();
@ -101,7 +101,7 @@ public class TransportUpgradeAction extends TransportBroadcastByNodeAction<Upgra
versions.put(index, new Tuple<>(version, luceneVersion));
}
}
Map<String, Tuple<org.elasticsearch.Version, String>> updatedVersions = newHashMap();
Map<String, Tuple<org.elasticsearch.Version, String>> updatedVersions = new HashMap<>();
MetaData metaData = clusterState.metaData();
for (Map.Entry<String, Tuple<Version, org.apache.lucene.util.Version>> versionEntry : versions.entrySet()) {
String index = versionEntry.getKey();

@ -27,11 +27,10 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* A response for optimize action.
*
@ -54,7 +53,7 @@ public class UpgradeResponse extends BroadcastResponse {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
versions = newHashMap();
versions = new HashMap<>();
for (int i=0; i<size; i++) {
String index = in.readString();
Version upgradeVersion = Version.readVersion(in);

@ -27,9 +27,9 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
import static org.elasticsearch.action.ValidateActions.addValidationError;
/**
@ -79,7 +79,7 @@ public class UpgradeSettingsRequest extends AcknowledgedRequest<UpgradeSettingsR
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
versions = newHashMap();
versions = new HashMap<>();
for (int i=0; i<size; i++) {
String index = in.readString();
Version upgradeVersion = Version.readVersion(in);

@ -19,7 +19,6 @@
package org.elasticsearch.action.bulk;
import com.google.common.collect.Maps;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.ExceptionsHelper;
@ -246,7 +245,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
}
// first, go over all the requests and create a ShardId -> Operations mapping
Map<ShardId, List<BulkItemRequest>> requestsByShard = Maps.newHashMap();
Map<ShardId, List<BulkItemRequest>> requestsByShard = new HashMap<>();
for (int i = 0; i < bulkRequest.requests.size(); i++) {
ActionRequest request = bulkRequest.requests.get(i);

@ -20,7 +20,6 @@
package org.elasticsearch.action.search.type;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRefBuilder;
import org.elasticsearch.action.search.SearchRequest;
@ -36,6 +35,7 @@ import org.elasticsearch.search.internal.InternalScrollSearchRequest;
import org.elasticsearch.search.internal.ShardSearchTransportRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
@ -114,7 +114,7 @@ public abstract class TransportSearchHelper {
if (attributesSize == 0) {
attributes = ImmutableMap.of();
} else {
attributes = Maps.newHashMapWithExpectedSize(attributesSize);
attributes = new HashMap<>(attributesSize);
for (int i = 0; i < attributesSize; i++) {
String element = elements[index++];
int sep = element.indexOf(':');

@ -19,7 +19,6 @@
package org.elasticsearch.action.support.broadcast.node;
import com.google.common.collect.Maps;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.IndicesRequest;
@ -57,6 +56,7 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
@ -247,7 +247,7 @@ public abstract class TransportBroadcastByNodeAction<Request extends BroadcastRe
logger.trace("resolving shards for [{}] based on cluster state version [{}]", actionName, clusterState.version());
ShardsIterator shardIt = shards(clusterState, request, concreteIndices);
nodeIds = Maps.newHashMap();
nodeIds = new HashMap<>();
for (ShardRouting shard : shardIt.asUnordered()) {
if (shard.assignedToNode()) {

@ -19,7 +19,6 @@
package org.elasticsearch.action.support.nodes;
import com.google.common.collect.Maps;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.cluster.ClusterName;
@ -28,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@ -79,7 +79,7 @@ public abstract class BaseNodesResponse<TNodeResponse extends BaseNodeResponse>
public Map<String, TNodeResponse> getNodesMap() {
if (nodesMap == null) {
nodesMap = Maps.newHashMap();
nodesMap = new HashMap<>();
for (TNodeResponse nodeResponse : nodes) {
nodesMap.put(nodeResponse.getNode().id(), nodeResponse);
}

@ -19,7 +19,6 @@
package org.elasticsearch.action.termvectors;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchParseException;
@ -39,7 +38,13 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.VersionType;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
@ -423,7 +428,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
* Override the analyzer used at each field when generating term vectors.
*/
public TermVectorsRequest perFieldAnalyzer(Map<String, String> perFieldAnalyzer) {
this.perFieldAnalyzer = perFieldAnalyzer != null && perFieldAnalyzer.size() != 0 ? Maps.newHashMap(perFieldAnalyzer) : null;
this.perFieldAnalyzer = perFieldAnalyzer != null && perFieldAnalyzer.size() != 0 ? new HashMap<>(perFieldAnalyzer) : null;
return this;
}

@ -53,8 +53,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMapWithExpectedSize;
/**
* Helper for translating an update request to an index, delete request or update response.
*/
@ -291,7 +289,7 @@ public class UpdateHelper extends AbstractComponent {
Object value = sourceLookup.extractValue(field);
if (value != null) {
if (fields == null) {
fields = newHashMapWithExpectedSize(2);
fields = new HashMap<>(2);
}
GetField getField = fields.get(field);
if (getField == null) {

@ -32,8 +32,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
public final class DiffableUtils {
private DiffableUtils() {
}
@ -152,7 +150,7 @@ public final class DiffableUtils {
@Override
public ImmutableMap<String, T> apply(ImmutableMap<String, T> map) {
HashMap<String, T> builder = newHashMap();
HashMap<String, T> builder = new HashMap<>();
builder.putAll(map);
for (String part : deletes) {
@ -233,14 +231,14 @@ public final class DiffableUtils {
protected MapDiff() {
deletes = new ArrayList<>();
diffs = newHashMap();
adds = newHashMap();
diffs = new HashMap<>();
adds = new HashMap<>();
}
protected MapDiff(StreamInput in, KeyedReader<T> reader) throws IOException {
deletes = new ArrayList<>();
diffs = newHashMap();
adds = newHashMap();
diffs = new HashMap<>();
adds = new HashMap<>();
int deletesCount = in.readVInt();
for (int i = 0; i < deletesCount; i++) {
deletes.add(in.readString());

@ -34,11 +34,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* Meta data about snapshots that are currently executing
*/
@ -155,7 +154,7 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
}
private ImmutableMap<String, List<ShardId>> findWaitingIndices(ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
Map<String, List<ShardId>> waitingIndicesMap = newHashMap();
Map<String, List<ShardId>> waitingIndicesMap = new HashMap<>();
for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> entry : shards.entrySet()) {
if (entry.getValue().state() == State.WAITING) {
List<ShardId> waitingShards = waitingIndicesMap.get(entry.getKey().getIndex());

@ -21,7 +21,6 @@ package org.elasticsearch.cluster.block;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.cluster.AbstractDiffable;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@ -31,6 +30,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@ -272,7 +272,7 @@ public class ClusterBlocks extends AbstractDiffable<ClusterBlocks> {
private Set<ClusterBlock> global = Sets.newHashSet();
private Map<String, Set<ClusterBlock>> indices = Maps.newHashMap();
private Map<String, Set<ClusterBlock>> indices = new HashMap<>();
public Builder() {
}

@ -43,6 +43,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@ -51,8 +52,6 @@ import java.util.Set;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import static com.google.common.collect.Maps.newHashMap;
public class IndexNameExpressionResolver extends AbstractComponent {
private final List<ExpressionResolver> expressionResolvers;
@ -324,7 +323,7 @@ public class IndexNameExpressionResolver extends AbstractComponent {
if (!aliasMetaData.searchRoutingValues().isEmpty()) {
// Routing alias
if (routings == null) {
routings = newHashMap();
routings = new HashMap<>();
}
Set<String> r = routings.get(concreteIndex);
if (r == null) {
@ -345,7 +344,7 @@ public class IndexNameExpressionResolver extends AbstractComponent {
if (paramRouting != null) {
Set<String> r = new HashSet<>(paramRouting);
if (routings == null) {
routings = newHashMap();
routings = new HashMap<>();
}
routings.put(concreteIndex, r);
} else {
@ -364,7 +363,7 @@ public class IndexNameExpressionResolver extends AbstractComponent {
if (paramRouting != null) {
Set<String> r = new HashSet<>(paramRouting);
if (routings == null) {
routings = newHashMap();
routings = new HashMap<>();
}
routings.put(expression, r);
} else {
@ -388,7 +387,7 @@ public class IndexNameExpressionResolver extends AbstractComponent {
private Map<String, Set<String>> resolveSearchRoutingAllIndices(MetaData metaData, String routing) {
if (routing != null) {
Set<String> r = Strings.splitStringByCommaToSet(routing);
Map<String, Set<String>> routings = newHashMap();
Map<String, Set<String>> routings = new HashMap<>();
String[] concreteIndices = metaData.concreteAllIndices();
for (String index : concreteIndices) {
routings.put(index, r);

@ -22,7 +22,6 @@ package org.elasticsearch.cluster.metadata;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.base.Charsets;
import com.google.common.collect.Maps;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
@ -36,7 +35,8 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.metadata.IndexMetaData.*;
import org.elasticsearch.cluster.metadata.IndexMetaData.Custom;
import org.elasticsearch.cluster.metadata.IndexMetaData.State;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.AllocationService;
@ -81,6 +81,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -88,7 +89,12 @@ import java.util.Set;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_CREATION_DATE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_INDEX_UUID;
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.cluster.metadata.IndexMetaData.SETTING_VERSION_CREATED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/**
@ -245,12 +251,12 @@ public class MetaDataCreateIndexService extends AbstractComponent {
// find templates, highest order are better matching
List<IndexTemplateMetaData> templates = findTemplates(request, currentState, indexTemplateFilter);
Map<String, Custom> customs = Maps.newHashMap();
Map<String, Custom> customs = new HashMap<>();
// add the request mapping
Map<String, Map<String, Object>> mappings = Maps.newHashMap();
Map<String, Map<String, Object>> mappings = new HashMap<>();
Map<String, AliasMetaData> templatesAliases = Maps.newHashMap();
Map<String, AliasMetaData> templatesAliases = new HashMap<>();
List<String> templateNames = new ArrayList<>();
@ -392,7 +398,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
}
// now, update the mappings with the actual source
Map<String, MappingMetaData> mappingsMetaData = Maps.newHashMap();
Map<String, MappingMetaData> mappingsMetaData = new HashMap<>();
for (DocumentMapper mapper : mapperService.docMappers(true)) {
MappingMetaData mappingMd = new MappingMetaData(mapper);
mappingsMetaData.put(mapper.type(), mappingMd);

@ -20,7 +20,6 @@
package org.elasticsearch.cluster.metadata;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.Maps;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesClusterStateUpdateRequest;
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
@ -38,6 +37,7 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.indices.IndicesService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -70,7 +70,7 @@ public class MetaDataIndexAliasesService extends AbstractComponent {
@Override
public ClusterState execute(final ClusterState currentState) {
List<String> indicesToClose = new ArrayList<>();
Map<String, IndexService> indices = Maps.newHashMap();
Map<String, IndexService> indices = new HashMap<>();
try {
for (AliasAction aliasAction : request.actions()) {
aliasValidator.validateAliasAction(aliasAction, currentState.metaData());

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.metadata;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.support.master.MasterNodeRequest;
@ -39,6 +38,7 @@ import org.elasticsearch.indices.IndexTemplateMissingException;
import org.elasticsearch.indices.InvalidIndexTemplateException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -239,9 +239,9 @@ public class MetaDataIndexTemplateService extends AbstractComponent {
int order;
String template;
Settings settings = Settings.Builder.EMPTY_SETTINGS;
Map<String, String> mappings = Maps.newHashMap();
Map<String, String> mappings = new HashMap<>();
List<Alias> aliases = new ArrayList<>();
Map<String, IndexMetaData.Custom> customs = Maps.newHashMap();
Map<String, IndexMetaData.Custom> customs = new HashMap<>();
TimeValue masterTimeout = MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT;

@ -20,7 +20,6 @@
package org.elasticsearch.cluster.metadata;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
@ -49,11 +48,10 @@ import org.elasticsearch.percolator.PercolatorService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
/**
* Service responsible for submitting mapping changes
*/
@ -141,7 +139,7 @@ public class MetaDataMappingService extends AbstractComponent {
// break down to tasks per index, so we can optimize the on demand index service creation
// to only happen for the duration of a single index processing of its respective events
Map<String, List<MappingTask>> tasksPerIndex = Maps.newHashMap();
Map<String, List<MappingTask>> tasksPerIndex = new HashMap<>();
for (MappingTask task : allTasks) {
if (task.index == null) {
logger.debug("ignoring a mapping task of type [{}] with a null index.", task);
@ -372,8 +370,8 @@ public class MetaDataMappingService extends AbstractComponent {
}
}
Map<String, DocumentMapper> newMappers = newHashMap();
Map<String, DocumentMapper> existingMappers = newHashMap();
Map<String, DocumentMapper> newMappers = new HashMap<>();
Map<String, DocumentMapper> existingMappers = new HashMap<>();
for (String index : request.indices()) {
IndexService indexService = indicesService.indexServiceSafe(index);
// try and parse it (no need to add it here) so we can bail early in case of parsing exception
@ -427,7 +425,7 @@ public class MetaDataMappingService extends AbstractComponent {
throw new InvalidTypeNameException("Document mapping type name can't start with '_'");
}
final Map<String, MappingMetaData> mappings = newHashMap();
final Map<String, MappingMetaData> mappings = new HashMap<>();
for (Map.Entry<String, DocumentMapper> entry : newMappers.entrySet()) {
String index = entry.getKey();
// do the actual merge here on the master, and update the mapping source

@ -19,11 +19,11 @@
package org.elasticsearch.cluster.node;
import com.google.common.collect.Maps;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@ -45,7 +45,7 @@ public class DiscoveryNodeService extends AbstractComponent {
}
public Map<String, String> buildAttributes() {
Map<String, String> attributes = Maps.newHashMap(settings.getByPrefix("node.").getAsMap());
Map<String, String> attributes = new HashMap<>(settings.getByPrefix("node.").getAsMap());
attributes.remove("name"); // name is extracted in other places
if (attributes.containsKey("client")) {
if (attributes.get("client").equals("false")) {

@ -41,7 +41,6 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Sets.newHashSet;
/**
@ -56,11 +55,11 @@ public class RoutingNodes implements Iterable<RoutingNode> {
private final RoutingTable routingTable;
private final Map<String, RoutingNode> nodesToShards = newHashMap();
private final Map<String, RoutingNode> nodesToShards = new HashMap<>();
private final UnassignedShards unassignedShards = new UnassignedShards(this);
private final Map<ShardId, List<ShardRouting>> assignedShards = newHashMap();
private final Map<ShardId, List<ShardRouting>> assignedShards = new HashMap<>();
private final ImmutableOpenMap<String, ClusterState.Custom> customs;
@ -85,7 +84,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
this.routingTable = clusterState.routingTable();
this.customs = clusterState.customs();
Map<String, List<ShardRouting>> nodesToShards = newHashMap();
Map<String, List<ShardRouting>> nodesToShards = new HashMap<>();
// fill in the nodeToShards with the "live" nodes
for (ObjectCursor<DiscoveryNode> cursor : clusterState.nodes().dataNodes().values()) {
nodesToShards.put(cursor.value.id(), new ArrayList<ShardRouting>());

@ -35,12 +35,11 @@ import org.elasticsearch.index.IndexNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import static com.google.common.collect.Maps.newHashMap;
/**
* Represents a global cluster-wide routing table for all indices including the
* version of the current routing state.
@ -345,7 +344,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
public static class Builder {
private long version;
private final Map<String, IndexRoutingTable> indicesRouting = newHashMap();
private final Map<String, IndexRoutingTable> indicesRouting = new HashMap<>();
public Builder() {
@ -362,7 +361,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
// this is being called without pre initializing the routing table, so we must copy over the version as well
this.version = routingNodes.routingTable().version();
Map<String, IndexRoutingTable.Builder> indexRoutingTableBuilders = newHashMap();
Map<String, IndexRoutingTable.Builder> indexRoutingTableBuilders = new HashMap<>();
for (RoutingNode routingNode : routingNodes) {
for (ShardRouting shardRoutingEntry : routingNode) {
// every relocating shard has a double entry, ignore the target one.

@ -27,11 +27,10 @@ import org.elasticsearch.common.io.stream.Streamable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* Encapsulates the result of a routing table validation and provides access to
* validation failures.
@ -100,7 +99,7 @@ public class RoutingTableValidation implements Streamable {
public void addIndexFailure(String index, String failure) {
valid = false;
if (indicesFailures == null) {
indicesFailures = newHashMap();
indicesFailures = new HashMap<>();
}
List<String> indexFailures = indicesFailures.get(index);
if (indexFailures == null) {
@ -131,7 +130,7 @@ public class RoutingTableValidation implements Streamable {
if (size == 0) {
indicesFailures = ImmutableMap.of();
} else {
indicesFailures = newHashMap();
indicesFailures = new HashMap<>();
for (int i = 0; i < size; i++) {
String index = in.readString();
int size2 = in.readVInt();

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.routing.allocation;
import com.google.common.collect.Maps;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -28,6 +27,7 @@ import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -77,7 +77,7 @@ public class AllocationExplanation implements Streamable {
}
}
private final Map<ShardId, List<NodeExplanation>> explanations = Maps.newHashMap();
private final Map<ShardId, List<NodeExplanation>> explanations = new HashMap<>();
/**
* Create and add a node explanation to this explanation referencing a shard

@ -20,7 +20,6 @@
package org.elasticsearch.cluster.routing.allocation.decider;
import com.carrotsearch.hppc.ObjectIntHashMap;
import com.google.common.collect.Maps;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting;
@ -135,7 +134,7 @@ public class AwarenessAllocationDecider extends AllocationDecider {
super(settings);
this.awarenessAttributes = settings.getAsArray(CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTES);
forcedAwarenessAttributes = Maps.newHashMap();
forcedAwarenessAttributes = new HashMap<>();
Map<String, Settings> forceGroups = settings.getGroups(CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP);
for (Map.Entry<String, Settings> entry : forceGroups.entrySet()) {
String[] aValues = entry.getValue().getAsArray("values");

@ -20,7 +20,6 @@
package org.elasticsearch.common;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.HashMap;
@ -33,8 +32,8 @@ public class Table {
private List<Cell> headers = new ArrayList<>();
private List<List<Cell>> rows = new ArrayList<>();
private Map<String, List<Cell>> map = Maps.newHashMap();
private Map<String, Cell> headerMap = Maps.newHashMap();
private Map<String, List<Cell>> map = new HashMap<>();
private Map<String, Cell> headerMap = new HashMap<>();
private List<Cell> currentCells;
private boolean inHeaders = false;

@ -19,7 +19,6 @@
package org.elasticsearch.common.cli;
import com.google.common.collect.Maps;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
@ -30,6 +29,7 @@ import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@ -69,9 +69,9 @@ public abstract class CheckFileCommand extends CliTool.Command {
return doExecute(settings, env);
}
Map<Path, Set<PosixFilePermission>> permissions = Maps.newHashMapWithExpectedSize(paths.length);
Map<Path, String> owners = Maps.newHashMapWithExpectedSize(paths.length);
Map<Path, String> groups = Maps.newHashMapWithExpectedSize(paths.length);
Map<Path, Set<PosixFilePermission>> permissions = new HashMap<>(paths.length);
Map<Path, String> owners = new HashMap<>(paths.length);
Map<Path, String> groups = new HashMap<>(paths.length);
if (paths != null && paths.length > 0) {
for (Path path : paths) {

@ -20,12 +20,20 @@
package org.elasticsearch.common.collect;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.UnmodifiableIterator;
import org.apache.lucene.util.mutable.MutableValueInt;
import java.lang.reflect.Array;
import java.util.*;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
/**
* An immutable map whose writes result in a new copy of the map to be created.
@ -128,7 +136,7 @@ public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {
@Override
void visit(Deque<Map.Entry<K, V>> entries, Deque<Node<K, V>> nodes) {
for (int i = 0; i < keys.length; ++i) {
entries.add(Maps.immutableEntry(keys[i], values[i]));
entries.add(new AbstractMap.SimpleImmutableEntry<>(keys[i], values[i]));
}
}
@ -278,7 +286,7 @@ public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {
} else {
@SuppressWarnings("unchecked")
final V value = (V) sub;
entries.add(Maps.immutableEntry(keys[i], value));
entries.add(new AbstractMap.SimpleImmutableEntry<>(keys[i], value));
}
}
}

@ -22,8 +22,8 @@ package org.elasticsearch.common.collect;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.ForwardingSet;
import com.google.common.collect.Maps;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@ -81,7 +81,7 @@ public class CopyOnWriteHashSet<T> extends ForwardingSet<T> {
final Collection<Entry<T, Boolean>> asMapEntries = Collections2.transform(entries,new Function<T, Map.Entry<T, Boolean>>() {
@Override
public Entry<T, Boolean> apply(T input) {
return Maps.immutableEntry(input, true);
return new AbstractMap.SimpleImmutableEntry<>(input, true);
}
});
CopyOnWriteHashMap<T, Boolean> updated = this.map.copyAndPutAll(asMapEntries);

@ -21,10 +21,9 @@ package org.elasticsearch.common.collect;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
*
*/
@ -38,14 +37,14 @@ public class MapBuilder<K, V> {
return new MapBuilder<>(map);
}
private Map<K, V> map = newHashMap();
private Map<K, V> map = new HashMap<>();
public MapBuilder() {
this.map = newHashMap();
this.map = new HashMap<>();
}
public MapBuilder(Map<K, V> map) {
this.map = newHashMap(map);
this.map = new HashMap<>(map);
}
public MapBuilder<K, V> putAll(Map<K, V> map) {

@ -17,7 +17,6 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.internal.BindingImpl;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.internal.InstanceBindingImpl;
@ -30,6 +29,8 @@ import org.elasticsearch.common.inject.spi.TypeListenerBinding;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -43,10 +44,10 @@ class InheritingState implements State {
private final State parent;
// Must be a linked hashmap in order to preserve order of bindings in Modules.
private final Map<Key<?>, Binding<?>> explicitBindingsMutable = Maps.newLinkedHashMap();
private final Map<Key<?>, Binding<?>> explicitBindingsMutable = new LinkedHashMap<>();
private final Map<Key<?>, Binding<?>> explicitBindings
= Collections.unmodifiableMap(explicitBindingsMutable);
private final Map<Class<? extends Annotation>, Scope> scopes = Maps.newHashMap();
private final Map<Class<? extends Annotation>, Scope> scopes = new HashMap<>();
private final List<MatcherAndConverter> converters = new ArrayList<>();
private final List<TypeListenerBinding> listenerBindings = new ArrayList<>();
private WeakKeySet blacklistedKeys = new WeakKeySet();
@ -150,7 +151,7 @@ class InheritingState implements State {
@Override
public void makeAllBindingsToEagerSingletons(Injector injector) {
Map<Key<?>, Binding<?>> x = Maps.newLinkedHashMap();
Map<Key<?>, Binding<?>> x = new LinkedHashMap<>();
for (Map.Entry<Key<?>, Binding<?>> entry : this.explicitBindingsMutable.entrySet()) {
Key key = entry.getKey();
BindingImpl<?> binding = (BindingImpl<?>) entry.getValue();

@ -16,12 +16,12 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.internal.ErrorsException;
import org.elasticsearch.common.inject.spi.InjectionPoint;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
@ -49,7 +49,7 @@ class Initializer {
/**
* Maps instances that need injection to a source that registered them
*/
private final Map<Object, InjectableReference<?>> pendingInjection = Maps.newIdentityHashMap();
private final Map<Object, InjectableReference<?>> pendingInjection = new IdentityHashMap<>();
/**
* Registers an instance for member injection when that step is performed.

@ -17,7 +17,6 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import org.elasticsearch.common.Classes;
import org.elasticsearch.common.inject.internal.Annotations;
import org.elasticsearch.common.inject.internal.BindingImpl;
@ -50,6 +49,7 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -72,7 +72,7 @@ class InjectorImpl implements Injector, Lookups {
/**
* Just-in-time binding cache. Guarded by state.lock()
*/
Map<Key<?>, BindingImpl<?>> jitBindings = Maps.newHashMap();
Map<Key<?>, BindingImpl<?>> jitBindings = new HashMap<>();
Lookups lookups = new DeferredLookups(this);
@ -698,7 +698,7 @@ class InjectorImpl implements Injector, Lookups {
}
private static class BindingsMultimap {
final Map<TypeLiteral<?>, List<Binding<?>>> multimap = Maps.newHashMap();
final Map<TypeLiteral<?>, List<Binding<?>>> multimap = new HashMap<>();
<T> void put(TypeLiteral<T> type, Binding<T> binding) {
List<Binding<?>> bindingsForType = multimap.get(type);
@ -900,7 +900,7 @@ class InjectorImpl implements Injector, Lookups {
state.clearBlacklisted();
constructors = new ConstructorInjectorStore(this);
membersInjectorStore = new MembersInjectorStore(this, state.getTypeListenerBindings());
jitBindings = Maps.newHashMap();
jitBindings = new HashMap<>();
}
// ES_GUICE: make all registered bindings act as eager singletons

@ -18,7 +18,6 @@ package org.elasticsearch.common.inject.assistedinject;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.ConfigurationException;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.Injector;
@ -37,6 +36,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -241,7 +241,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
constructors.size(), factoryType, factoryMethods.length);
}
Map<ParameterListKey, AssistedConstructor> paramsToConstructor = Maps.newHashMap();
Map<ParameterListKey, AssistedConstructor> paramsToConstructor = new HashMap<>();
for (AssistedConstructor c : constructors) {
if (paramsToConstructor.containsKey(c.getAssistedParameters())) {
@ -250,7 +250,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
paramsToConstructor.put(c.getAssistedParameters(), c);
}
Map<Method, AssistedConstructor<?>> result = Maps.newHashMap();
Map<Method, AssistedConstructor<?>> result = new HashMap<>();
for (Method method : factoryMethods) {
if (!method.getReturnType().isAssignableFrom(implementationType.getRawType())) {
throw newConfigurationException("Return type of method %s is not assignable from %s",

@ -16,9 +16,9 @@
package org.elasticsearch.common.inject.internal;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.spi.Dependency;
import java.util.HashMap;
import java.util.Map;
/**
@ -29,7 +29,7 @@ import java.util.Map;
*/
public final class InternalContext {
private Map<Object, ConstructionContext<?>> constructionContexts = Maps.newHashMap();
private Map<Object, ConstructionContext<?>> constructionContexts = new HashMap<>();
private Dependency dependency;
@SuppressWarnings("unchecked")

@ -17,7 +17,6 @@
package org.elasticsearch.common.inject.internal;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.Key;
@ -28,11 +27,14 @@ import org.elasticsearch.common.inject.spi.PrivateElements;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.base.Preconditions.*;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
/**
* @author jessewilson@google.com (Jesse Wilson)
@ -93,7 +95,7 @@ public final class PrivateElementsImpl implements PrivateElements {
@Override
public Set<Key<?>> getExposedKeys() {
if (exposedKeysToSources == null) {
Map<Key<?>, Object> exposedKeysToSourcesMutable = Maps.newLinkedHashMap();
Map<Key<?>, Object> exposedKeysToSourcesMutable = new LinkedHashMap<>();
for (ExposureBuilder<?> exposureBuilder : exposureBuilders) {
exposedKeysToSourcesMutable.put(exposureBuilder.getKey(), exposureBuilder.getSource());
}

@ -17,7 +17,6 @@
package org.elasticsearch.common.inject.util;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Binder;
@ -36,6 +35,7 @@ import org.elasticsearch.common.inject.spi.ScopeBinding;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -178,7 +178,7 @@ public final class Modules {
// execute the original module, skipping all scopes and overridden keys. We only skip each
// overridden binding once so things still blow up if the module binds the same thing
// multiple times.
final Map<Scope, Object> scopeInstancesInUse = Maps.newHashMap();
final Map<Scope, Object> scopeInstancesInUse = new HashMap<>();
final List<ScopeBinding> scopeBindings = new ArrayList<>();
new ModuleWriter(binder()) {
@Override

@ -22,7 +22,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 com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Strings;
@ -118,7 +117,7 @@ public final class Settings implements ToXContent {
* The settings as a structured {@link java.util.Map}.
*/
public Map<String, Object> getAsStructuredMap() {
Map<String, Object> map = Maps.newHashMapWithExpectedSize(2);
Map<String, Object> map = new HashMap<>(2);
for (Map.Entry<String, String> entry : settings.entrySet()) {
processSetting(map, "", entry.getKey(), entry.getValue());
}
@ -148,7 +147,7 @@ public final class Settings implements ToXContent {
String rest = setting.substring(prefixLength + 1);
Object existingValue = map.get(prefix + key);
if (existingValue == null) {
Map<String, Object> newMap = Maps.newHashMapWithExpectedSize(2);
Map<String, Object> newMap = new HashMap<>(2);
processSetting(newMap, "", rest, value);
map.put(key, newMap);
} else {
@ -1181,7 +1180,7 @@ public final class Settings implements ToXContent {
return true;
}
};
for (Map.Entry<String, String> entry : Maps.newHashMap(map).entrySet()) {
for (Map.Entry<String, String> entry : new HashMap<>(map).entrySet()) {
String value = propertyPlaceholder.replacePlaceholders(entry.getValue(), placeholderResolver);
// if the values exists and has length, we should maintain it in the map
// otherwise, the replace process resolved into removing it
@ -1200,7 +1199,7 @@ public final class Settings implements ToXContent {
* If a setting doesn't start with the prefix, the builder appends the prefix to such setting.
*/
public Builder normalizePrefix(String prefix) {
Map<String, String> replacements = Maps.newHashMap();
Map<String, String> replacements = new HashMap<>();
Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
while(iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();

@ -25,11 +25,10 @@ import org.elasticsearch.common.io.FastStringReader;
import org.elasticsearch.common.io.stream.StreamInput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import static com.google.common.collect.Maps.newHashMap;
/**
* Settings loader that loads (parses) the settings in a properties format.
*/
@ -41,7 +40,7 @@ public class PropertiesSettingsLoader implements SettingsLoader {
FastStringReader reader = new FastStringReader(source);
try {
props.load(reader);
Map<String, String> result = newHashMap();
Map<String, String> result = new HashMap<>();
for (Map.Entry entry : props.entrySet()) {
result.put((String) entry.getKey(), (String) entry.getValue());
}
@ -57,7 +56,7 @@ public class PropertiesSettingsLoader implements SettingsLoader {
StreamInput stream = StreamInput.wrap(source);
try {
props.load(stream);
Map<String, String> result = newHashMap();
Map<String, String> result = new HashMap<>();
for (Map.Entry entry : props.entrySet()) {
result.put((String) entry.getKey(), (String) entry.getValue());
}

@ -23,11 +23,10 @@ import org.elasticsearch.common.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* Provides the ability to load settings (in the form of a simple Map) from
* the actual source content that represents them.
@ -37,7 +36,7 @@ public interface SettingsLoader {
static class Helper {
public static Map<String, String> loadNestedFromMap(@Nullable Map map) {
Map<String, String> settings = newHashMap();
Map<String, String> settings = new HashMap<>();
if (map == null) {
return settings;
}

@ -26,11 +26,10 @@ import org.elasticsearch.common.xcontent.XContentType;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* Settings loader that loads (parses) the settings in a xcontent format by flattening them
* into a map.
@ -55,7 +54,7 @@ public abstract class XContentSettingsLoader implements SettingsLoader {
public Map<String, String> load(XContentParser jp) throws IOException {
StringBuilder sb = new StringBuilder();
Map<String, String> settings = newHashMap();
Map<String, String> settings = new HashMap<>();
List<String> path = new ArrayList<>();
XContentParser.Token token = jp.nextToken();
if (token == null) {

@ -20,7 +20,6 @@
package org.elasticsearch.common.xcontent;
import com.google.common.base.Charsets;
import com.google.common.collect.Maps;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.bytes.BytesArray;
@ -35,6 +34,7 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -250,7 +250,7 @@ public class XContentHelper {
List mergedList = new ArrayList();
if (allListValuesAreMapsOfOne(defaultList) && allListValuesAreMapsOfOne(contentList)) {
// all are in the form of [ {"key1" : {}}, {"key2" : {}} ], merge based on keys
Map<String, Map<String, Object>> processed = Maps.newLinkedHashMap();
Map<String, Map<String, Object>> processed = new LinkedHashMap<>();
for (Object o : contentList) {
Map<String, Object> map = (Map<String, Object>) o;
Map.Entry<String, Object> entry = map.entrySet().iterator().next();

@ -19,13 +19,13 @@
package org.elasticsearch.common.xcontent.support;
import com.google.common.collect.Maps;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.unit.TimeValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -135,7 +135,7 @@ public class XContentMapValues {
}
public static Map<String, Object> filter(Map<String, Object> map, String[] includes, String[] excludes) {
Map<String, Object> result = Maps.newHashMap();
Map<String, Object> result = new HashMap<>();
filter(map, result, includes == null ? Strings.EMPTY_ARRAY : includes, excludes == null ? Strings.EMPTY_ARRAY : excludes, new StringBuilder());
return result;
}
@ -201,7 +201,7 @@ public class XContentMapValues {
if (entry.getValue() instanceof Map) {
Map<String, Object> innerInto = Maps.newHashMap();
Map<String, Object> innerInto = new HashMap<>();
// if we had an exact match, we want give deeper excludes their chance
filter((Map<String, Object>) entry.getValue(), innerInto, exactIncludeMatch ? Strings.EMPTY_ARRAY : includes, excludes, sb);
if (exactIncludeMatch || !innerInto.isEmpty()) {
@ -228,7 +228,7 @@ public class XContentMapValues {
for (Object o : from) {
if (o instanceof Map) {
Map<String, Object> innerInto = Maps.newHashMap();
Map<String, Object> innerInto = new HashMap<>();
filter((Map<String, Object>) o, innerInto, includes, excludes, sb);
if (!innerInto.isEmpty()) {
to.add(innerInto);

@ -19,7 +19,6 @@
package org.elasticsearch.discovery.zen.publish;
import com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterState;
@ -42,9 +41,17 @@ import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.discovery.zen.DiscoveryNodesProvider;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.*;
import org.elasticsearch.transport.BytesTransportRequest;
import org.elasticsearch.transport.EmptyTransportResponseHandler;
import org.elasticsearch.transport.TransportChannel;
import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequestHandler;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@ -103,8 +110,8 @@ public class PublishClusterStateAction extends AbstractComponent {
private void publish(final ClusterChangedEvent clusterChangedEvent, final Set<DiscoveryNode> nodesToPublishTo,
final BlockingClusterStatePublishResponseHandler publishResponseHandler) {
Map<Version, BytesReference> serializedStates = Maps.newHashMap();
Map<Version, BytesReference> serializedDiffs = Maps.newHashMap();
Map<Version, BytesReference> serializedStates = new HashMap<>();
Map<Version, BytesReference> serializedDiffs = new HashMap<>();
final ClusterState clusterState = clusterChangedEvent.state();
final ClusterState previousState = clusterChangedEvent.previousState();

@ -19,7 +19,7 @@
package org.elasticsearch.gateway;
import com.google.common.collect.*;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.component.AbstractComponent;
@ -30,6 +30,7 @@ import org.elasticsearch.env.NodeEnvironment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@ -109,7 +110,7 @@ public class DanglingIndicesState extends AbstractComponent {
return ImmutableMap.of();
}
Map<String, IndexMetaData> newIndices = Maps.newHashMap();
Map<String, IndexMetaData> newIndices = new HashMap<>();
for (String indexName : indices) {
if (metaData.hasIndex(indexName) == false && danglingIndices.containsKey(indexName) == false) {
try {

@ -19,7 +19,6 @@
package org.elasticsearch.gateway;
import com.google.common.collect.Maps;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.Nullable;
@ -34,6 +33,7 @@ import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.Index;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@ -61,16 +61,16 @@ public class MetaStateService extends AbstractComponent {
this.nodeEnv = nodeEnv;
this.format = XContentType.fromRestContentType(settings.get(FORMAT_SETTING, "smile"));
if (this.format == XContentType.SMILE) {
Map<String, String> params = Maps.newHashMap();
Map<String, String> params = new HashMap<>();
params.put("binary", "true");
formatParams = new ToXContent.MapParams(params);
Map<String, String> gatewayModeParams = Maps.newHashMap();
Map<String, String> gatewayModeParams = new HashMap<>();
gatewayModeParams.put("binary", "true");
gatewayModeParams.put(MetaData.CONTEXT_MODE_PARAM, MetaData.CONTEXT_MODE_GATEWAY);
gatewayModeFormatParams = new ToXContent.MapParams(gatewayModeParams);
} else {
formatParams = ToXContent.EMPTY_PARAMS;
Map<String, String> gatewayModeParams = Maps.newHashMap();
Map<String, String> gatewayModeParams = new HashMap<>();
gatewayModeParams.put(MetaData.CONTEXT_MODE_PARAM, MetaData.CONTEXT_MODE_GATEWAY);
gatewayModeFormatParams = new ToXContent.MapParams(gatewayModeParams);
}

@ -19,7 +19,6 @@
package org.elasticsearch.gateway;
import com.google.common.collect.Maps;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
@ -36,6 +35,7 @@ import org.elasticsearch.index.settings.IndexSettings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -193,7 +193,7 @@ public abstract class PrimaryShardAllocator extends AbstractComponent {
*/
NodesAndVersions buildNodesAndVersions(ShardRouting shard, boolean recoveryOnAnyNode, Set<String> ignoreNodes,
AsyncShardFetch.FetchResult<TransportNodesListGatewayStartedShards.NodeGatewayStartedShards> shardState) {
final Map<DiscoveryNode, Long> nodesWithVersion = Maps.newHashMap();
final Map<DiscoveryNode, Long> nodesWithVersion = new HashMap<>();
int numberOfAllocationsFound = 0;
long highestVersion = -1;
for (TransportNodesListGatewayStartedShards.NodeGatewayStartedShards nodeShardState : shardState.getData().values()) {

@ -22,7 +22,6 @@ package org.elasticsearch.index;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterators;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.ElasticsearchException;
@ -30,7 +29,12 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.*;
import org.elasticsearch.common.inject.CreationException;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.Injectors;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.env.ShardLock;
@ -47,7 +51,12 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.IndexQueryParserService;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.settings.IndexSettingsService;
import org.elasticsearch.index.shard.*;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.IndexShardModule;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.ShardNotFoundException;
import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.shard.StoreRecoveryService;
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.index.store.IndexStore;
import org.elasticsearch.index.store.Store;
@ -69,7 +78,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.google.common.collect.Maps.newHashMap;
import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder;
/**
@ -411,7 +419,7 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
return;
}
logger.debug("[{}] closing... (reason: [{}])", shardId, reason);
HashMap<Integer, IndexShardInjectorPair> tmpShardsMap = newHashMap(shards);
HashMap<Integer, IndexShardInjectorPair> tmpShardsMap = new HashMap<>(shards);
IndexShardInjectorPair indexShardInjectorPair = tmpShardsMap.remove(shardId);
indexShard = indexShardInjectorPair.getIndexShard();
shardInjector = indexShardInjectorPair.getInjector();

@ -19,7 +19,6 @@
package org.elasticsearch.index.analysis;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Scopes;
import org.elasticsearch.common.inject.assistedinject.FactoryProvider;
@ -29,6 +28,7 @@ import org.elasticsearch.index.analysis.compound.DictionaryCompoundWordTokenFilt
import org.elasticsearch.index.analysis.compound.HyphenationCompoundWordTokenFilterFactory;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Objects;
@ -45,7 +45,7 @@ public class AnalysisModule extends AbstractModule {
}
public static class CharFiltersBindings {
private final Map<String, Class<? extends CharFilterFactory>> charFilters = Maps.newHashMap();
private final Map<String, Class<? extends CharFilterFactory>> charFilters = new HashMap<>();
public CharFiltersBindings() {
}
@ -60,7 +60,7 @@ public class AnalysisModule extends AbstractModule {
}
public static class TokenFiltersBindings {
private final Map<String, Class<? extends TokenFilterFactory>> tokenFilters = Maps.newHashMap();
private final Map<String, Class<? extends TokenFilterFactory>> tokenFilters = new HashMap<>();
public TokenFiltersBindings() {
}
@ -75,7 +75,7 @@ public class AnalysisModule extends AbstractModule {
}
public static class TokenizersBindings {
private final Map<String, Class<? extends TokenizerFactory>> tokenizers = Maps.newHashMap();
private final Map<String, Class<? extends TokenizerFactory>> tokenizers = new HashMap<>();
public TokenizersBindings() {
}
@ -90,7 +90,7 @@ public class AnalysisModule extends AbstractModule {
}
public static class AnalyzersBindings {
private final Map<String, Class<? extends AnalyzerProvider>> analyzers = Maps.newHashMap();
private final Map<String, Class<? extends AnalyzerProvider>> analyzers = new HashMap<>();
public AnalyzersBindings() {
}
@ -107,10 +107,10 @@ public class AnalysisModule extends AbstractModule {
private final LinkedList<AnalysisBinderProcessor> processors = new LinkedList<>();
private final Map<String, Class<? extends CharFilterFactory>> charFilters = Maps.newHashMap();
private final Map<String, Class<? extends TokenFilterFactory>> tokenFilters = Maps.newHashMap();
private final Map<String, Class<? extends TokenizerFactory>> tokenizers = Maps.newHashMap();
private final Map<String, Class<? extends AnalyzerProvider>> analyzers = Maps.newHashMap();
private final Map<String, Class<? extends CharFilterFactory>> charFilters = new HashMap<>();
private final Map<String, Class<? extends TokenFilterFactory>> tokenFilters = new HashMap<>();
private final Map<String, Class<? extends TokenizerFactory>> tokenizers = new HashMap<>();
private final Map<String, Class<? extends AnalyzerProvider>> analyzers = new HashMap<>();
public AnalysisModule(Settings settings, IndicesAnalysisService indicesAnalysisService) {
Objects.requireNonNull(indicesAnalysisService);

@ -34,10 +34,9 @@ import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import java.io.Closeable;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
*
*/
@ -66,7 +65,7 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable
@Nullable Map<String, TokenFilterFactoryFactory> tokenFilterFactoryFactories) {
super(index, indexSettings);
Settings defaultSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.indexCreated(indexSettings)).build();
Map<String, TokenizerFactory> tokenizers = newHashMap();
Map<String, TokenizerFactory> tokenizers = new HashMap<>();
if (tokenizerFactoryFactories != null) {
Map<String, Settings> tokenizersSettings = indexSettings.getGroups("index.analysis.tokenizer");
for (Map.Entry<String, TokenizerFactoryFactory> entry : tokenizerFactoryFactories.entrySet()) {
@ -101,7 +100,7 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable
this.tokenizers = ImmutableMap.copyOf(tokenizers);
Map<String, CharFilterFactory> charFilters = newHashMap();
Map<String, CharFilterFactory> charFilters = new HashMap<>();
if (charFilterFactoryFactories != null) {
Map<String, Settings> charFiltersSettings = indexSettings.getGroups("index.analysis.char_filter");
for (Map.Entry<String, CharFilterFactoryFactory> entry : charFilterFactoryFactories.entrySet()) {
@ -136,7 +135,7 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable
this.charFilters = ImmutableMap.copyOf(charFilters);
Map<String, TokenFilterFactory> tokenFilters = newHashMap();
Map<String, TokenFilterFactory> tokenFilters = new HashMap<>();
if (tokenFilterFactoryFactories != null) {
Map<String, Settings> tokenFiltersSettings = indexSettings.getGroups("index.analysis.filter");
for (Map.Entry<String, TokenFilterFactoryFactory> entry : tokenFilterFactoryFactories.entrySet()) {
@ -171,7 +170,7 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable
}
this.tokenFilters = ImmutableMap.copyOf(tokenFilters);
Map<String, AnalyzerProvider> analyzerProviders = newHashMap();
Map<String, AnalyzerProvider> analyzerProviders = new HashMap<>();
if (analyzerFactoryFactories != null) {
Map<String, Settings> analyzersSettings = indexSettings.getGroups("index.analysis.analyzer");
for (Map.Entry<String, AnalyzerProviderFactory> entry : analyzerFactoryFactories.entrySet()) {
@ -214,7 +213,7 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable
analyzerProviders.put("default_search_quoted", analyzerProviders.get("default_search"));
}
Map<String, NamedAnalyzer> analyzers = newHashMap();
Map<String, NamedAnalyzer> analyzers = new HashMap<>();
for (AnalyzerProvider analyzerFactory : analyzerProviders.values()) {
/*
* Lucene defaults positionIncrementGap to 0 in all analyzers but

@ -20,11 +20,11 @@
package org.elasticsearch.index.analysis;
import com.carrotsearch.hppc.IntObjectHashMap;
import com.google.common.collect.Maps;
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
import org.joda.time.format.DateTimeFormatter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
@ -32,7 +32,7 @@ import java.util.Map;
*/
public class NumericDateAnalyzer extends NumericAnalyzer<NumericDateTokenizer> {
private static final Map<String, IntObjectHashMap<NamedAnalyzer>> globalAnalyzers = Maps.newHashMap();
private static final Map<String, IntObjectHashMap<NamedAnalyzer>> globalAnalyzers = new HashMap<>();
public static synchronized NamedAnalyzer buildNamedAnalyzer(FormatDateTimeFormatter formatter, int precisionStep) {
IntObjectHashMap<NamedAnalyzer> precisionMap = globalAnalyzers.get(formatter.format());

@ -20,8 +20,6 @@
package org.elasticsearch.index.fielddata;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.lucene.util.Accountable;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
@ -31,7 +29,17 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.fielddata.plain.*;
import org.elasticsearch.index.fielddata.plain.BytesBinaryDVIndexFieldData;
import org.elasticsearch.index.fielddata.plain.DisabledIndexFieldData;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
import org.elasticsearch.index.fielddata.plain.DoubleArrayIndexFieldData;
import org.elasticsearch.index.fielddata.plain.FloatArrayIndexFieldData;
import org.elasticsearch.index.fielddata.plain.GeoPointBinaryDVIndexFieldData;
import org.elasticsearch.index.fielddata.plain.GeoPointDoubleArrayIndexFieldData;
import org.elasticsearch.index.fielddata.plain.IndexIndexFieldData;
import org.elasticsearch.index.fielddata.plain.PackedArrayIndexFieldData;
import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData;
import org.elasticsearch.index.fielddata.plain.ParentChildIndexFieldData;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.core.BooleanFieldMapper;
@ -44,6 +52,7 @@ import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -140,7 +149,7 @@ public class IndexFieldDataService extends AbstractIndexComponent {
private final IndicesFieldDataCache indicesFieldDataCache;
// the below map needs to be modified under a lock
private final Map<String, IndexFieldDataCache> fieldDataCaches = Maps.newHashMap();
private final Map<String, IndexFieldDataCache> fieldDataCaches = new HashMap<>();
private final MapperService mapperService;
private static final IndexFieldDataCache.Listener DEFAULT_NOOP_LISTENER = new IndexFieldDataCache.Listener() {
@Override

@ -20,7 +20,6 @@ package org.elasticsearch.index.fieldvisitor;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.util.BytesRef;
@ -41,13 +40,12 @@ import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Maps.newHashMap;
/**
* Base {@link StoredFieldsVisitor} that retrieves all non-redundant metadata.
*/
@ -209,7 +207,7 @@ public class FieldsVisitor extends StoredFieldVisitor {
void addValue(String name, Object value) {
if (fieldsValues == null) {
fieldsValues = newHashMap();
fieldsValues = new HashMap<>();
}
List<Object> values = fieldsValues.get(name);

@ -35,11 +35,11 @@ import org.elasticsearch.search.lookup.SourceLookup;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMapWithExpectedSize;
import static org.elasticsearch.index.get.GetField.readGetField;
/**
@ -288,7 +288,7 @@ public class GetResult implements Streamable, Iterable<GetField>, ToXContent {
if (size == 0) {
fields = ImmutableMap.of();
} else {
fields = newHashMapWithExpectedSize(size);
fields = new HashMap<>(size);
for (int i = 0; i < size; i++) {
GetField field = readGetField(in);
fields.put(field.getName(), field);

@ -20,7 +20,6 @@
package org.elasticsearch.index.get;
import com.google.common.collect.Sets;
import org.apache.lucene.index.Term;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.Nullable;
@ -37,8 +36,16 @@ import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.fieldvisitor.CustomFieldsVisitor;
import org.elasticsearch.index.fieldvisitor.FieldsVisitor;
import org.elasticsearch.index.mapper.*;
import org.elasticsearch.index.mapper.internal.*;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.Uid;
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.UidFieldMapper;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.translog.Translog;
@ -56,8 +63,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import static com.google.common.collect.Maps.newHashMapWithExpectedSize;
/**
*/
public final class ShardGetService extends AbstractIndexShardComponent {
@ -253,7 +258,7 @@ public final class ShardGetService extends AbstractIndexShardComponent {
}
if (value != null) {
if (fields == null) {
fields = newHashMapWithExpectedSize(2);
fields = new HashMap<>(2);
}
if (value instanceof List) {
fields.put(field, new GetField(field, (List) value));
@ -378,7 +383,7 @@ public final class ShardGetService extends AbstractIndexShardComponent {
if (value != null) {
if (fields == null) {
fields = newHashMapWithExpectedSize(2);
fields = new HashMap<>(2);
}
if (value instanceof List) {
fields.put(field, new GetField(field, (List) value));

@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.lucene.analysis.Analyzer;
import org.elasticsearch.common.collect.CopyOnWriteHashMap;
@ -29,6 +28,7 @@ import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.index.analysis.AnalysisService;
import org.elasticsearch.index.analysis.FieldNameAnalyzer;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@ -68,19 +68,19 @@ public final class DocumentFieldMappers implements Iterable<FieldMapper> {
FieldNameAnalyzer indexAnalyzer = this.indexAnalyzer.copyAndAddAll(Collections2.transform(newMappers, new Function<FieldMapper, Map.Entry<String, Analyzer>>() {
@Override
public Map.Entry<String, Analyzer> apply(FieldMapper input) {
return Maps.immutableEntry(input.fieldType().names().indexName(), (Analyzer)input.fieldType().indexAnalyzer());
return new AbstractMap.SimpleImmutableEntry<>(input.fieldType().names().indexName(), (Analyzer)input.fieldType().indexAnalyzer());
}
}));
FieldNameAnalyzer searchAnalyzer = this.searchAnalyzer.copyAndAddAll(Collections2.transform(newMappers, new Function<FieldMapper, Map.Entry<String, Analyzer>>() {
@Override
public Map.Entry<String, Analyzer> apply(FieldMapper input) {
return Maps.immutableEntry(input.fieldType().names().indexName(), (Analyzer)input.fieldType().searchAnalyzer());
return new AbstractMap.SimpleImmutableEntry<>(input.fieldType().names().indexName(), (Analyzer)input.fieldType().searchAnalyzer());
}
}));
FieldNameAnalyzer searchQuoteAnalyzer = this.searchQuoteAnalyzer.copyAndAddAll(Collections2.transform(newMappers, new Function<FieldMapper, Map.Entry<String, Analyzer>>() {
@Override
public Map.Entry<String, Analyzer> apply(FieldMapper input) {
return Maps.immutableEntry(input.fieldType().names().indexName(), (Analyzer)input.fieldType().searchQuoteAnalyzer());
return new AbstractMap.SimpleImmutableEntry<>(input.fieldType().names().indexName(), (Analyzer)input.fieldType().searchQuoteAnalyzer());
}
}));
return new DocumentFieldMappers(map, indexAnalyzer, searchAnalyzer, searchQuoteAnalyzer);

@ -19,11 +19,8 @@
package org.elasticsearch.index.mapper;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
@ -33,7 +30,6 @@ import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.text.StringAndBytesText;
@ -67,6 +63,7 @@ import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@ -163,7 +160,7 @@ public class DocumentMapper implements ToXContent {
private volatile DocumentFieldMappers fieldMappers;
private volatile ImmutableMap<String, ObjectMapper> objectMappers = ImmutableMap.of();
private volatile Map<String, ObjectMapper> objectMappers = Collections.emptyMap();
private boolean hasNestedObjects = false;
@ -206,12 +203,16 @@ public class DocumentMapper implements ToXContent {
MapperUtils.collect(this.mapping.root, newObjectMappers, newFieldMappers);
this.fieldMappers = new DocumentFieldMappers(docMapperParser.analysisService).copyAndAllAll(newFieldMappers);
this.objectMappers = Maps.uniqueIndex(newObjectMappers, new Function<ObjectMapper, String>() {
@Override
public String apply(ObjectMapper mapper) {
return mapper.fullPath();
Map<String, ObjectMapper> builder = new HashMap<>();
for (ObjectMapper objectMapper : newObjectMappers) {
ObjectMapper previous = builder.put(objectMapper.fullPath(), objectMapper);
if (previous != null) {
throw new IllegalStateException("duplicate key " + objectMapper.fullPath() + " encountered");
}
});
}
this.objectMappers = Collections.unmodifiableMap(builder);
for (ObjectMapper objectMapper : newObjectMappers) {
if (objectMapper.nested().isNested()) {
hasNestedObjects = true;
@ -306,7 +307,7 @@ public class DocumentMapper implements ToXContent {
return this.fieldMappers;
}
public ImmutableMap<String, ObjectMapper> objectMappers() {
public Map<String, ObjectMapper> objectMappers() {
return this.objectMappers;
}
@ -390,14 +391,14 @@ public class DocumentMapper implements ToXContent {
mapperService.checkNewMappersCompatibility(objectMappers, fieldMappers, updateAllTypes);
// update mappers for this document type
MapBuilder<String, ObjectMapper> builder = MapBuilder.newMapBuilder(this.objectMappers);
Map<String, ObjectMapper> builder = new HashMap<>(this.objectMappers);
for (ObjectMapper objectMapper : objectMappers) {
builder.put(objectMapper.fullPath(), objectMapper);
if (objectMapper.nested().isNested()) {
hasNestedObjects = true;
}
}
this.objectMappers = builder.immutableMap();
this.objectMappers = Collections.unmodifiableMap(builder);
this.fieldMappers = this.fieldMappers.copyAndAllAll(fieldMappers);
// finally update for the entire index

@ -21,8 +21,6 @@ package org.elasticsearch.index.mapper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseFieldMatcher;
@ -38,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;
@ -51,6 +72,7 @@ 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;
@ -168,7 +190,7 @@ public class DocumentMapperParser {
mapping = t.v2();
}
if (mapping == null) {
mapping = Maps.newHashMap();
mapping = new HashMap<>();
}
return parse(type, mapping, defaultSource);
}
@ -187,7 +209,7 @@ public class DocumentMapperParser {
mapping = t.v2();
}
if (mapping == null) {
mapping = Maps.newHashMap();
mapping = new HashMap<>();
}
return parse(type, mapping, defaultSource);
}

@ -18,7 +18,6 @@
*/
package org.elasticsearch.index.mapper.core;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
@ -60,6 +59,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import static org.elasticsearch.index.mapper.MapperBuilders.completionField;
import static org.elasticsearch.index.mapper.core.TypeParsers.parseMultiField;
@ -372,7 +372,7 @@ public class CompletionFieldMapper extends FieldMapper {
throw new IllegalArgumentException("Unknown field name[" + currentFieldName + "], must be one of " + ALLOWED_CONTENT_FIELD_NAMES);
}
} else if (Fields.CONTEXT.equals(currentFieldName)) {
SortedMap<String, ContextConfig> configs = Maps.newTreeMap();
SortedMap<String, ContextConfig> configs = new TreeMap<>();
if (token == Token.START_OBJECT) {
while ((token = parser.nextToken()) != Token.END_OBJECT) {
@ -385,7 +385,7 @@ public class CompletionFieldMapper extends FieldMapper {
configs.put(name, mapping.parseContext(context, parser));
}
}
contextConfig = Maps.newTreeMap();
contextConfig = new TreeMap<>();
for (ContextMapping mapping : fieldType().getContextMapping().values()) {
ContextConfig config = configs.get(mapping.name());
contextConfig.put(mapping.name(), config==null ? mapping.defaultConfig() : config);
@ -443,7 +443,7 @@ public class CompletionFieldMapper extends FieldMapper {
}
if(contextConfig == null) {
contextConfig = Maps.newTreeMap();
contextConfig = new TreeMap<>();
for (ContextMapping mapping : fieldType().getContextMapping().values()) {
contextConfig.put(mapping.name(), mapping.defaultConfig());
}

@ -19,13 +19,13 @@
package org.elasticsearch.index.mapper.object;
import com.google.common.collect.Maps;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.index.mapper.ContentPath;
import org.elasticsearch.index.mapper.MapperParsingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@ -168,7 +168,7 @@ public class DynamicTemplate {
}
private Map<String, Object> processMap(Map<String, Object> map, String name, String dynamicType) {
Map<String, Object> processedMap = Maps.newHashMap();
Map<String, Object> processedMap = new HashMap<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey().replace("{name}", name).replace("{dynamic_type}", dynamicType).replace("{dynamicType}", dynamicType);
Object value = entry.getValue();

@ -18,8 +18,6 @@
*/
package org.elasticsearch.index.percolator;
import com.google.common.collect.Maps;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.Query;
@ -37,13 +35,14 @@ import org.elasticsearch.index.mapper.Uid;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
*/
final class QueriesLoaderCollector extends SimpleCollector {
private final Map<BytesRef, Query> queries = Maps.newHashMap();
private final Map<BytesRef, Query> queries = new HashMap<>();
private final FieldsVisitor fieldsVisitor = new FieldsVisitor(true);
private final PercolatorQueriesRegistry percolator;
private final IndexFieldData<?> uidFieldData;

@ -19,8 +19,6 @@
package org.elasticsearch.index.query;
import com.google.common.collect.Maps;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.inject.Inject;
@ -32,6 +30,7 @@ import org.elasticsearch.index.search.MatchQuery;
import org.elasticsearch.index.search.MultiMatchQuery;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
@ -62,7 +61,7 @@ public class MultiMatchQueryParser implements QueryParser {
MultiMatchQueryBuilder.Type type = null;
MultiMatchQuery multiMatchQuery = new MultiMatchQuery(parseContext);
String minimumShouldMatch = null;
Map<String, Float> fieldNameWithBoosts = Maps.newHashMap();
Map<String, Float> fieldNameWithBoosts = new HashMap<>();
String queryName = null;
XContentParser.Token token;
String currentFieldName = null;

@ -20,8 +20,6 @@
package org.elasticsearch.index.query;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.queryparser.classic.MapperQueryParser;
import org.apache.lucene.queryparser.classic.QueryParserSettings;
@ -90,7 +88,7 @@ public class QueryParseContext {
private final IndexQueryParserService indexQueryParser;
private final Map<String, Query> namedQueries = Maps.newHashMap();
private final Map<String, Query> namedQueries = new HashMap<>();
private final MapperQueryParser queryParser = new MapperQueryParser(this);

@ -38,11 +38,10 @@ import org.elasticsearch.script.SearchScript;
import org.elasticsearch.search.lookup.SearchLookup;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import static com.google.common.collect.Maps.newHashMap;
/**
*
*/
@ -99,7 +98,7 @@ public class ScriptQueryParser implements QueryParser {
ScriptParameterValue scriptValue = scriptParameterParser.getDefaultScriptParameterValue();
if (scriptValue != null) {
if (params == null) {
params = newHashMap();
params = new HashMap<>();
}
script = new Script(scriptValue.script(), scriptValue.scriptType(), scriptParameterParser.lang(), params);
}

@ -21,7 +21,6 @@
package org.elasticsearch.index.query.functionscore.script;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.lucene.search.function.ScoreFunction;
import org.elasticsearch.common.lucene.search.function.ScriptScoreFunction;
@ -37,10 +36,9 @@ import org.elasticsearch.script.ScriptParameterParser.ScriptParameterValue;
import org.elasticsearch.script.SearchScript;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
*
*/
@ -86,7 +84,7 @@ public class ScriptScoreFunctionParser implements ScoreFunctionParser {
ScriptParameterValue scriptValue = scriptParameterParser.getDefaultScriptParameterValue();
if (scriptValue != null) {
if (vars == null) {
vars = newHashMap();
vars = new HashMap<>();
}
script = new Script(scriptValue.script(), scriptValue.scriptType(), scriptParameterParser.lang(), vars);
}

@ -19,13 +19,13 @@
package org.elasticsearch.index.similarity;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Scopes;
import org.elasticsearch.common.inject.assistedinject.FactoryProvider;
import org.elasticsearch.common.inject.multibindings.MapBinder;
import org.elasticsearch.common.settings.Settings;
import java.util.HashMap;
import java.util.Map;
/**
@ -42,7 +42,7 @@ public class SimilarityModule extends AbstractModule {
public static final String SIMILARITY_SETTINGS_PREFIX = "index.similarity";
private final Settings settings;
private final Map<String, Class<? extends SimilarityProvider>> similarities = Maps.newHashMap();
private final Map<String, Class<? extends SimilarityProvider>> similarities = new HashMap<>();
public SimilarityModule(Settings settings) {
this.settings = settings;

@ -33,12 +33,11 @@ import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.F
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* Contains information about all snapshot for the given shard in repository
* <p/>
@ -56,9 +55,9 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
public BlobStoreIndexShardSnapshots(List<SnapshotFiles> shardSnapshots) {
this.shardSnapshots = Collections.unmodifiableList(new ArrayList<>(shardSnapshots));
// Map between blob names and file info
Map<String, FileInfo> newFiles = newHashMap();
Map<String, FileInfo> newFiles = new HashMap<>();
// Map between original physical names and file info
Map<String, List<FileInfo>> physicalFiles = newHashMap();
Map<String, List<FileInfo>> physicalFiles = new HashMap<>();
for (SnapshotFiles snapshot : shardSnapshots) {
// First we build map between filenames in the repo and their original file info
// this map will be used in the next loop
@ -89,7 +88,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
private BlobStoreIndexShardSnapshots(ImmutableMap<String, FileInfo> files, List<SnapshotFiles> shardSnapshots) {
this.shardSnapshots = shardSnapshots;
this.files = files;
Map<String, List<FileInfo>> physicalFiles = newHashMap();
Map<String, List<FileInfo>> physicalFiles = new HashMap<>();
for (SnapshotFiles snapshot : shardSnapshots) {
for (FileInfo fileInfo : snapshot.indexFiles()) {
List<FileInfo> physicalFileList = physicalFiles.get(fileInfo.physicalName());
@ -237,7 +236,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
if (token == null) { // New parser
token = parser.nextToken();
}
Map<String, List<String>> snapshotsMap = newHashMap();
Map<String, List<String>> snapshotsMap = new HashMap<>();
ImmutableMap.Builder<String, FileInfo> filesBuilder = ImmutableMap.builder();
if (token == XContentParser.Token.START_OBJECT) {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {

@ -20,11 +20,10 @@ package org.elasticsearch.index.snapshots.blobstore;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* Contains a list of files participating in a snapshot
*/
@ -69,7 +68,7 @@ public class SnapshotFiles {
*/
public FileInfo findPhysicalIndexFile(String physicalName) {
if (physicalFiles == null) {
Map<String, FileInfo> files = newHashMap();
Map<String, FileInfo> files = new HashMap<>();
for(FileInfo fileInfo : indexFiles) {
files.put(fileInfo.physicalName(), fileInfo);
}

@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.CollectionUtil;
import org.apache.lucene.util.IOUtils;
@ -99,7 +98,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static com.google.common.collect.Maps.newHashMap;
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;
@ -246,7 +244,7 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
}
}
Map<Index, List<IndexShardStats>> statsByShard = Maps.newHashMap();
Map<Index, List<IndexShardStats>> statsByShard = new HashMap<>();
for (IndexServiceInjectorPair value : indices.values()) {
IndexService indexService = value.getIndexService();
for (IndexShard indexShard : indexService) {
@ -395,7 +393,7 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
}
logger.debug("[{}] closing ... (reason [{}])", index, reason);
Map<String, IndexServiceInjectorPair> tmpMap = newHashMap(indices);
Map<String, IndexServiceInjectorPair> tmpMap = new HashMap<>(indices);
IndexServiceInjectorPair remove = tmpMap.remove(index);
indexService = remove.getIndexService();
indexInjector = remove.getInjector();

@ -19,7 +19,6 @@
package org.elasticsearch.indices;
import com.google.common.collect.Maps;
import org.elasticsearch.action.admin.indices.stats.CommonStats;
import org.elasticsearch.action.admin.indices.stats.IndexShardStats;
import org.elasticsearch.action.admin.indices.stats.ShardStats;
@ -50,6 +49,7 @@ import org.elasticsearch.search.suggest.completion.CompletionStats;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -170,7 +170,7 @@ public class NodeIndicesStats implements Streamable, ToXContent {
stats = CommonStats.readCommonStats(in);
if (in.readBoolean()) {
int entries = in.readVInt();
statsByShard = Maps.newHashMap();
statsByShard = new HashMap<>();
for (int i = 0; i < entries; i++) {
Index index = Index.readIndexName(in);
int indexShardListSize = in.readVInt();
@ -241,7 +241,7 @@ public class NodeIndicesStats implements Streamable, ToXContent {
}
private Map<Index, CommonStats> createStatsByIndex() {
Map<Index, CommonStats> statsMap = Maps.newHashMap();
Map<Index, CommonStats> statsMap = new HashMap<>();
for (Map.Entry<Index, List<IndexShardStats>> entry : statsByShard.entrySet()) {
if (!statsMap.containsKey(entry.getKey())) {
statsMap.put(entry.getKey(), new CommonStats());

@ -18,10 +18,10 @@
*/
package org.elasticsearch.indices.analysis;
import com.google.common.collect.Maps;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import java.util.HashMap;
import java.util.Map;
/**
@ -81,7 +81,7 @@ public class PreBuiltCacheFactory {
*/
private static class PreBuiltCacheStrategyElasticsearch<T> implements PreBuiltCache<T> {
Map<Version, T> mapModel = Maps.newHashMapWithExpectedSize(2);
Map<Version, T> mapModel = new HashMap<>(2);
@Override
public T get(Version version) {
@ -99,7 +99,7 @@ public class PreBuiltCacheFactory {
*/
private static class PreBuiltCacheStrategyLucene<T> implements PreBuiltCache<T> {
private Map<org.apache.lucene.util.Version, T> mapModel = Maps.newHashMapWithExpectedSize(2);
private Map<org.apache.lucene.util.Version, T> mapModel = new HashMap<>(2);
@Override
public T get(Version version) {

@ -20,13 +20,12 @@
package org.elasticsearch.indices.query;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryParser;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@ -37,7 +36,7 @@ public class IndicesQueriesRegistry extends AbstractComponent {
@Inject
public IndicesQueriesRegistry(Settings settings, Set<QueryParser> injectedQueryParsers) {
super(settings);
Map<String, QueryParser> queryParsers = Maps.newHashMap();
Map<String, QueryParser> queryParsers = new HashMap<>();
for (QueryParser queryParser : injectedQueryParsers) {
for (String name : queryParser.names()) {
queryParsers.put(name, queryParser);

@ -19,18 +19,14 @@
package org.elasticsearch.indices.recovery;
import com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.index.store.StoreFileMetaData;
import org.elasticsearch.transport.TransportRequest;
import java.io.IOException;
import java.util.Map;
/**
*

@ -21,9 +21,12 @@ package org.elasticsearch.repositories;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.cluster.*;
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateListener;
import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest;
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
import org.elasticsearch.cluster.metadata.MetaData;
@ -43,10 +46,10 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS;
/**
@ -265,7 +268,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta
logger.trace("processing new index repositories for state version [{}]", event.state().version());
Map<String, RepositoryHolder> survivors = newHashMap();
Map<String, RepositoryHolder> survivors = new HashMap<>();
// First, remove repositories that are no longer there
for (Map.Entry<String, RepositoryHolder> entry : repositories.entrySet()) {
if (newMetaData == null || newMetaData.repository(entry.getKey()) == null) {
@ -370,7 +373,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta
// Closing previous version
closeRepository(repositoryMetaData.name(), previous);
}
Map<String, RepositoryHolder> newRepositories = newHashMap(repositories);
Map<String, RepositoryHolder> newRepositories = new HashMap<>(repositories);
newRepositories.put(repositoryMetaData.name(), holder);
repositories = ImmutableMap.copyOf(newRepositories);
return true;

@ -18,14 +18,17 @@
*/
package org.elasticsearch.repositories.blobstore;
import com.google.common.collect.Maps;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.blobstore.BlobContainer;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.common.xcontent.FromXContentBuilder;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@ -44,7 +47,7 @@ public abstract class BlobStoreFormat<T extends ToXContent> {
protected static final ToXContent.Params SNAPSHOT_ONLY_FORMAT_PARAMS;
static {
Map<String, String> snapshotOnlyParams = Maps.newHashMap();
Map<String, String> snapshotOnlyParams = new HashMap<>();
// when metadata is serialized certain elements of the metadata shouldn't be included into snapshot
// exclusion of these elements is done by setting MetaData.CONTEXT_MODE_PARAM to MetaData.CONTEXT_MODE_SNAPSHOT
snapshotOnlyParams.put(MetaData.CONTEXT_MODE_PARAM, MetaData.CONTEXT_MODE_SNAPSHOT);

@ -18,7 +18,6 @@
*/
package org.elasticsearch.rest.action.admin.indices.template.get;
import com.google.common.collect.Maps;
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesRequest;
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
import org.elasticsearch.client.Client;
@ -28,9 +27,16 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.*;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.support.RestBuilderListener;
import java.util.HashMap;
import java.util.Map;
import static org.elasticsearch.rest.RestRequest.Method.GET;
@ -65,7 +71,7 @@ public class RestGetIndexTemplateAction extends BaseRestHandler {
public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse, XContentBuilder builder) throws Exception {
boolean templateExists = getIndexTemplatesResponse.getIndexTemplates().size() > 0;
Map<String, String> paramsMap = Maps.newHashMap();
Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("reduce_mappings", "true");
ToXContent.Params params = new ToXContent.DelegatingMapParams(paramsMap, request);

@ -19,7 +19,6 @@
package org.elasticsearch.rest.action.cat;
import com.google.common.collect.Maps;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
@ -36,14 +35,21 @@ import org.elasticsearch.common.Table;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.rest.*;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.action.support.RestActionListener;
import org.elasticsearch.rest.action.support.RestResponseListener;
import org.elasticsearch.rest.action.support.RestTable;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolStats;
import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import static org.elasticsearch.rest.RestRequest.Method.GET;
@ -95,11 +101,11 @@ public class RestThreadPoolAction extends AbstractCatAction {
private final static Map<String, String> THREAD_POOL_TO_ALIAS;
static {
ALIAS_TO_THREAD_POOL = Maps.newHashMapWithExpectedSize(SUPPORTED_NAMES.length);
ALIAS_TO_THREAD_POOL = new HashMap<>(SUPPORTED_NAMES.length);
for (String supportedThreadPool : SUPPORTED_NAMES) {
ALIAS_TO_THREAD_POOL.put(supportedThreadPool.substring(0, 3), supportedThreadPool);
}
THREAD_POOL_TO_ALIAS = Maps.newHashMapWithExpectedSize(SUPPORTED_NAMES.length);
THREAD_POOL_TO_ALIAS = new HashMap<>(SUPPORTED_NAMES.length);
for (int i = 0; i < SUPPORTED_NAMES.length; i++) {
THREAD_POOL_TO_ALIAS.put(SUPPORTED_NAMES[i], SUPPORTED_ALIASES[i]);
}

@ -22,8 +22,8 @@ package org.elasticsearch.script;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import java.util.HashMap;
import java.util.Map;
/**
@ -37,7 +37,7 @@ public final class ScriptContextRegistry {
private final ImmutableMap<String, ScriptContext> scriptContexts;
ScriptContextRegistry(Iterable<ScriptContext.Plugin> customScriptContexts) {
Map<String, ScriptContext> scriptContexts = Maps.newHashMap();
Map<String, ScriptContext> scriptContexts = new HashMap<>();
for (ScriptContext.Standard scriptContext : ScriptContext.Standard.values()) {
scriptContexts.put(scriptContext.getKey(), scriptContext);
}

@ -20,7 +20,6 @@
package org.elasticsearch.script;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.script.ScriptService.ScriptType;
@ -44,13 +43,13 @@ public class ScriptModes {
ScriptModes(Map<String, ScriptEngineService> scriptEngines, ScriptContextRegistry scriptContextRegistry, Settings settings) {
//filter out the native engine as we don't want to apply fine grained settings to it.
//native scripts are always on as they are static by definition.
Map<String, ScriptEngineService> filteredEngines = Maps.newHashMap(scriptEngines);
Map<String, ScriptEngineService> filteredEngines = new HashMap<>(scriptEngines);
filteredEngines.remove(NativeScriptEngineService.NAME);
this.scriptModes = buildScriptModeSettingsMap(settings, filteredEngines, scriptContextRegistry);
}
private static ImmutableMap<String, ScriptMode> buildScriptModeSettingsMap(Settings settings, Map<String, ScriptEngineService> scriptEngines, ScriptContextRegistry scriptContextRegistry) {
HashMap<String, ScriptMode> scriptModesMap = Maps.newHashMap();
HashMap<String, ScriptMode> scriptModesMap = new HashMap<>();
//file scripts are enabled by default, for any language
addGlobalScriptTypeModes(scriptEngines.keySet(), scriptContextRegistry, ScriptType.FILE, ScriptMode.ON, scriptModesMap);

@ -19,7 +19,6 @@
package org.elasticsearch.script;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.multibindings.MapBinder;
import org.elasticsearch.common.inject.multibindings.Multibinder;
@ -30,6 +29,7 @@ import org.elasticsearch.script.groovy.GroovyScriptEngineService;
import org.elasticsearch.script.mustache.MustacheScriptEngineService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -43,7 +43,7 @@ public class ScriptModule extends AbstractModule {
private final List<Class<? extends ScriptEngineService>> scriptEngines = new ArrayList<>();
private final Map<String, Class<? extends NativeScriptFactory>> scripts = Maps.newHashMap();
private final Map<String, Class<? extends NativeScriptFactory>> scripts = new HashMap<>();
private final List<ScriptContext.Plugin> customScriptContexts = new ArrayList<>();

@ -21,7 +21,6 @@ package org.elasticsearch.search.aggregations;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -40,7 +39,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
import static org.elasticsearch.common.util.CollectionUtils.eagerTransform;
/**
@ -100,13 +98,13 @@ public class InternalAggregations implements Aggregations, ToXContent, Streamabl
@Override
public Map<String, Aggregation> getAsMap() {
if (aggregationsAsMap == null) {
Map<String, InternalAggregation> aggregationsAsMap = newHashMap();
Map<String, InternalAggregation> aggregationsAsMap = new HashMap<>();
for (InternalAggregation aggregation : aggregations) {
aggregationsAsMap.put(aggregation.getName(), aggregation);
}
this.aggregationsAsMap = aggregationsAsMap;
}
return Maps.transformValues(aggregationsAsMap, SUPERTYPE_CAST);
return new HashMap<>(aggregationsAsMap);
}
/**

@ -19,8 +19,6 @@
package org.elasticsearch.search.aggregations;
import com.google.common.collect.Maps;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;

@ -18,8 +18,6 @@
*/
package org.elasticsearch.search.aggregations.bucket.significant;
import com.google.common.collect.Maps;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.search.aggregations.Aggregations;
@ -151,7 +149,7 @@ public abstract class InternalSignificantTerms<A extends InternalSignificantTerm
@Override
public SignificantTerms.Bucket getBucketByKey(String term) {
if (bucketMap == null) {
bucketMap = Maps.newHashMapWithExpectedSize(buckets.size());
bucketMap = new HashMap<>(buckets.size());
for (Bucket bucket : buckets) {
bucketMap.put(bucket.getKeyAsString(), bucket);
}

@ -41,10 +41,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
public class ScriptHeuristic extends SignificanceHeuristic {
protected static final ParseField NAMES_FIELD = new ParseField("script_heuristic");
@ -162,7 +161,7 @@ public class ScriptHeuristic extends SignificanceHeuristic {
ScriptParameterValue scriptValue = scriptParameterParser.getDefaultScriptParameterValue();
if (scriptValue != null) {
if (params == null) {
params = newHashMap();
params = new HashMap<>();
}
script = new Script(scriptValue.script(), scriptValue.scriptType(), scriptParameterParser.lang(), params);
}

@ -19,9 +19,7 @@
package org.elasticsearch.search.aggregations.bucket.terms;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.search.aggregations.AggregationExecutionException;
@ -36,6 +34,7 @@ import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -147,7 +146,7 @@ public abstract class InternalTerms<A extends InternalTerms, B extends InternalT
@Override
public Terms.Bucket getBucketByKey(String term) {
if (bucketMap == null) {
bucketMap = Maps.newHashMapWithExpectedSize(buckets.size());
bucketMap = new HashMap<>(buckets.size());
for (Bucket bucket : buckets) {
bucketMap.put(bucket.getKeyAsString(), bucket);
}

@ -43,10 +43,9 @@ import org.elasticsearch.search.internal.SearchContext;
import org.joda.time.DateTimeZone;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
*
*/
@ -163,7 +162,7 @@ public class ValuesSourceParser<VS extends ValuesSource> {
ScriptParameterValue scriptValue = scriptParameterParser.getDefaultScriptParameterValue();
if (scriptValue != null) {
if (input.params == null) {
input.params = newHashMap();
input.params = new HashMap<>();
}
input.script = new Script(scriptValue.script(), scriptValue.scriptType(), scriptParameterParser.lang(), input.params);
}

@ -18,8 +18,6 @@
*/
package org.elasticsearch.search.fetch;
import com.google.common.collect.Maps;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@ -29,6 +27,7 @@ import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.SearchContext;
import java.util.HashMap;
import java.util.Map;
/**
@ -76,7 +75,7 @@ public interface FetchSubPhase {
public Map<String, Object> cache() {
if (cache == null) {
cache = Maps.newHashMap();
cache = new HashMap<>();
}
return cache;
}

@ -30,10 +30,9 @@ import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.internal.SearchContext;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
/**
* <pre>
* "script_fields" : {
@ -85,7 +84,7 @@ public class ScriptFieldsParseElement implements SearchParseElement {
ScriptParameterValue scriptValue = scriptParameterParser.getDefaultScriptParameterValue();
if (scriptValue != null) {
if (params == null) {
params = newHashMap();
params = new HashMap<>();
}
script = new Script(scriptValue.script(), scriptValue.scriptType(), scriptParameterParser.lang(), params);
}

Some files were not shown because too many files have changed in this diff Show More