Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop commons-lang dependency #12972

Merged
merged 1 commit into from Aug 18, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions core/pom.xml
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion core/src/main/assemblies/common-bin.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -23,7 +23,6 @@
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;
Expand Down
Expand Up @@ -22,9 +22,9 @@
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.*;

/**
Expand Down Expand Up @@ -134,12 +134,13 @@ void visit(Deque<Map.Entry<K, V>> entries, Deque<Node<K, V>> nodes) {

@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) {
Expand All @@ -151,14 +152,20 @@ private static <T> T[] replace(T[] array, int index, T value) {
@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);
Expand All @@ -170,16 +177,49 @@ Leaf<K, V> put(K key, int hash, int hashBits, V value, MutableValueInt newValue)

@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
Expand Down Expand Up @@ -320,8 +360,8 @@ private InnerNode<K, V> putExisting(K key, int hash, int hashBits, int slot, V 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);
}

Expand All @@ -342,8 +382,8 @@ InnerNode<K, V> put(K key, int hash, int hashBits, V value, MutableValueInt newV

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);
}

Expand Down
Expand Up @@ -23,7 +23,7 @@
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;
Expand Down Expand Up @@ -98,7 +98,6 @@ public E hole(BaseLineStringBuilder<?> hole) {

/**
* build new hole to the polygon
* @param hole linear ring defining the hole
* @return this
*/
public Ring<E> hole() {
Expand Down Expand Up @@ -285,7 +284,7 @@ private static int component(final Edge edge, final int id, final ArrayList<Edge
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;
Expand All @@ -301,7 +300,7 @@ private static int component(final Edge edge, final int id, final ArrayList<Edge
// 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;
Expand All @@ -312,12 +311,12 @@ private static int component(final Edge edge, final int id, final ArrayList<Edge
// 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;
Expand Down
Expand Up @@ -26,9 +26,8 @@
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;
Expand Down Expand Up @@ -487,7 +486,7 @@ private static final int top(Coordinate[] points, int offset, int length) {
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;
Expand All @@ -507,7 +506,7 @@ private static final Pair range(Coordinate[] points, int offset, int length) {
maxY = points[offset + i].y;
}
}
return Pair.of(Pair.of(minX, maxX), Pair.of(minY, maxY));
return new double[] {minX, maxX, minY, maxY};
}

/**
Expand Down Expand Up @@ -585,8 +584,8 @@ protected static Edge[] ring(int component, boolean direction, boolean handednes
// 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)
Expand Down
Expand Up @@ -18,7 +18,6 @@
*/
package org.elasticsearch.common;

import org.apache.commons.lang3.ArrayUtils;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;

Expand Down Expand Up @@ -77,7 +76,10 @@ public void testAllDeprecated() {
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));
Expand Down
Expand Up @@ -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;
Expand All @@ -32,13 +31,8 @@
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;
Expand Down
Expand Up @@ -28,12 +28,10 @@
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;
Expand Down Expand Up @@ -80,7 +78,6 @@
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;
Expand Down Expand Up @@ -1920,7 +1917,11 @@ protected Settings prepareBackwardsDataDir(Path backwardsIndex, Object... settin
}

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());
Expand Down
5 changes: 0 additions & 5 deletions plugins/pom.xml
Expand Up @@ -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>
Expand Down
6 changes: 0 additions & 6 deletions pom.xml
Expand Up @@ -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>
Expand Down
5 changes: 0 additions & 5 deletions qa/smoke-test-multinode/pom.xml
Expand Up @@ -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>
Expand Down
5 changes: 0 additions & 5 deletions qa/smoke-test-plugins/pom.xml
Expand Up @@ -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>
Expand Down