mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
[JAVA7 Upgrade] Move to Long.compare
This commit is contained in:
parent
11b51b1780
commit
49d84cb47f
@ -44,3 +44,6 @@ java.lang.Object#notifyAll()
|
||||
@defaultMessage Beware of the behavior of this method on MIN_VALUE
|
||||
java.lang.Math#abs(int)
|
||||
java.lang.Math#abs(long)
|
||||
|
||||
@defaultMessage Use Long.compare instead we are on Java7
|
||||
com.google.common.primitives.Longs#compare(long,long)
|
@ -22,7 +22,6 @@ package org.elasticsearch.common.util;
|
||||
import com.carrotsearch.hppc.DoubleArrayList;
|
||||
import com.carrotsearch.hppc.FloatArrayList;
|
||||
import com.carrotsearch.hppc.LongArrayList;
|
||||
import com.google.common.primitives.Longs;
|
||||
import org.apache.lucene.util.IntroSorter;
|
||||
import org.elasticsearch.common.Preconditions;
|
||||
|
||||
@ -52,7 +51,7 @@ public enum CollectionUtils {
|
||||
|
||||
@Override
|
||||
protected int compare(int i, int j) {
|
||||
return Longs.compare(array[i], array[j]);
|
||||
return Long.compare(array[i], array[j]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +61,7 @@ public enum CollectionUtils {
|
||||
|
||||
@Override
|
||||
protected int comparePivot(int j) {
|
||||
return Longs.compare(pivot, array[j]);
|
||||
return Long.compare(pivot, array[j]);
|
||||
}
|
||||
|
||||
}.sort(0, len);
|
||||
|
@ -100,7 +100,7 @@ public final class BytesRefOrdValComparator extends NestedWrappableComparator<By
|
||||
@Override
|
||||
public int compare(int slot1, int slot2) {
|
||||
if (readerGen[slot1] == readerGen[slot2]) {
|
||||
return LongValuesComparator.compare(ords[slot1], ords[slot2]);
|
||||
return Long.compare(ords[slot1], ords[slot2]);
|
||||
}
|
||||
|
||||
final BytesRef val1 = values[slot1];
|
||||
@ -205,7 +205,7 @@ public final class BytesRefOrdValComparator extends NestedWrappableComparator<By
|
||||
assert bottomSlot != -1;
|
||||
final long docOrd = getOrd(doc);
|
||||
final long comparableOrd = docOrd == Ordinals.MISSING_ORDINAL ? missingOrd : docOrd << 2;
|
||||
return LongValuesComparator.compare(bottomOrd, comparableOrd);
|
||||
return Long.compare(bottomOrd, comparableOrd);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -215,19 +215,19 @@ public final class BytesRefOrdValComparator extends NestedWrappableComparator<By
|
||||
return compareTopMissing();
|
||||
} else {
|
||||
final long comparableOrd = ord << 2;
|
||||
return LongValuesComparator.compare(topOrd, comparableOrd);
|
||||
return Long.compare(topOrd, comparableOrd);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareBottomMissing() {
|
||||
assert bottomSlot != -1;
|
||||
return LongValuesComparator.compare(bottomOrd, missingOrd);
|
||||
return Long.compare(bottomOrd, missingOrd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTopMissing() {
|
||||
int cmp = LongValuesComparator.compare(topOrd, missingOrd);
|
||||
int cmp = Long.compare(topOrd, missingOrd);
|
||||
if (cmp == 0) {
|
||||
return compareValues(top, missingValue);
|
||||
} else {
|
||||
|
@ -38,7 +38,7 @@ public final class LongValuesComparator extends LongValuesComparatorBase<Long> {
|
||||
public int compare(int slot1, int slot2) {
|
||||
final long v1 = values[slot1];
|
||||
final long v2 = values[slot2];
|
||||
return compare(v1, v2);
|
||||
return Long.compare(v1, v2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,22 +43,12 @@ abstract class LongValuesComparatorBase<T extends Number> extends NumberComparat
|
||||
@Override
|
||||
public final int compareBottom(int doc) throws IOException {
|
||||
long v2 = sortMode.getRelevantValue(readerValues, doc, missingValue);
|
||||
return compare(bottom, v2);
|
||||
return Long.compare(bottom, v2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTop(int doc) throws IOException {
|
||||
return compare(top.longValue(), sortMode.getRelevantValue(readerValues, doc, missingValue));
|
||||
}
|
||||
|
||||
static final int compare(long left, long right) {
|
||||
if (left > right) {
|
||||
return 1;
|
||||
} else if (left < right) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return Long.compare(top.longValue(), sortMode.getRelevantValue(readerValues, doc, missingValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,11 +59,11 @@ abstract class LongValuesComparatorBase<T extends Number> extends NumberComparat
|
||||
|
||||
@Override
|
||||
public int compareBottomMissing() {
|
||||
return compare(bottom, missingValue);
|
||||
return Long.compare(bottom, missingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTopMissing() {
|
||||
return compare(top.longValue(), missingValue);
|
||||
return Long.compare(top.longValue(), missingValue);
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class BlobStoreSnapshot implements Snapshot {
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Snapshot o) {
|
||||
return Longs.compare(startTime, ((BlobStoreSnapshot) o).startTime);
|
||||
return Long.compare(startTime, ((BlobStoreSnapshot) o).startTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.search.aggregations.bucket.histogram;
|
||||
|
||||
import com.google.common.primitives.Longs;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
||||
|
||||
@ -72,23 +71,23 @@ public interface Histogram extends MultiBucketsAggregation {
|
||||
public static final Order KEY_ASC = new InternalOrder((byte) 1, "_key", true, new Comparator<InternalHistogram.Bucket>() {
|
||||
@Override
|
||||
public int compare(InternalHistogram.Bucket b1, InternalHistogram.Bucket b2) {
|
||||
return Longs.compare(b1.key, b2.key);
|
||||
return Long.compare(b1.key, b2.key);
|
||||
}
|
||||
});
|
||||
|
||||
public static final Order KEY_DESC = new InternalOrder((byte) 2, "_key", false, new Comparator<InternalHistogram.Bucket>() {
|
||||
@Override
|
||||
public int compare(InternalHistogram.Bucket b1, InternalHistogram.Bucket b2) {
|
||||
return -Longs.compare(b1.key, b2.key);
|
||||
return -Long.compare(b1.key, b2.key);
|
||||
}
|
||||
});
|
||||
|
||||
public static final Order COUNT_ASC = new InternalOrder((byte) 3, "_count", true, new Comparator<InternalHistogram.Bucket>() {
|
||||
@Override
|
||||
public int compare(InternalHistogram.Bucket b1, InternalHistogram.Bucket b2) {
|
||||
int cmp = Longs.compare(b1.getDocCount(), b2.getDocCount());
|
||||
int cmp = Long.compare(b1.getDocCount(), b2.getDocCount());
|
||||
if (cmp == 0) {
|
||||
cmp = Longs.compare(b1.key, b2.key);
|
||||
cmp = Long.compare(b1.key, b2.key);
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
@ -98,9 +97,9 @@ public interface Histogram extends MultiBucketsAggregation {
|
||||
public static final Order COUNT_DESC = new InternalOrder((byte) 4, "_count", false, new Comparator<InternalHistogram.Bucket>() {
|
||||
@Override
|
||||
public int compare(InternalHistogram.Bucket b1, InternalHistogram.Bucket b2) {
|
||||
int cmp = -Longs.compare(b1.getDocCount(), b2.getDocCount());
|
||||
int cmp = -Long.compare(b1.getDocCount(), b2.getDocCount());
|
||||
if (cmp == 0) {
|
||||
cmp = Longs.compare(b1.key, b2.key);
|
||||
cmp = Long.compare(b1.key, b2.key);
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class SignificantLongTerms extends InternalSignificantTerms {
|
||||
|
||||
@Override
|
||||
int compareTerm(SignificantTerms.Bucket other) {
|
||||
return Longs.compare(term, other.getKeyAsNumber().longValue());
|
||||
return Long.compare(term, other.getKeyAsNumber().longValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ class InternalOrder extends Terms.Order {
|
||||
public static final InternalOrder COUNT_DESC = new InternalOrder((byte) 1, "_count", false, new Comparator<Terms.Bucket>() {
|
||||
@Override
|
||||
public int compare(Terms.Bucket o1, Terms.Bucket o2) {
|
||||
int cmp = - Longs.compare(o1.getDocCount(), o2.getDocCount());
|
||||
int cmp = - Long.compare(o1.getDocCount(), o2.getDocCount());
|
||||
if (cmp == 0) {
|
||||
cmp = o1.compareTerm(o2);
|
||||
}
|
||||
@ -60,7 +60,7 @@ class InternalOrder extends Terms.Order {
|
||||
|
||||
@Override
|
||||
public int compare(Terms.Bucket o1, Terms.Bucket o2) {
|
||||
int cmp = Longs.compare(o1.getDocCount(), o2.getDocCount());
|
||||
int cmp = Long.compare(o1.getDocCount(), o2.getDocCount());
|
||||
if (cmp == 0) {
|
||||
cmp = o1.compareTerm(o2);
|
||||
}
|
||||
@ -163,7 +163,7 @@ class InternalOrder extends Terms.Order {
|
||||
public int compare(Terms.Bucket o1, Terms.Bucket o2) {
|
||||
long v1 = ((SingleBucketAggregator) aggregator).bucketDocCount(((InternalTerms.Bucket) o1).bucketOrd);
|
||||
long v2 = ((SingleBucketAggregator) aggregator).bucketDocCount(((InternalTerms.Bucket) o2).bucketOrd);
|
||||
return asc ? Longs.compare(v1, v2) : Longs.compare(v2, v1);
|
||||
return asc ? Long.compare(v1, v2) : Long.compare(v2, v1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.search.aggregations.bucket.terms;
|
||||
|
||||
import com.google.common.primitives.Longs;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.text.StringText;
|
||||
@ -85,7 +84,7 @@ public class LongTerms extends InternalTerms {
|
||||
|
||||
@Override
|
||||
int compareTerm(Terms.Bucket other) {
|
||||
return Longs.compare(term, other.getKeyAsNumber().longValue());
|
||||
return Long.compare(term, other.getKeyAsNumber().longValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class GroupRedBlackTree extends RedBlackTree {
|
||||
final double centroid = mean(node);
|
||||
int cmp = Double.compare(tmpCentroid, centroid);
|
||||
if (cmp == 0) {
|
||||
cmp = Longs.compare(tmpId, ids[node]);
|
||||
cmp = Long.compare(tmpId, ids[node]);
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.search.aggregations.support;
|
||||
|
||||
import com.google.common.primitives.Longs;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.util.ArrayUtil;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
@ -630,7 +629,7 @@ public abstract class FieldDataSource {
|
||||
protected int compare(int i, int j) {
|
||||
final long l1 = array[i];
|
||||
final long l2 = array[j];
|
||||
return Longs.compare(l1, l2);
|
||||
return Long.compare(l1, l2);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user