Skip to content

Commit a024da6

Browse files
VinayGuthalashwinraghav
VinayGuthal
authored andcommitted
Project import generated by Copybara. (#93)
1 parent 2e9e59e commit a024da6

File tree

5 files changed

+11
-45
lines changed

5 files changed

+11
-45
lines changed

firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberComparisonHelper.java

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414

1515
package com.google.cloud.datastore.core.number;
1616

17-
/**
18-
* A utility class for comparing numbers.
19-
*
20-
* @hide
21-
*/
17+
/** A utility class for comparing numbers. */
2218
public final class NumberComparisonHelper {
2319

2420
// Long.MIN_VALUE has an exact representation as double, so the long lower bound is inclusive.
@@ -33,10 +29,10 @@ public final class NumberComparisonHelper {
3329
public static final long MIN_SAFE_LONG = -MAX_SAFE_LONG;
3430

3531
/**
36-
* Compares a double and a long. Firestore ordering: NaN precedes all other numbers and equals
37-
* itself, all zeroes are equal.
32+
* Compares a double and a with Firestore query semantics: NaN precedes all other numbers and
33+
* equals itself, all zeroes are equal.
3834
*/
39-
public static int compareDoubleWithLong(double doubleValue, long longValue) {
35+
public static int firestoreCompareDoubleWithLong(double doubleValue, long longValue) {
4036
// In Firestore NaN is defined to compare before all other numbers.
4137
if (Double.isNaN(doubleValue)) {
4238
return -1;
@@ -60,7 +56,7 @@ public static int compareDoubleWithLong(double doubleValue, long longValue) {
6056

6157
// At this point the long representations are equal but this could be due to rounding.
6258
double longAsDouble = (double) longValue;
63-
return compareDoubles(doubleValue, longAsDouble);
59+
return firestoreCompareDoubles(doubleValue, longAsDouble);
6460
}
6561

6662
/**
@@ -77,25 +73,14 @@ public static int compareLongs(long leftLong, long rightLong) {
7773
}
7874
}
7975

80-
/** Compares ints. See the comment to {@link #compareLongs} for rationale. */
81-
public static int compareInts(int leftInt, int rightInt) {
82-
if (leftInt < rightInt) {
83-
return -1;
84-
} else if (leftInt > rightInt) {
85-
return 1;
86-
} else {
87-
return 0;
88-
}
89-
}
90-
9176
/**
92-
* Compares doubles. Firestore ordering: NaN precedes all other numbers and equals itself, all
93-
* zeroes are equal.
77+
* Compares doubles with Firestore query semantics: NaN precedes all other numbers and equals
78+
* itself, all zeroes are equal.
9479
*
9580
* @return a negative integer, zero, or a positive integer as the first argument is less than,
9681
* equal to, or greater than the second.
9782
*/
98-
public static int compareDoubles(double leftDouble, double rightDouble) {
83+
public static int firestoreCompareDoubles(double leftDouble, double rightDouble) {
9984
// NaN sorts equal to itself and before any other number.
10085
if (leftDouble < rightDouble) {
10186
return -1;

firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberIndexEncoder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* <p>Implementation conforms to the UTF Style Encoding section of "Number Index Entry Encoding".
2525
*
2626
* @see "https://docs.google.com/document/d/1QX32BCTFWFS_4BneQHFRDnPb2ts04fYrm4Vgy0HLSBg/edit#"
27-
* @hide
2827
*/
2928
public class NumberIndexEncoder {
3029

firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberParts.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
/**
1818
* The representation of a number that can accommodate the range of doubles and longs without loss
1919
* of precision.
20-
*
21-
* @hide
2220
*/
2321
public final class NumberParts {
2422

firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/package-info.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

firebase-firestore/src/main/java/com/google/firebase/firestore/util/Util.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ public static int compareLongs(long i1, long i2) {
8686

8787
/** Utility function to compare ints. See {@link #compareLongs} for rationale. */
8888
public static int compareInts(int i1, int i2) {
89-
return NumberComparisonHelper.compareInts(i1, i2);
89+
return NumberComparisonHelper.compareLongs(i1, i2);
9090
}
9191

9292
/** Utility function to compare doubles (using Firestore semantics for NaN). */
9393
public static int compareDoubles(double i1, double i2) {
94-
return NumberComparisonHelper.compareDoubles(i1, i2);
94+
return NumberComparisonHelper.firestoreCompareDoubles(i1, i2);
9595
}
9696

9797
/** Compares a double and a long (using Firestore semantics for NaN). */
9898
public static int compareMixed(double doubleValue, long longValue) {
99-
return NumberComparisonHelper.compareDoubleWithLong(doubleValue, longValue);
99+
return NumberComparisonHelper.firestoreCompareDoubleWithLong(doubleValue, longValue);
100100
}
101101

102102
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)