Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,7 @@ public static <T> Recycler<T> deque(Recycler.C<T> c, int limit) {
* 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);
}

/**
Expand All @@ -107,14 +73,14 @@ protected Recycler<T> getDelegate() {
}

@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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ static long hash(long value) {
return BitMixer.mix64(value);
}

static long hash(double value) {
return hash(Double.doubleToLongBits(value));
}

final BigArrays bigArrays;
final float maxLoadFactor;
long size, maxSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
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;
Expand All @@ -48,96 +47,6 @@
/** 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.
*
Expand Down Expand Up @@ -405,17 +314,6 @@ public static <E> ArrayList<E> newSingletonArrayList(E element) {
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public T put(long key, T value) {
return map.put(key, value);
}

@Override
public T putIfAbsent(long key, T value) {
return map.putIfAbsent(key, value);
}

// MAP DELEGATION

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@ final String getName() {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ static int calculateL(final double lambda, final long targetedResponseTimeNanos)
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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,6 @@ private ThreadContextStruct putTransient(String key, Object value) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static <T> Set<T> newConcurrentHashSet() {
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);
}

/**
Expand Down Expand Up @@ -157,6 +157,6 @@ public static <T> Set<T> intersection(Set<T> set1, Set<T> set2) {
left = set2;
right = set1;
}
return left.stream().filter(o -> right.contains(o)).collect(Collectors.toSet());
return left.stream().filter(right::contains).collect(Collectors.toSet());
}
}