public class Decimal extends Object
An arbitrary-precision signed decimal number. The value is unscaled * 10 ^ -scale where:
Decimal does not provide a fixed schema because it is parameterized by the scale, which is fixed on the schema rather than being part of the value.
The underlying representation of this type is bytes containing a two's complement integer
Modifier and Type | Field and Description |
---|---|
static String |
LOGICAL_NAME |
static String |
SCALE_FIELD |
Constructor and Description |
---|
Decimal() |
Modifier and Type | Method and Description |
---|---|
static SchemaBuilder |
builder(int scale)
Returns a SchemaBuilder for a Decimal with the given scale factor.
|
static byte[] |
fromLogical(Schema schema,
BigDecimal value)
Convert a value from its logical format (
BigDecimal ) to its encoded format (byte[]). |
static Schema |
schema(int scale) |
static BigDecimal |
toLogical(Schema schema,
byte[] value)
Convert a value from its encoded format (byte[]) to its logical format (
BigDecimal ). |
public static final String LOGICAL_NAME
public static final String SCALE_FIELD
public static SchemaBuilder builder(int scale)
scale
- the scale factor to apply to unscaled valuespublic static Schema schema(int scale)
public static byte[] fromLogical(Schema schema, BigDecimal value)
BigDecimal
) to its encoded format (byte[]).value
- the logical valuepublic static BigDecimal toLogical(Schema schema, byte[] value)
BigDecimal
).value
- the encoded value