Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie committed Jun 26, 2024
1 parent 4b3327c commit 8ab7bf0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/debezium/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func decimalWithNewExponent(decimal *apd.Decimal, newExponent int32) *apd.Decima
}
}

// EncodeDecimal is used to encode a [*apd.Decimal] to [org.apache.kafka.connect.data.Decimal].
// EncodeDecimal is used to encode a [*apd.Decimal] to `org.apache.kafka.connect.data.Decimal`.
// The scale of the value (which is the negated exponent of the decimal) is returned as the second argument.
func EncodeDecimal(decimal *apd.Decimal) ([]byte, int32) {
bigIntValue := decimal.Coeff.MathBigInt()
Expand All @@ -99,7 +99,7 @@ func EncodeDecimal(decimal *apd.Decimal) ([]byte, int32) {
return encodeBigInt(bigIntValue), -decimal.Exponent
}

// EncodeDecimalWithScale is used to encode a [*apd.Decimal] to [org.apache.kafka.connect.data.Decimal]
// EncodeDecimalWithScale is used to encode a [*apd.Decimal] to `org.apache.kafka.connect.data.Decimal`
// using a specific scale.
func EncodeDecimalWithScale(decimal *apd.Decimal, scale int32) []byte {
targetExponent := -scale // Negate scale since [Decimal.Exponent] is negative.
Expand All @@ -110,7 +110,7 @@ func EncodeDecimalWithScale(decimal *apd.Decimal, scale int32) []byte {
return bytes
}

// DecodeDecimal is used to decode [org.apache.kafka.connect.data.Decimal].
// DecodeDecimal is used to decode `org.apache.kafka.connect.data.Decimal`.
func DecodeDecimal(data []byte, scale int32) *apd.Decimal {
return apd.NewWithBigInt(new(apd.BigInt).SetMathBigInt(decodeBigInt(data)), -scale)
}

0 comments on commit 8ab7bf0

Please sign in to comment.