Package org.apache.kafka.connect.data
Class Decimal
- java.lang.Object
-
- org.apache.kafka.connect.data.Decimal
-
public class Decimal extends Object
An arbitrary-precision signed decimal number. The value is unscaled * 10 ^ -scale where:
- unscaled is an integer
- scale is an integer representing how many digits the decimal point should be shifted on the unscaled value
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
-
-
Field Summary
Fields Modifier and Type Field Description static String
LOGICAL_NAME
static String
SCALE_FIELD
-
Constructor Summary
Constructors Constructor Description Decimal()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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 it's encoded format.static Schema
schema(int scale)
static BigDecimal
toLogical(Schema schema, byte[] value)
-
-
-
Field Detail
-
LOGICAL_NAME
public static final String LOGICAL_NAME
- See Also:
- Constant Field Values
-
SCALE_FIELD
public static final String SCALE_FIELD
- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static SchemaBuilder builder(int scale)
Returns a SchemaBuilder for a Decimal with the given scale factor. By returning a SchemaBuilder you can override additional schema settings such as required/optional, default value, and documentation.- Parameters:
scale
- the scale factor to apply to unscaled values- Returns:
- a SchemaBuilder
-
schema
public static Schema schema(int scale)
-
fromLogical
public static byte[] fromLogical(Schema schema, BigDecimal value)
Convert a value from its logical format (BigDecimal) to it's encoded format.- Parameters:
value
- the logical value- Returns:
- the encoded value
-
toLogical
public static BigDecimal toLogical(Schema schema, byte[] value)
-
-