private static long normalizeIntegerValue(Type type, long value) { if (type.equals(BIGINT)) { return value; } if (type.equals(INTEGER)) { return Ints.saturatedCast(value); } if (type.equals(SMALLINT)) { return Shorts.saturatedCast(value); } if (type.equals(TINYINT)) { return SignedBytes.saturatedCast(value); } throw new IllegalArgumentException("Unexpected type: " + type); }
public void testSaturatedCast() { for (short value : VALUES) { assertEquals(value, Shorts.saturatedCast((long) value)); } assertEquals(GREATEST, Shorts.saturatedCast(GREATEST + 1L)); assertEquals(LEAST, Shorts.saturatedCast(LEAST - 1L)); assertEquals(GREATEST, Shorts.saturatedCast(Long.MAX_VALUE)); assertEquals(LEAST, Shorts.saturatedCast(Long.MIN_VALUE)); }
@ScalarOperator(SATURATED_FLOOR_CAST) @SqlType(StandardTypes.SMALLINT) public static long saturatedFloorCastToSmallint(@SqlType(StandardTypes.INTEGER) long value) { return Shorts.saturatedCast(value); }
@ScalarOperator(SATURATED_FLOOR_CAST) @SqlType(StandardTypes.SMALLINT) public static long saturatedFloorCastToSmallint(@SqlType(StandardTypes.BIGINT) long value) { return Shorts.saturatedCast(value); }
public void mergeWith(SetDigest other) { hll.mergeWith(other.hll); LongBidirectionalIterator iterator = other.minhash.keySet().iterator(); while (iterator.hasNext()) { long key = iterator.nextLong(); int count = minhash.get(key) + other.minhash.get(key); minhash.put(key, Shorts.saturatedCast(count)); } while (minhash.size() > maxHashes) { minhash.remove(minhash.lastLongKey()); } }
private static long normalizeIntegerValue(Type type, long value) { if (type.equals(BIGINT)) { return value; } if (type.equals(INTEGER)) { return Ints.saturatedCast(value); } if (type.equals(SMALLINT)) { return Shorts.saturatedCast(value); } if (type.equals(TINYINT)) { return SignedBytes.saturatedCast(value); } throw new IllegalArgumentException("Unexpected type: " + type); }
@ScalarOperator(SATURATED_FLOOR_CAST) @SqlType(StandardTypes.SMALLINT) public static long saturatedFloorCastToSmallint(@SqlType(StandardTypes.BIGINT) long value) { return Shorts.saturatedCast(value); }
@ScalarOperator(SATURATED_FLOOR_CAST) @SqlType(StandardTypes.SMALLINT) public static long saturatedFloorCastToSmallint(@SqlType(StandardTypes.BIGINT) long value) { return Shorts.saturatedCast(value); }
@ScalarOperator(SATURATED_FLOOR_CAST) @SqlType(StandardTypes.SMALLINT) public static long saturatedFloorCastToSmallint(@SqlType(StandardTypes.INTEGER) long value) { return Shorts.saturatedCast(value); }
public void testSaturatedCast() { for (short value : VALUES) { assertEquals(value, Shorts.saturatedCast((long) value)); } assertEquals(GREATEST, Shorts.saturatedCast(GREATEST + 1L)); assertEquals(LEAST, Shorts.saturatedCast(LEAST - 1L)); assertEquals(GREATEST, Shorts.saturatedCast(Long.MAX_VALUE)); assertEquals(LEAST, Shorts.saturatedCast(Long.MIN_VALUE)); }
@ScalarOperator(SATURATED_FLOOR_CAST) @SqlType(StandardTypes.SMALLINT) public static long saturatedFloorCastToSmallint(@SqlType(StandardTypes.INTEGER) long value) { return Shorts.saturatedCast(value); }
public void mergeWith(SetDigest other) { hll.mergeWith(other.hll); LongBidirectionalIterator iterator = other.minhash.keySet().iterator(); while (iterator.hasNext()) { long key = iterator.nextLong(); int count = minhash.get(key) + other.minhash.get(key); minhash.put(key, Shorts.saturatedCast(count)); } while (minhash.size() > maxHashes) { minhash.remove(minhash.lastLongKey()); } }
public void mergeWith(SetDigest other) { hll.mergeWith(other.hll); LongBidirectionalIterator iterator = other.minhash.keySet().iterator(); while (iterator.hasNext()) { long key = iterator.nextLong(); int count = minhash.get(key) + other.minhash.get(key); minhash.put(key, Shorts.saturatedCast(count)); } while (minhash.size() > maxHashes) { minhash.remove(minhash.lastLongKey()); } }