@Override public int compare(Chunk o1, Chunk o2) { return Long.signum(o1.block - o2.block); } });
@Override public int getSignum() { return Long.signum(value); }
@Override public int getSignum() { return Long.signum(nanos); }
/** * Returns -1 if this timestamp is older than the given timestamp, 1 if this * timestamp is newer, or zero if they are equal. */ public int compare(Timestamp other) { return Long.signum(this.unixTime - other.unixTime); }
@Override public int compareTo(EdgePattern o) { int timeDifference = Long.signum(timestamp - o.timestamp); if (timeDifference != 0) { return timeDifference; } else { // don't really care about the order, but want to make them unique in the set. return System.identityHashCode(this) - System.identityHashCode(o); } } }
@Override public Value add(Value v) { ValueLong other = (ValueLong) v; long result = value + other.value; int sv = Long.signum(value); int so = Long.signum(other.value); int sr = Long.signum(result); // if the operands have different signs overflow can not occur // if the operands have the same sign, // and the result has a different sign, then it is an overflow // it can not be an overflow when one of the operands is 0 if (sv != so || sr == so || sv == 0 || so == 0) { return ValueLong.get(result); } throw getOverflow(); }
@Override public int compare(Object aObj, Object bObj) { if (aObj == bObj) { return 0; } VersionedValue a = (VersionedValue) aObj; VersionedValue b = (VersionedValue) bObj; long comp = a.operationId - b.operationId; if (comp == 0) { return valueType.compare(a.value, b.value); } return Long.signum(comp); }
@Override public int compareTo(final Setup other) { // largest ops/sec first return Long.signum(other.stats.averageOpsPerSec - stats.averageOpsPerSec); }
public int compareTo(final XidKey o) { final int res = signum(expiration - o.expiration); return res == 0 ? gtid.compareTo(o.gtid) : res; }
@Override public Value subtract(Value v) { ValueLong other = (ValueLong) v; int sv = Long.signum(value); int so = Long.signum(other.value); // if the operands have the same sign, then overflow can not occur // if the second operand is 0, then overflow can not occur if (sv == so || so == 0) { return ValueLong.get(value - other.value); } // now, if the other value is Long.MIN_VALUE, it must be an overflow // x - Long.MIN_VALUE overflows for x>=0 return add(other.negate()); }
@UsedByGeneratedCode public static long divideShortShortShort(long dividend, long divisor, int rescaleFactor) { if (divisor == 0) { throw new PrestoException(DIVISION_BY_ZERO, "Division by zero"); } if (dividend == 0) { return 0; } int resultSignum = signum(dividend) * signum(divisor); long unsignedDividend = abs(dividend); long unsignedDivisor = abs(divisor); long rescaledUnsignedDividend = unsignedDividend * longTenToNth(rescaleFactor); long quotient = rescaledUnsignedDividend / unsignedDivisor; long remainder = rescaledUnsignedDividend - (quotient * unsignedDivisor); if (Long.compareUnsigned(remainder * 2, unsignedDivisor) >= 0) { quotient++; } return resultSignum * quotient; }
@Override public int compare(VirtualFile resource, VirtualFile resource1) { return Long.signum(resource.getLastModified() - resource1.getLastModified()); } };
@Override public int compareTo(OffHeapStoredObject o) { int result = Integer.signum(getSize() - o.getSize()); if (result == 0) { // For the same sized chunks we really don't care about their order // but we need compareTo to only return 0 if the two chunks are identical result = Long.signum(getAddress() - o.getAddress()); } return result; }
@Override public int compare(VersionTag o1, VersionTag o2) { long result = o1.getRegionVersion() - o2.getRegionVersion(); if (result == 0) { result = o1.getVersionTimeStamp() - o2.getVersionTimeStamp(); } return Long.signum(result); }
@Override public int compare(FetchInputFormatSplit a, FetchInputFormatSplit b) { final Path ap = a.getPath(); final Path bp = b.getPath(); if (ap != null) { return (ap.compareTo(bp)); } return Long.signum(a.getLength() - b.getLength()); } }
public int compareLonger(Streak other) { if (this.getLength() != other.getLength()) return Long.signum(this.getLength() - other.getLength()); return compareNewer(other); }