public static int compareLongAgainstDouble( long lhs, double rhs ) { return -compareDoubleAgainstLong( rhs, lhs ); }
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 computeHash() { return NumberValues.hash( value ); }
@Override public boolean equals( double x ) { return NumberValues.numbersEqual( x, longValue() ); }
@Override public int compareTo( IntegralArray other ) { return -NumberValues.compareIntegerVsFloatArrays( other, this ); }
@Override int unsafeCompareTo( Value otherValue ) { return NumberValues.compareBooleanArrays( this, (BooleanArray) otherValue ); }
@Override public int compareTo( FloatingPointArray other ) { return NumberValues.compareFloatArrays( this, other ); }
@Override public int compareTo( IntegralArray other ) { return NumberValues.compareIntegerArrays( this, other ); }
@Override public final boolean equals( long x ) { return NumberValues.numbersEqual( doubleValue(), x ); }
@Override public int compareTo( FloatingPointArray other ) { return NumberValues.compareIntegerVsFloatArrays( this, other ); }
@Override int unsafeCompareTo( Value otherValue ) { return NumberValues.compareBooleanArrays( this, (BooleanArray) otherValue ); }
@Override public int compareTo( FloatingPointArray other ) { return NumberValues.compareFloatArrays( this, other ); }
@Override public int compareTo( IntegralArray other ) { return NumberValues.compareIntegerArrays( this, other ); }
public static int hash( double[] values ) { int result = 1; for ( double value : values ) { int elementHash = NumberValues.hash( value ); result = 31 * result + elementHash; } return result; }
@Override public int compareTo( FloatingPointValue other ) { return NumberValues.compareLongAgainstDouble( longValue(), other.doubleValue() ); }
private static int compareDoubleAgainstRawType( double lhsDouble, long rhsRawBits, byte rhsType ) { if ( rhsType == BYTE || rhsType == SHORT || rhsType == INT || rhsType == LONG ) { return NumberValues.compareDoubleAgainstLong( lhsDouble, rhsRawBits ); } else if ( rhsType == FLOAT ) { return Double.compare( lhsDouble, Float.intBitsToFloat( (int) rhsRawBits ) ); } else if ( rhsType == DOUBLE ) { return Double.compare( lhsDouble, 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( Double.doubleToLongBits( lhsDouble ), rhsRawBits ); } }
public static boolean numbersEqual( FloatingPointArray fps, IntegralArray ins ) { int length = ins.length(); if ( length != fps.length() ) { return false; } for ( int i = 0; i < length; i++ ) { if ( !numbersEqual( fps.doubleValue( i ), ins.longValue( i ) ) ) { return false; } } return true; }
@Override public int compareTo( FloatingPointArray other ) { return NumberValues.compareIntegerVsFloatArrays( this, other ); }
@Override public int computeHash() { return NumberValues.hash( value ); }
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; }