private static int compareLongAgainstRawType( long lhs, long rhsRawBits, byte rhsType ) { if ( rhsType == BYTE || rhsType == SHORT || rhsType == INT || rhsType == LONG ) { return Long.compare( lhs, rhsRawBits ); } else if ( rhsType == FLOAT ) { return NumberValues.compareLongAgainstDouble( lhs, Float.intBitsToFloat( (int) rhsRawBits ) ); } else if ( rhsType == DOUBLE ) { return NumberValues.compareLongAgainstDouble( lhs, Double.longBitsToDouble( rhsRawBits ) ); } // We can not throw here because we will visit this method inside a pageCursor.shouldRetry() block. // Just return a comparison that at least will be commutative. return Long.compare( lhs, rhsRawBits ); }
@Override public int compareTo( FloatingPointValue other ) { return NumberValues.compareLongAgainstDouble( longValue(), other.doubleValue() ); }
public static int compareIntegerVsFloatArrays( IntegralArray a, FloatingPointArray b ) { int i = 0; int x = 0; int length = Math.min( a.length(), b.length() ); while ( x == 0 && i < length ) { x = compareLongAgainstDouble( a.longValue( i ), b.doubleValue( i ) ); i++; } if ( x == 0 ) { x = a.length() - b.length(); } return x; }
private static int compareLongAgainstRawType( long lhs, long rhsRawBits, byte rhsType ) { if ( rhsType == BYTE || rhsType == SHORT || rhsType == INT || rhsType == LONG ) { return Long.compare( lhs, rhsRawBits ); } else if ( rhsType == FLOAT ) { return NumberValues.compareLongAgainstDouble( lhs, Float.intBitsToFloat( (int) rhsRawBits ) ); } else if ( rhsType == DOUBLE ) { return NumberValues.compareLongAgainstDouble( lhs, Double.longBitsToDouble( rhsRawBits ) ); } // We can not throw here because we will visit this method inside a pageCursor.shouldRetry() block. // Just return a comparison that at least will be commutative. return Long.compare( lhs, rhsRawBits ); }
@Override public int compareTo( FloatingPointValue other ) { return NumberValues.compareLongAgainstDouble( longValue(), other.doubleValue() ); }
public static int compareIntegerVsFloatArrays( IntegralArray a, FloatingPointArray b ) { int i = 0; int x = 0; int length = Math.min( a.length(), b.length() ); while ( x == 0 && i < length ) { x = compareLongAgainstDouble( a.longValue( i ), b.doubleValue( i ) ); i++; } if ( x == 0 ) { x = a.length() - b.length(); } return x; }