deephaven / deephaven-core

Deephaven Community Core
Other
236 stars 79 forks source link

Null-safe wrapper for toIntExact #5639

Open rbasralian opened 2 weeks ago

rbasralian commented 2 weeks ago

We should have a statically-imported wrapper for toIntExact() so that you can safely truncate longs to ints, with support for nulls.

Regular long-to-int cast are handled by io.deephaven.engine.table.impl.lang.QueryLanguageFunctionUtils#intCast(long), but we don't handle values that overflow int. And if you call java.lang.Math#toIntExact directly, NULL_LONG isn't handled.

devinrsmith commented 2 weeks ago

Likely makes sense to consider toShortExact and toByteExact in the same scope.