Skip to content

Commit 213cc66

Browse files
Remove Dead Code in o.e.util package (#39717) (#39779)
* None of this code is used so we should delete it, we can always bring it back if needed
1 parent 34ea849 commit 213cc66

File tree

11 files changed

+5
-183
lines changed

11 files changed

+5
-183
lines changed

server/src/main/java/org/elasticsearch/common/recycler/Recyclers.java

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,41 +51,7 @@ public static <T> Recycler<T> deque(Recycler.C<T> c, int limit) {
5151
* Return a recycler based on a deque.
5252
*/
5353
public static <T> Recycler.Factory<T> dequeFactory(final Recycler.C<T> c, final int limit) {
54-
return new Recycler.Factory<T>() {
55-
@Override
56-
public Recycler<T> build() {
57-
return deque(c, limit);
58-
}
59-
};
60-
}
61-
62-
/**
63-
* Wrap two recyclers and forward to calls to <code>smallObjectRecycler</code> when <code>size &lt; minSize</code> and to
64-
* <code>defaultRecycler</code> otherwise.
65-
*/
66-
public static <T> Recycler<T> sizing(final Recycler<T> defaultRecycler, final Recycler<T> smallObjectRecycler, final int minSize) {
67-
return new FilterRecycler<T>() {
68-
69-
@Override
70-
protected Recycler<T> getDelegate() {
71-
return defaultRecycler;
72-
}
73-
74-
@Override
75-
public Recycler.V<T> obtain(int sizing) {
76-
if (sizing > 0 && sizing < minSize) {
77-
return smallObjectRecycler.obtain(sizing);
78-
}
79-
return super.obtain(sizing);
80-
}
81-
82-
@Override
83-
public void close() {
84-
defaultRecycler.close();
85-
smallObjectRecycler.close();
86-
}
87-
88-
};
54+
return () -> deque(c, limit);
8955
}
9056

9157
/**
@@ -107,14 +73,14 @@ protected Recycler<T> getDelegate() {
10773
}
10874

10975
@Override
110-
public org.elasticsearch.common.recycler.Recycler.V<T> obtain(int sizing) {
76+
public Recycler.V<T> obtain(int sizing) {
11177
synchronized (lock) {
11278
return super.obtain(sizing);
11379
}
11480
}
11581

11682
@Override
117-
public org.elasticsearch.common.recycler.Recycler.V<T> obtain() {
83+
public Recycler.V<T> obtain() {
11884
synchronized (lock) {
11985
return super.obtain();
12086
}

server/src/main/java/org/elasticsearch/common/util/AbstractPagedHashMap.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ static long hash(long value) {
3737
return BitMixer.mix64(value);
3838
}
3939

40-
static long hash(double value) {
41-
return hash(Double.doubleToLongBits(value));
42-
}
43-
4440
final BigArrays bigArrays;
4541
final float maxLoadFactor;
4642
long size, maxSize;

server/src/main/java/org/elasticsearch/common/util/BitArray.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import org.elasticsearch.common.lease.Releasable;
2323
import org.elasticsearch.common.lease.Releasables;
24-
import org.elasticsearch.common.util.BigArrays;
25-
import org.elasticsearch.common.util.LongArray;
2624

2725
/**
2826
* A bit array that is implemented using a growing {@link LongArray}

server/src/main/java/org/elasticsearch/common/util/CollectionUtils.java

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.Collections;
3838
import java.util.Comparator;
3939
import java.util.IdentityHashMap;
40-
import java.util.LinkedList;
4140
import java.util.List;
4241
import java.util.Locale;
4342
import java.util.Map;
@@ -48,96 +47,6 @@
4847
/** Collections-related utility methods. */
4948
public class CollectionUtils {
5049

51-
public static void sort(final long[] array, int len) {
52-
new IntroSorter() {
53-
54-
long pivot;
55-
56-
@Override
57-
protected void swap(int i, int j) {
58-
final long tmp = array[i];
59-
array[i] = array[j];
60-
array[j] = tmp;
61-
}
62-
63-
@Override
64-
protected int compare(int i, int j) {
65-
return Long.compare(array[i], array[j]);
66-
}
67-
68-
@Override
69-
protected void setPivot(int i) {
70-
pivot = array[i];
71-
}
72-
73-
@Override
74-
protected int comparePivot(int j) {
75-
return Long.compare(pivot, array[j]);
76-
}
77-
78-
}.sort(0, len);
79-
}
80-
81-
public static void sort(final float[] array, int len) {
82-
new IntroSorter() {
83-
84-
float pivot;
85-
86-
@Override
87-
protected void swap(int i, int j) {
88-
final float tmp = array[i];
89-
array[i] = array[j];
90-
array[j] = tmp;
91-
}
92-
93-
@Override
94-
protected int compare(int i, int j) {
95-
return Float.compare(array[i], array[j]);
96-
}
97-
98-
@Override
99-
protected void setPivot(int i) {
100-
pivot = array[i];
101-
}
102-
103-
@Override
104-
protected int comparePivot(int j) {
105-
return Float.compare(pivot, array[j]);
106-
}
107-
108-
}.sort(0, len);
109-
}
110-
111-
public static void sort(final double[] array, int len) {
112-
new IntroSorter() {
113-
114-
double pivot;
115-
116-
@Override
117-
protected void swap(int i, int j) {
118-
final double tmp = array[i];
119-
array[i] = array[j];
120-
array[j] = tmp;
121-
}
122-
123-
@Override
124-
protected int compare(int i, int j) {
125-
return Double.compare(array[i], array[j]);
126-
}
127-
128-
@Override
129-
protected void setPivot(int i) {
130-
pivot = array[i];
131-
}
132-
133-
@Override
134-
protected int comparePivot(int j) {
135-
return Double.compare(pivot, array[j]);
136-
}
137-
138-
}.sort(0, len);
139-
}
140-
14150
/**
14251
* Checks if the given array contains any elements.
14352
*
@@ -405,17 +314,6 @@ public static <E> ArrayList<E> newSingletonArrayList(E element) {
405314
return new ArrayList<>(Collections.singletonList(element));
406315
}
407316

408-
public static <E> LinkedList<E> newLinkedList(Iterable<E> elements) {
409-
if (elements == null) {
410-
throw new NullPointerException("elements");
411-
}
412-
LinkedList<E> linkedList = new LinkedList<>();
413-
for (E element : elements) {
414-
linkedList.add(element);
415-
}
416-
return linkedList;
417-
}
418-
419317
public static <E> List<List<E>> eagerPartition(List<E> list, int size) {
420318
if (list == null) {
421319
throw new NullPointerException("list");

server/src/main/java/org/elasticsearch/common/util/LongObjectPagedHashMap.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public class LongObjectPagedHashMap<T> extends AbstractPagedHashMap implements I
3535
private LongArray keys;
3636
private ObjectArray<T> values;
3737

38-
public LongObjectPagedHashMap(BigArrays bigArrays) {
39-
this(16, bigArrays);
40-
}
41-
4238
public LongObjectPagedHashMap(long capacity, BigArrays bigArrays) {
4339
this(capacity, DEFAULT_MAX_LOAD_FACTOR, bigArrays);
4440
}

server/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentHashMapLong.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ public T put(long key, T value) {
4747
return map.put(key, value);
4848
}
4949

50-
@Override
51-
public T putIfAbsent(long key, T value) {
52-
return map.putIfAbsent(key, value);
53-
}
54-
5550
// MAP DELEGATION
5651

5752
@Override

server/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentMapLong.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ public interface ConcurrentMapLong<T> extends ConcurrentMap<Long, T> {
2828
T remove(long key);
2929

3030
T put(long key, T value);
31-
32-
T putIfAbsent(long key, T value);
3331
}

server/src/main/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutor.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,6 @@ final String getName() {
5959
this.contextHolder = contextHolder;
6060
}
6161

62-
public void shutdown(ShutdownListener listener) {
63-
synchronized (monitor) {
64-
if (this.listener != null) {
65-
throw new IllegalStateException("Shutdown was already called on this thread pool");
66-
}
67-
if (isTerminated()) {
68-
listener.onTerminated();
69-
} else {
70-
this.listener = listener;
71-
}
72-
}
73-
shutdown();
74-
}
75-
7662
@Override
7763
protected synchronized void terminated() {
7864
super.terminated();

server/src/main/java/org/elasticsearch/common/util/concurrent/QueueResizingEsThreadPoolExecutor.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,6 @@ static int calculateL(final double lambda, final long targetedResponseTimeNanos)
124124
return Math.toIntExact((long)(lambda * targetedResponseTimeNanos));
125125
}
126126

127-
/**
128-
* Returns the current queue capacity
129-
*/
130-
public int getCurrentCapacity() {
131-
return workQueue.capacity();
132-
}
133-
134127
/**
135128
* Returns the exponentially weighted moving average of the task execution time
136129
*/

server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,6 @@ private ThreadContextStruct putTransient(String key, Object value) {
580580
return new ThreadContextStruct(requestHeaders, responseHeaders, newTransient, isSystemContext);
581581
}
582582

583-
boolean isEmpty() {
584-
return requestHeaders.isEmpty() && responseHeaders.isEmpty() && transientHeaders.isEmpty();
585-
}
586-
587583
private ThreadContextStruct copyHeaders(Iterable<Map.Entry<String, String>> headers) {
588584
Map<String, String> newHeaders = new HashMap<>();
589585
for (Map.Entry<String, String> header : headers) {

0 commit comments

Comments
 (0)