-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Add basic vector type #2866
Add basic vector type #2866
Conversation
This adds the new MySQL 9.0 vector type. It can still be handled like a binary blob for now I think. Maybe it's worth in the future to directly decode / parse it into an array of floats here? Signed-off-by: Dirkjan Bussink <[email protected]>
See https://dev.mysql.com/doc/dev/mysql-server/latest/field__types_8h.html also for the constant value here. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2866 +/- ##
=======================================
Coverage 88.18% 88.18%
=======================================
Files 71 71
Lines 12874 12875 +1
Branches 1350 1351 +1
=======================================
+ Hits 11353 11354 +1
Misses 1521 1521
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
hey @dbussink do you have any pointers to documentation on how the value is transmitted over the wire? Or maybe you can help with some examples I can run and try to reverse engineer serialisation format. Happy to merge without detailed deserealizing, we can tackle that later |
@sidorares, can we include a symbolic commit to release it? Also, to include it in change logs. Or if you prefer, we can wait until a next release to bring this update along, but it won't be included in the logs. |
See https://dev.mysql.com/doc/refman/9.0/en/vector.html and if you look in the MySQL CLI, it's a binary blob of data. It's always a multiple of 4 bytes, since it's up to |
@wellwelwel sorry I should've updated commit to have |
So it might be as simple as doing |
yes, connection.execute(`SELECT TO_VECTOR("[1.05, -17.8, 32, 123.456]")`, (err, res) => {
if (err) throw err;
const buf = Object.values(res[0])[0];
let offset = 0;
while (offset < buf.length) {
const v = buf.readFloatLE(offset);
console.log(v);
offset += 4;
}
connection.end();
}); prints
|
This adds the new MySQL 9.0 vector type. It can still be handled like a binary blob for now I think. Maybe it's worth in the future to directly decode / parse it into an array of floats here?