Skip to content

Conversation

@muskan124947
Copy link
Contributor

@muskan124947 muskan124947 commented Nov 26, 2025

Description

For upcoming VECTOR_FLOAT16 support in the Microsoft JDBC Driver for SQL Server, this change introduces complete serialization and deserialization logic for half-precision floating-point values used inside vector columns.

The driver performs IEEE-754–compliant bidirectional conversion between standard Java Float[] (FLOAT32, 4 bytes) and the compact FLOAT16 (2 bytes) wire format. Applications continue interacting with Float[], while the driver transparently handles precision conversion depending on the negotiated vector type.

Data Flow

Direction Client Representation Wire Representation Conversion Performed
Write (Client → Server) Float[] (4 bytes each) FLOAT16 (2 bytes each) 32-bit → 16-bit
Read (Server → Client) FLOAT16 (2 bytes each) Float[] (4 bytes each) 16-bit → 32-bit

Conversions Added

  • floatToFloat16() : Converts a 32-bit float into its IEEE-754 half-precision (16-bit) representation, applying correct rounding, overflow handling, and encoding of NaN/Infinity.
  • float16ToFloat() : Converts a 16-bit half-precision value back into a 32-bit float, preserving sign, exponent, and all special values.
  • serializeFloat16Array() : Converts a Float[] into a compact byte array by encoding each element as float16, including support for null markers and special floating-point values.
  • deserializeFloat16Array() : Converts a float16 byte array back into a Float[], restoring each element to its 32-bit float form with correct decoding of NaN, Infinity, and nulls.

Motivation

This enhancement enables efficient storage and transmission of VECTOR_FLOAT16 data between Java applications and SQL Server, providing a foundation for vector search, embeddings, and machine-learning workflows that benefit from reduced memory footprint.

@muskan124947 muskan124947 self-assigned this Nov 26, 2025
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 81.81818% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.44%. Comparing base (caef383) to head (93fc891).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...java/com/microsoft/sqlserver/jdbc/VectorUtils.java 81.81% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2853      +/-   ##
============================================
+ Coverage     56.36%   56.44%   +0.08%     
- Complexity     4523     4559      +36     
============================================
  Files           151      151              
  Lines         34442    34511      +69     
  Branches       5738     5758      +20     
============================================
+ Hits          19412    19480      +68     
- Misses        12408    12413       +5     
+ Partials       2622     2618       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@muskan124947 muskan124947 merged commit 652d4b9 into main Dec 1, 2025
19 checks passed
@muskan124947 muskan124947 added this to the 13.3.1 milestone Dec 1, 2025
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.

4 participants