public class TruncateUtil
extends java.lang.Object
truncate
transformations for various types.
This utility class allows for the logic to be reused in different scenarios where input validation is done at different times either in org.apache.iceberg.transforms.Truncate and within defined SQL functions for different compute engines for usage in SQL.
In general, the inputs to the functions should have already been validated by the calling code, as different classes use truncate with different preprocessing. This generally means that the truncation width is positive and the value to truncate is non-null.
Thus, none of these utility functions validate their input. It is the responsibility of the calling code to validate input.
See also UnicodeUtil.truncateString(CharSequence, int) and BinaryUtil.truncateBinaryUnsafe(ByteBuffer, int)
for similar methods for Strings and
ByteBuffers.
Modifier and Type | Method and Description |
---|---|
static byte |
truncateByte(int width,
byte value) |
static java.math.BigDecimal |
truncateDecimal(java.math.BigInteger unscaledWidth,
java.math.BigDecimal value) |
static int |
truncateInt(int width,
int value) |
static long |
truncateLong(int width,
long value) |
static short |
truncateShort(int width,
short value) |
public static byte truncateByte(int width, byte value)
public static short truncateShort(int width, short value)
public static int truncateInt(int width, int value)
public static long truncateLong(int width, long value)
public static java.math.BigDecimal truncateDecimal(java.math.BigInteger unscaledWidth, java.math.BigDecimal value)