[HZ-5510] Introduced number types and removed the default_int_type config - #837
Open
yuce wants to merge 4 commits into
Open
[HZ-5510] Introduced number types and removed the default_int_type config#837yuce wants to merge 4 commits into
yuce wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #837 +/- ##
==========================================
- Coverage 94.21% 94.16% -0.05%
==========================================
Files 413 414 +1
Lines 27646 27688 +42
==========================================
+ Hits 26046 26073 +27
- Misses 1600 1615 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hazelcast has a number of default serializers for numeric types, modeled after the corresponding Java types: signed 8, 16, 32, 64 bit integers, 32 and 64 bit floating point numbers. Go, C++ and .Net clients have corresponding native types, so they are able to serialize numeric values with the intended type. Python and Node.js clients have a different story though.
Python has a single unbounded integer type, and a single floating point type. When a user saves a number using the Python client, it is not immediately apparent which data type is used for storage. Consider the following example:
A configuration based mechanism was used as a workaround to solve this problem, and ensure a number is stored with the intended type. Python Client has the default_int_type configuration which sets the integer type to be used when storing an integer to the cluster. It must be set during client creation, and cannot be changed later:
The obvious problem with this approach is, the integer/number setting is global to a client, and can be set only once. If an application uses different number types, there is no way of storing values with different types using the client.
As I’ve shown, serializing number types is problematic using the Python Client. How about deserialization? The values are deserialized to the expected type:
intso there’s not a problem, unless the user wants to put the same value back to the cluster. That problem is out of scope for this proposal, and a possible solution will be explained in a future proposal.This problem can be easily solved by introducing missing number types. For example, the
hazelcast.Int16class can be used to serialize a value as a 16 bit signed integer:That allows us to remove the
default_int_typefrom configuration and related code. We can keep serializing integers by default as 32 bit signed integers for convenience. So if the user never setsdefault_int_typeother than the default, their code still works as expected.This PR:
default_int_typeconfiguration and related code.Int8,Int16,Int32,Int64,BigInt,Float32,Float64NOTE: Do not mind the link checker failure, they are due to AI-protection mechanism.