[MONGOCRYPT-483] Support decimal128 Created: 12/Sep/22 Updated: 28/Oct/23 Resolved: 19/Jan/23 |
|
| Status: | Closed |
| Project: | Libmongocrypt |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.7.0, 1.7.0-alpha2 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Kevin Albertson | Assignee: | Colby Pike |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Epic Link: | libmongocrypt Support for Range Index | ||||||||||||||||||||
| Binding Changes: | Not Needed | ||||||||||||||||||||
| Server Compat: | 6.2 | ||||||||||||||||||||
| Description |
|
Scope
Background & Motivation Relevant server code is in fle_crypto.cpp This will require a dependency on a decimal128 library. DBX Scope: Driver Support for Range Index suggests "Import libtommath or tomsfastmath or similar to perform int128 math". The server vendors the Intel Decimal Floating-Point Math Library v2.1: https://github.com/mongodb/mongo/tree/master/src/third_party/IntelRDFPMathLib20U1 |
| Comments |
| Comment by Githook User [ 25/Jan/23 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}Message:
This enables the C driver to build with the same CMAKE_BUILD_TYPE as the C driver. On Windows, a matching build type may be required. Mixing debug / release versions of the CRT may be problematic.
|
| Comment by Githook User [ 25/Jan/23 ] |
|
Author: {'name': 'vector-of-bool', 'email': 'vectorofbool@gmail.com', 'username': 'vector-of-bool'}Message:
Co-authored-by: Kevin Albertson <kevin.albertson@mongodb.com> |
| Comment by Githook User [ 25/Jan/23 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}Message:
|
| Comment by Githook User [ 20/Jan/23 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}Message:
This enables the C driver to build with the same CMAKE_BUILD_TYPE as the C driver. On Windows, a matching build type may be required. Mixing debug / release versions of the CRT may be problematic.
|
| Comment by Githook User [ 18/Jan/23 ] |
|
Author: {'name': 'vector-of-bool', 'email': 'vectorofbool@gmail.com', 'username': 'vector-of-bool'}Message:
Co-authored-by: Kevin Albertson <kevin.albertson@mongodb.com> |
| Comment by Githook User [ 18/Jan/23 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}Message:
|
| Comment by Githook User [ 19/Dec/22 ] |
|
Author: {'name': 'vector-of-bool', 'email': 'vectorofbool@gmail.com', 'username': 'vector-of-bool'}Message: This changeset adds a new trivial type mlib_int128, which presents a method of performing 128-bit binary arithmetic. This is a prerequisite to Some platforms, such as 64-bit GCC, provide an __int128 abstraction, but other platforms do not. MSVC and all 32-bit targets do not have such extensions. For this reason, this PR implements 128-bit arithmetic using only standard C99. The implementations of add, sub, the bitshifts, to/from string, compare, and equality are all fairly straightforward extensions of 64-bit operations (with carry/borrow). Multiplication here is implemented using Knuth's 4.3.1M multiplication algorithm (from The Art of Computer Programming). Here 4.3.1M is used to multiply the two low 64-bit words to obtain the 128-bit product. The high word of the result is then adjusted by two more regular 64-bit multiplications. Division is the most complicated operation and took a lot of testing to ensure correct. It uses Knuth's 4.3.1D algorithm for arbitrary precision unsigned division (defined in _mlibKnuth431D). Certain optimizations and shortcuts were learned from the constexpr implementations. Future optimizations to use intrinsics and hardware acceleration are not done here, since we just need these 128-bit integers for a few operations and want guaranteed platform-equivalence. Most of the code has been marked as constexpr, and a lot of functionality is tested via static_asserts for failing CI as-fast-as-possible and immediate IDE feedback. |