Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[debezium] Change function signature of EncodeDecimal #761

Merged
merged 8 commits into from
Jun 25, 2024

Conversation

nathan-artie
Copy link
Contributor

@nathan-artie nathan-artie commented Jun 25, 2024

EncodeDecimal is only called by Reader in two places, and in one of those places we already have code to determine the scale, which is something we can simplify if we have a apd.Decimal, so rather than depend on Transfer to parse strings into encoded org.apache.kafka.connect.data.Decimals we'll let Reader handle the parsing to apd.Decimal and just let Transfer handle the encoding.


// 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to use int32 for the scale because that's both what apd.Decimal uses as well as the wire representation of org.apache.kafka.connect.data.Decimal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this private?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you are planning to have reader call EncodeDecimal and EncodeDecimalWithScale depending on whether we know the scale or not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reader is going to call both functions in different places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah your second comment didn't show up for me when I responded!

@nathan-artie nathan-artie marked this pull request as ready for review June 25, 2024 22:46
@nathan-artie nathan-artie changed the title [debezium] Change function signature of `EncodeDecimal [debezium] Change function signature of EncodeDecimal Jun 25, 2024
@nathan-artie nathan-artie merged commit d317519 into master Jun 25, 2024
1 check passed
@nathan-artie nathan-artie deleted the nv/change-enc-dec-function-signature branch June 25, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants