Merge pull request #13596 from jasontedor/ints-be-gone
Remove and forbid use of com.google.common.primitives.Ints
This commit is contained in:
commit
3a88f670ab
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.common.util;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.store.DataOutput;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
|
@ -325,7 +324,7 @@ public class BloomFilter {
|
|||
private static int size(long bits) {
|
||||
long quotient = bits / 64;
|
||||
long remainder = bits - quotient * 64;
|
||||
return Ints.checkedCast(remainder == 0 ? quotient : 1 + quotient);
|
||||
return Math.toIntExact(remainder == 0 ? quotient : 1 + quotient);
|
||||
}
|
||||
|
||||
// Used by serialization
|
||||
|
|
|
@ -277,6 +277,11 @@ public enum CollectionUtils {
|
|||
}.sort(0, array.size());
|
||||
}
|
||||
|
||||
public static int[] toArray(Collection<Integer> ints) {
|
||||
Objects.requireNonNull(ints);
|
||||
return ints.stream().mapToInt(s -> s).toArray();
|
||||
}
|
||||
|
||||
private static class RotatedList<T> extends AbstractList<T> implements RandomAccess {
|
||||
|
||||
private final List<T> in;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.common.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import com.google.common.primitives.Ints;
|
||||
import org.apache.lucene.index.CheckIndex;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
@ -43,19 +41,10 @@ import org.elasticsearch.index.shard.ShardStateMetaData;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.FileStore;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.FileVisitor;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -369,12 +358,11 @@ public class MultiDataPathUpgrader {
|
|||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(indexPath)) {
|
||||
String currentIndex = indexPath.getFileName().toString();
|
||||
for (Path shardPath : stream) {
|
||||
if (Files.isDirectory(shardPath)) {
|
||||
Integer shardId = Ints.tryParse(shardPath.getFileName().toString());
|
||||
if (shardId != null) {
|
||||
ShardId id = new ShardId(currentIndex, shardId);
|
||||
shardIds.add(id);
|
||||
}
|
||||
String fileName = shardPath.getFileName().toString();
|
||||
if (Files.isDirectory(shardPath) && fileName.chars().allMatch(Character::isDigit)) {
|
||||
int shardId = Integer.parseInt(fileName);
|
||||
ShardId id = new ShardId(currentIndex, shardId);
|
||||
shardIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,15 +20,9 @@
|
|||
package org.elasticsearch.env;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.primitives.Ints;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.SegmentInfos;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.FSDirectory;
|
||||
import org.apache.lucene.store.Lock;
|
||||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.store.NativeFSLockFactory;
|
||||
import org.apache.lucene.store.SimpleFSDirectory;
|
||||
import org.apache.lucene.store.*;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
|
@ -48,21 +42,8 @@ import org.elasticsearch.monitor.fs.FsProbe;
|
|||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.AtomicMoveNotSupportedException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.FileStore;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -711,12 +692,11 @@ public class NodeEnvironment extends AbstractComponent implements Closeable {
|
|||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(indexPath)) {
|
||||
String currentIndex = indexPath.getFileName().toString();
|
||||
for (Path shardPath : stream) {
|
||||
if (Files.isDirectory(shardPath)) {
|
||||
Integer shardId = Ints.tryParse(shardPath.getFileName().toString());
|
||||
if (shardId != null) {
|
||||
ShardId id = new ShardId(currentIndex, shardId);
|
||||
shardIds.add(id);
|
||||
}
|
||||
String fileName = shardPath.getFileName().toString();
|
||||
if (Files.isDirectory(shardPath) && fileName.chars().allMatch(Character::isDigit)) {
|
||||
int shardId = Integer.parseInt(fileName);
|
||||
ShardId id = new ShardId(currentIndex, shardId);
|
||||
shardIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
package org.elasticsearch.test.discovery;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.RandomizedTest;
|
||||
import com.google.common.primitives.Ints;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.SuppressForbidden;
|
||||
import org.elasticsearch.common.network.NetworkUtils;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
import org.elasticsearch.test.NodeConfigurationSource;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class ClusterDiscoveryConfiguration extends NodeConfigurationSource {
|
|||
while (ordinals.size() != numOfUnicastHosts) {
|
||||
ordinals.add(RandomizedTest.randomInt(numOfNodes - 1));
|
||||
}
|
||||
unicastHostOrdinals = Ints.toArray(ordinals);
|
||||
unicastHostOrdinals = CollectionUtils.toArray(ordinals);
|
||||
}
|
||||
this.unicastHostPorts = unicastHostPorts(numOfNodes);
|
||||
assert unicastHostOrdinals.length <= unicastHostPorts.length;
|
||||
|
|
|
@ -125,6 +125,7 @@ com.google.common.collect.ArrayListMultimap
|
|||
com.google.common.collect.HashMultimap
|
||||
com.google.common.collect.FluentIterable
|
||||
com.google.common.io.Files
|
||||
com.google.common.primitives.Ints
|
||||
|
||||
@defaultMessage Do not violate java's access system
|
||||
java.lang.reflect.AccessibleObject#setAccessible(boolean)
|
||||
|
|
Loading…
Reference in New Issue