Skip to content

Commit 765dafd

Browse files
authored
Remove unnecessary uses of ObjectHashSet (#85911)
A couple places in ES code use ObjectHashSet when a Java HashSet is essentially equivalent. This commit converts these trivial uses to use HashSet. relates #84735
1 parent 10aa947 commit 765dafd

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
package org.elasticsearch.action.admin.indices.mapping.put;
1010

11-
import com.carrotsearch.hppc.ObjectHashSet;
12-
1311
import org.elasticsearch.ElasticsearchGenerationException;
1412
import org.elasticsearch.Version;
1513
import org.elasticsearch.action.ActionRequestValidationException;
@@ -35,6 +33,7 @@
3533
import java.util.Arrays;
3634
import java.util.Map;
3735
import java.util.Objects;
36+
import java.util.Set;
3837

3938
import static org.elasticsearch.action.ValidateActions.addValidationError;
4039

@@ -51,7 +50,7 @@
5150
*/
5251
public class PutMappingRequest extends AcknowledgedRequest<PutMappingRequest> implements IndicesRequest.Replaceable {
5352

54-
private static ObjectHashSet<String> RESERVED_FIELDS = ObjectHashSet.from(
53+
private static Set<String> RESERVED_FIELDS = Set.of(
5554
"_uid",
5655
"_id",
5756
"_type",

server/src/main/java/org/elasticsearch/indices/IndicesRequestCache.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
package org.elasticsearch.indices;
1010

11-
import com.carrotsearch.hppc.ObjectHashSet;
12-
import com.carrotsearch.hppc.ObjectSet;
13-
1411
import org.apache.lucene.index.DirectoryReader;
1512
import org.apache.lucene.util.Accountable;
1613
import org.apache.lucene.util.RamUsageEstimator;
@@ -34,6 +31,7 @@
3431
import java.io.IOException;
3532
import java.util.Collection;
3633
import java.util.Collections;
34+
import java.util.HashSet;
3735
import java.util.Iterator;
3836
import java.util.Objects;
3937
import java.util.Set;
@@ -319,10 +317,8 @@ public int hashCode() {
319317
}
320318

321319
synchronized void cleanCache() {
322-
final ObjectSet<CleanupKey> currentKeysToClean = new ObjectHashSet<>();
323-
final ObjectSet<Object> currentFullClean = new ObjectHashSet<>();
324-
currentKeysToClean.clear();
325-
currentFullClean.clear();
320+
final Set<CleanupKey> currentKeysToClean = new HashSet<>();
321+
final Set<Object> currentFullClean = new HashSet<>();
326322
for (Iterator<CleanupKey> iterator = keysToClean.iterator(); iterator.hasNext();) {
327323
CleanupKey cleanupKey = iterator.next();
328324
iterator.remove();

0 commit comments

Comments
 (0)