Drop commons-lang dependency
commons-lang really is only used by some core classes to join strings or modiy arrays. It's not worth carrying the dependency. This commit removes the dependency on commons-lang entirely.
This commit is contained in:
parent
e07f039659
commit
0ffd99cca3
|
@ -161,10 +161,6 @@
|
|||
<groupId>org.hdrhistogram</groupId>
|
||||
<artifactId>HdrHistogram</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
<include>com.ning:compress-lzf</include>
|
||||
<include>com.github.spullara.mustache.java:compiler</include>
|
||||
<include>com.tdunning:t-digest</include>
|
||||
<include>org.apache.commons:commons-lang3</include>
|
||||
<include>commons-cli:commons-cli</include>
|
||||
<include>com.twitter:jsr166e</include>
|
||||
<include>org.hdrhistogram:HdrHistogram</include>
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.base.Preconditions;
|
|||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
|
|
|
@ -22,9 +22,9 @@ 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.commons.lang3.ArrayUtils;
|
||||
import org.apache.lucene.util.mutable.MutableValueInt;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -134,13 +134,14 @@ public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {
|
|||
|
||||
@Override
|
||||
V get(Object key, int hash) {
|
||||
final int slot = ArrayUtils.indexOf(keys, key);
|
||||
if (slot < 0) {
|
||||
return null;
|
||||
} else {
|
||||
return values[slot];
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
if (key.equals(keys[i])) {
|
||||
return values[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private static <T> T[] replace(T[] array, int index, T value) {
|
||||
final T[] copy = Arrays.copyOf(array, array.length);
|
||||
|
@ -151,14 +152,20 @@ public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {
|
|||
@Override
|
||||
Leaf<K, V> put(K key, int hash, int hashBits, V value, MutableValueInt newValue) {
|
||||
assert hashBits <= 0 : hashBits;
|
||||
final int slot = ArrayUtils.indexOf(keys, key);
|
||||
int slot = -1;
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
if (key.equals(keys[i])) {
|
||||
slot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final K[] keys2;
|
||||
final V[] values2;
|
||||
|
||||
if (slot < 0) {
|
||||
keys2 = ArrayUtils.add(keys, key);
|
||||
values2 = ArrayUtils.add(values, value);
|
||||
keys2 = appendElement(keys, key);
|
||||
values2 = appendElement(values, value);
|
||||
newValue.value = 1;
|
||||
} else {
|
||||
keys2 = replace(keys, slot, key);
|
||||
|
@ -170,16 +177,49 @@ public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {
|
|||
|
||||
@Override
|
||||
Leaf<K, V> remove(Object key, int hash) {
|
||||
final int slot = ArrayUtils.indexOf(keys, key);
|
||||
int slot = -1;
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
if (key.equals(keys[i])) {
|
||||
slot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (slot < 0) {
|
||||
return this;
|
||||
}
|
||||
final K[] keys2 = ArrayUtils.remove(keys, slot);
|
||||
final V[] values2 = ArrayUtils.remove(values, slot);
|
||||
final K[] keys2 = removeArrayElement(keys, slot);
|
||||
final V[] values2 = removeArrayElement(values, slot);
|
||||
return new Leaf<>(keys2, values2);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> T[] removeArrayElement(T[] array, int index) {
|
||||
final Object result = Array.newInstance(array.getClass().getComponentType(), array.length - 1);
|
||||
System.arraycopy(array, 0, result, 0, index);
|
||||
if (index < array.length - 1) {
|
||||
System.arraycopy(array, index + 1, result, index, array.length - index - 1);
|
||||
}
|
||||
|
||||
return (T[]) result;
|
||||
}
|
||||
|
||||
public static <T> T[] appendElement(final T[] array, final T element) {
|
||||
final T[] newArray = Arrays.copyOf(array, array.length + 1);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
||||
public static <T> T[] insertElement(final T[] array, final T element, final int index) {
|
||||
final T[] result = Arrays.copyOf(array, array.length + 1);
|
||||
System.arraycopy(array, 0, result, 0, index);
|
||||
result[index] = element;
|
||||
if (index < array.length) {
|
||||
System.arraycopy(array, index, result, index + 1, array.length - index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An inner node in this trie. Inner nodes store up to 64 key-value pairs
|
||||
* and use a bitmap in order to associate hashes to them. For example, if
|
||||
|
@ -320,8 +360,8 @@ public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {
|
|||
|
||||
private InnerNode<K, V> putNew(K key, int hash6, int slot, V value) {
|
||||
final long mask2 = mask | (1L << hash6);
|
||||
final K[] keys2 = ArrayUtils.add(keys, slot, key);
|
||||
final Object[] subNodes2 = ArrayUtils.add(subNodes, slot, value);
|
||||
final K[] keys2 = insertElement(keys, key, slot);
|
||||
final Object[] subNodes2 = insertElement(subNodes, value, slot);
|
||||
return new InnerNode<>(mask2, keys2, subNodes2);
|
||||
}
|
||||
|
||||
|
@ -342,8 +382,8 @@ public final class CopyOnWriteHashMap<K, V> extends AbstractMap<K, V> {
|
|||
|
||||
private InnerNode<K, V> removeSlot(int hash6, int slot) {
|
||||
final long mask2 = mask & ~(1L << hash6);
|
||||
final K[] keys2 = ArrayUtils.remove(keys, slot);
|
||||
final Object[] subNodes2 = ArrayUtils.remove(subNodes, slot);
|
||||
final K[] keys2 = removeArrayElement(keys, slot);
|
||||
final Object[] subNodes2 = removeArrayElement(subNodes, slot);
|
||||
return new InnerNode<>(mask2, keys2, subNodes2);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.common.collect.Sets;
|
|||
import com.spatial4j.core.exception.InvalidShapeException;
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
import com.vividsolutions.jts.geom.*;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -98,7 +98,6 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
|
|||
|
||||
/**
|
||||
* build new hole to the polygon
|
||||
* @param hole linear ring defining the hole
|
||||
* @return this
|
||||
*/
|
||||
public Ring<E> hole() {
|
||||
|
@ -285,7 +284,7 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
|
|||
Edge current = edge;
|
||||
Edge prev = edge;
|
||||
// bookkeep the source and sink of each visited coordinate
|
||||
HashMap<Coordinate, Pair<Edge, Edge>> visitedEdge = new HashMap<>();
|
||||
HashMap<Coordinate, Tuple<Edge, Edge>> visitedEdge = new HashMap<>();
|
||||
do {
|
||||
current.coordinate = shift(current.coordinate, shiftOffset);
|
||||
current.component = id;
|
||||
|
@ -301,7 +300,7 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
|
|||
// since we're splitting connected components, we want the edges method to visit
|
||||
// the newly separated component
|
||||
final int visitID = -id;
|
||||
Edge firstAppearance = visitedEdge.get(current.coordinate).getRight();
|
||||
Edge firstAppearance = visitedEdge.get(current.coordinate).v2();
|
||||
// correct the graph pointers by correcting the 'next' pointer for both the
|
||||
// first appearance and this appearance of the edge
|
||||
Edge temp = firstAppearance.next;
|
||||
|
@ -312,12 +311,12 @@ public abstract class BasePolygonBuilder<E extends BasePolygonBuilder<E>> extend
|
|||
// a non-visited value (anything positive)
|
||||
do {
|
||||
prev.component = visitID;
|
||||
prev = visitedEdge.get(prev.coordinate).getLeft();
|
||||
prev = visitedEdge.get(prev.coordinate).v1();
|
||||
++splitIndex;
|
||||
} while (!current.coordinate.equals(prev.coordinate));
|
||||
++connectedComponents;
|
||||
} else {
|
||||
visitedEdge.put(current.coordinate, Pair.of(prev, current));
|
||||
visitedEdge.put(current.coordinate, new Tuple<Edge, Edge>(prev, current));
|
||||
}
|
||||
edges.add(current);
|
||||
prev = current;
|
||||
|
|
|
@ -26,9 +26,8 @@ import com.spatial4j.core.shape.jts.JtsGeometry;
|
|||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Explicit;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.common.unit.DistanceUnit.Distance;
|
||||
|
@ -487,7 +486,7 @@ public abstract class ShapeBuilder implements ToXContent {
|
|||
return top;
|
||||
}
|
||||
|
||||
private static final Pair range(Coordinate[] points, int offset, int length) {
|
||||
private static final double[] range(Coordinate[] points, int offset, int length) {
|
||||
double minX = points[0].x;
|
||||
double maxX = points[0].x;
|
||||
double minY = points[0].y;
|
||||
|
@ -507,7 +506,7 @@ public abstract class ShapeBuilder implements ToXContent {
|
|||
maxY = points[offset + i].y;
|
||||
}
|
||||
}
|
||||
return Pair.of(Pair.of(minX, maxX), Pair.of(minY, maxY));
|
||||
return new double[] {minX, maxX, minY, maxY};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -585,8 +584,8 @@ public abstract class ShapeBuilder implements ToXContent {
|
|||
// and convert to a right handed system
|
||||
|
||||
// compute the bounding box and calculate range
|
||||
Pair<Pair, Pair> range = range(points, offset, length);
|
||||
final double rng = (Double)range.getLeft().getRight() - (Double)range.getLeft().getLeft();
|
||||
double[] range = range(points, offset, length);
|
||||
final double rng = range[1] - range[0];
|
||||
// translate the points if the following is true
|
||||
// 1. shell orientation is cw and range is greater than a hemisphere (180 degrees) but not spanning 2 hemispheres
|
||||
// (translation would result in a collapsed poly)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.common;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -77,7 +76,10 @@ public class ParseFieldTests extends ESTestCase {
|
|||
String[] deprecated = new String[]{"text", "same_as_text"};
|
||||
String[] allValues = values;
|
||||
if (withDeprecatedNames) {
|
||||
allValues = ArrayUtils.addAll(values, deprecated);
|
||||
String[] newArray = new String[allValues.length + deprecated.length];
|
||||
System.arraycopy(allValues, 0, newArray, 0, allValues.length);
|
||||
System.arraycopy(deprecated, 0, newArray, allValues.length, deprecated.length);
|
||||
allValues = newArray;
|
||||
}
|
||||
|
||||
ParseField field = new ParseField(randomFrom(values));
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
|
@ -32,13 +31,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.indices.recovery.RecoverySettings;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
import org.elasticsearch.test.junit.listeners.LoggingListener;
|
||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportModule;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.netty.NettyTransport;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
|
@ -28,12 +28,10 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.index.shard.MergeSchedulerConfig;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
@ -80,7 +78,6 @@ import org.elasticsearch.common.Priority;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
|
@ -1920,7 +1917,11 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
}
|
||||
|
||||
if (list.length != 1) {
|
||||
throw new IllegalStateException("Backwards index must contain exactly one cluster\n" + StringUtils.join(list, "\n"));
|
||||
StringBuilder builder = new StringBuilder("Backwards index must contain exactly one cluster\n");
|
||||
for (Path line : list) {
|
||||
builder.append(line.toString()).append('\n');
|
||||
}
|
||||
throw new IllegalStateException(builder.toString());
|
||||
}
|
||||
Path src = list[0];
|
||||
Path dest = dataDir.resolve(internalCluster().getClusterName());
|
||||
|
|
|
@ -177,11 +177,6 @@
|
|||
<artifactId>t-digest</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -409,12 +409,6 @@
|
|||
<version>2.1.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
|
|
|
@ -165,11 +165,6 @@
|
|||
<artifactId>t-digest</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
|
|
|
@ -170,11 +170,6 @@
|
|||
<artifactId>t-digest</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
|
|
Loading…
Reference in New Issue