-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support Float as primary key for Mysql source #3016
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
base: main
Are you sure you want to change the base?
Changes from all commits
ce14361
efa4fa6
10492ef
ad36de1
ac745f9
78feca2
66a089c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -67,6 +67,11 @@ public class BoundarySplitterFactory { | |||
| (BoundarySplitter<Timestamp>) | ||||
| (start, end, partitionColumn, boundaryTypeMapper, processContext) -> | ||||
| splitTimestamps(start, end)) | ||||
| .put( | ||||
| Float.class, | ||||
| (BoundarySplitter<Float>) | ||||
| (start, end, partitionColumn, boundaryTypeMapper, processContext) -> | ||||
| splitFloats(start, end)) | ||||
| .build(); | ||||
|
|
||||
| /** | ||||
|
|
@@ -263,4 +268,29 @@ protected static Timestamp instantToTimestamp(Instant instant) { | |||
| private static Timestamp splitTimestamps(Timestamp start, Timestamp end) { | ||||
| return instantToTimestamp(splitInstants(timeStampToInstant(start), timeStampToInstant(end))); | ||||
| } | ||||
|
|
||||
| private static Float splitFloats(Float start, Float end) { | ||||
| if (start == null && end == null) { | ||||
| return null; | ||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BoundarySplitter interface comments does not specify what should be the behavior when both start and end parameters are null :
Line 40 in ef38a80
For consistency, I then followed the behavior used by other split functions:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right. |
||||
| } | ||||
| if (start == null) { | ||||
| start = -Float.MAX_VALUE; | ||||
| } | ||||
| if (end == null) { | ||||
| end = Float.MAX_VALUE; | ||||
| } | ||||
|
|
||||
| // Calculate overflow safe mid-point | ||||
|
|
||||
| // If signs are different, simple addition is safe from overflow | ||||
| // because the values cancel each other out towards zero. | ||||
| if ((start < 0 && end > 0) || (start > 0 && end < 0)) { | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For float and double we also need to enhance isSplittable to stop the splitting at appropriate precision. |
||||
| return (start + end) / 2.0f; | ||||
| } | ||||
|
|
||||
| // If signs are the same (both positive or both negative), | ||||
| // we use the offset formula to prevent overflow (Infinity). | ||||
| // This works regardless of whether start > end or start < end. | ||||
| return start + (end - start) / 2.0f; | ||||
| } | ||||
| } | ||||
Uh oh!
There was an error while loading. Please reload this page.