Package org.apache.kafka.connect.data
Class Decimal
java.lang.Object
org.apache.kafka.connect.data.Decimal
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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
Convert a value from its encoded format (byte[]) to its logical format (BigDecimal
).
-
Field Details
-
LOGICAL_NAME
- See Also:
-
SCALE_FIELD
- See Also:
-
-
Constructor Details
-
Decimal
public Decimal()
-
-
Method Details
-
builder
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
-
fromLogical
Convert a value from its logical format (BigDecimal
) to its encoded format (byte[]).- Parameters:
value
- the logical value- Returns:
- the encoded value
-
toLogical
Convert a value from its encoded format (byte[]) to its logical format (BigDecimal
).- Parameters:
value
- the encoded value- Returns:
- the logical value
-