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
This commit is contained in:
Armin Braun 2019-03-07 08:31:46 +01:00 committed by GitHub
parent 34ea84948c
commit 213cc6673c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 5 additions and 183 deletions

View File

@ -51,41 +51,7 @@ public enum Recyclers {
* Return a recycler based on a deque.
*/
public static <T> Recycler.Factory<T> dequeFactory(final Recycler.C<T> c, final int limit) {
return new Recycler.Factory<T>() {
@Override
public Recycler<T> build() {
return deque(c, limit);
}
};
}
/**
* Wrap two recyclers and forward to calls to <code>smallObjectRecycler</code> when <code>size &lt; minSize</code> and to
* <code>defaultRecycler</code> otherwise.
*/
public static <T> Recycler<T> sizing(final Recycler<T> defaultRecycler, final Recycler<T> smallObjectRecycler, final int minSize) {
return new FilterRecycler<T>() {
@Override
protected Recycler<T> getDelegate() {
return defaultRecycler;
}
@Override
public Recycler.V<T> obtain(int sizing) {
if (sizing > 0 && sizing < minSize) {
return smallObjectRecycler.obtain(sizing);
}
return super.obtain(sizing);
}
@Override
public void close() {
defaultRecycler.close();
smallObjectRecycler.close();
}
};
return () -> deque(c, limit);
}
/**
@ -107,14 +73,14 @@ public enum Recyclers {
}
@Override
public org.elasticsearch.common.recycler.Recycler.V<T> obtain(int sizing) {
public Recycler.V<T> obtain(int sizing) {
synchronized (lock) {
return super.obtain(sizing);
}
}
@Override
public org.elasticsearch.common.recycler.Recycler.V<T> obtain() {
public Recycler.V<T> obtain() {
synchronized (lock) {
return super.obtain();
}

View File

@ -37,10 +37,6 @@ abstract class AbstractPagedHashMap implements Releasable {
return BitMixer.mix64(value);
}
static long hash(double value) {
return hash(Double.doubleToLongBits(value));
}
final BigArrays bigArrays;
final float maxLoadFactor;
long size, maxSize;

View File

@ -21,8 +21,6 @@ package org.elasticsearch.common.util;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.lease.Releasables;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.LongArray;
/**
* A bit array that is implemented using a growing {@link LongArray}

View File

@ -37,7 +37,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -48,96 +47,6 @@ import java.util.Set;
/** Collections-related utility methods. */
public class CollectionUtils {
public static void sort(final long[] array, int len) {
new IntroSorter() {
long pivot;
@Override
protected void swap(int i, int j) {
final long tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
@Override
protected int compare(int i, int j) {
return Long.compare(array[i], array[j]);
}
@Override
protected void setPivot(int i) {
pivot = array[i];
}
@Override
protected int comparePivot(int j) {
return Long.compare(pivot, array[j]);
}
}.sort(0, len);
}
public static void sort(final float[] array, int len) {
new IntroSorter() {
float pivot;
@Override
protected void swap(int i, int j) {
final float tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
@Override
protected int compare(int i, int j) {
return Float.compare(array[i], array[j]);
}
@Override
protected void setPivot(int i) {
pivot = array[i];
}
@Override
protected int comparePivot(int j) {
return Float.compare(pivot, array[j]);
}
}.sort(0, len);
}
public static void sort(final double[] array, int len) {
new IntroSorter() {
double pivot;
@Override
protected void swap(int i, int j) {
final double tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
@Override
protected int compare(int i, int j) {
return Double.compare(array[i], array[j]);
}
@Override
protected void setPivot(int i) {
pivot = array[i];
}
@Override
protected int comparePivot(int j) {
return Double.compare(pivot, array[j]);
}
}.sort(0, len);
}
/**
* Checks if the given array contains any elements.
*
@ -405,17 +314,6 @@ public class CollectionUtils {
return new ArrayList<>(Collections.singletonList(element));
}
public static <E> LinkedList<E> newLinkedList(Iterable<E> elements) {
if (elements == null) {
throw new NullPointerException("elements");
}
LinkedList<E> linkedList = new LinkedList<>();
for (E element : elements) {
linkedList.add(element);
}
return linkedList;
}
public static <E> List<List<E>> eagerPartition(List<E> list, int size) {
if (list == null) {
throw new NullPointerException("list");

View File

@ -35,10 +35,6 @@ public class LongObjectPagedHashMap<T> extends AbstractPagedHashMap implements I
private LongArray keys;
private ObjectArray<T> values;
public LongObjectPagedHashMap(BigArrays bigArrays) {
this(16, bigArrays);
}
public LongObjectPagedHashMap(long capacity, BigArrays bigArrays) {
this(capacity, DEFAULT_MAX_LOAD_FACTOR, bigArrays);
}

View File

@ -47,11 +47,6 @@ public class ConcurrentHashMapLong<T> implements ConcurrentMapLong<T> {
return map.put(key, value);
}
@Override
public T putIfAbsent(long key, T value) {
return map.putIfAbsent(key, value);
}
// MAP DELEGATION
@Override

View File

@ -28,6 +28,4 @@ public interface ConcurrentMapLong<T> extends ConcurrentMap<Long, T> {
T remove(long key);
T put(long key, T value);
T putIfAbsent(long key, T value);
}

View File

@ -59,20 +59,6 @@ public class EsThreadPoolExecutor extends ThreadPoolExecutor {
this.contextHolder = contextHolder;
}
public void shutdown(ShutdownListener listener) {
synchronized (monitor) {
if (this.listener != null) {
throw new IllegalStateException("Shutdown was already called on this thread pool");
}
if (isTerminated()) {
listener.onTerminated();
} else {
this.listener = listener;
}
}
shutdown();
}
@Override
protected synchronized void terminated() {
super.terminated();

View File

@ -124,13 +124,6 @@ public final class QueueResizingEsThreadPoolExecutor extends EsThreadPoolExecuto
return Math.toIntExact((long)(lambda * targetedResponseTimeNanos));
}
/**
* Returns the current queue capacity
*/
public int getCurrentCapacity() {
return workQueue.capacity();
}
/**
* Returns the exponentially weighted moving average of the task execution time
*/

View File

@ -580,10 +580,6 @@ public final class ThreadContext implements Closeable, Writeable {
return new ThreadContextStruct(requestHeaders, responseHeaders, newTransient, isSystemContext);
}
boolean isEmpty() {
return requestHeaders.isEmpty() && responseHeaders.isEmpty() && transientHeaders.isEmpty();
}
private ThreadContextStruct copyHeaders(Iterable<Map.Entry<String, String>> headers) {
Map<String, String> newHeaders = new HashMap<>();
for (Map.Entry<String, String> header : headers) {

View File

@ -68,7 +68,7 @@ public final class Sets {
public static <T> boolean haveEmptyIntersection(Set<T> left, Set<T> right) {
Objects.requireNonNull(left);
Objects.requireNonNull(right);
return !left.stream().anyMatch(k -> right.contains(k));
return left.stream().noneMatch(right::contains);
}
/**
@ -157,6 +157,6 @@ public final class Sets {
left = set2;
right = set1;
}
return left.stream().filter(o -> right.contains(o)).collect(Collectors.toSet());
return left.stream().filter(right::contains).collect(Collectors.toSet());
}
}