Skip to content

Conversation

@gagik
Copy link
Contributor

@gagik gagik commented Apr 1, 2025

Add friendlier support for displaying BSON binary vector types in mongosh by displaying them as reproducable Binary constructor calls.
Screenshot 2025-04-03 at 1 19 53 AM

@gagik gagik force-pushed the gagik/add-binary-types branch from 084e52c to d93774d Compare April 2, 2025 14:48
depth,
...options,
// These arrays can be very large, so would prefer to use the default options instead.
maxArrayLength: utilInspect.defaultOptions.maxArrayLength,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we want this, could remove. it just seems possible that these arrays can be very large I'd imagine so the {maxArrayLength: Infinity} that we're getting from

return formatCursor(value, { ...options, ...fullDepthInspectOptions });
can be problematic

)
).matches(
// Precision is lost because of float handling, so we use regex to match
/Binary.fromFloat32Array\(new Float32Array\(\[ 1\.1\d*, 2\.2\d*, 3\.3\d* \]\)\)/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we're meant to be dealing with float precision weirdness in JS in this case. can definitely see how it'd be weird to see imprecise floats while trying to inspect data. we could do something like https://github.com/mongodb-js/compass/pull/6834/files#diff-3d4b298fbb2cfe42467edc59277483eb9bcfdc46b07ea658ab3dc4f66903da88R174

@gagik gagik changed the title WIP feat(service-provider-core): support new BSON vector types in mongosh MONGOSH-1873 feat(service-provider-core): support new BSON vector types in mongosh MONGOSH-1873 Apr 2, 2025
@gagik gagik marked this pull request as ready for review April 2, 2025 23:16
@gagik gagik force-pushed the gagik/add-binary-types branch 2 times, most recently from 89ba28e to ad3efe5 Compare April 2, 2025 23:31
@gagik gagik requested review from addaleax and kraenhansen April 3, 2025 08:20
Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! 🚀

return binaryInspect.apply(this, args);
}
},
} satisfies CustomInspectFunction,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💙

@gagik gagik force-pushed the gagik/add-binary-types branch 2 times, most recently from 85d942b to 93b6028 Compare April 3, 2025 15:46
@gagik gagik force-pushed the gagik/add-binary-types branch from 93b6028 to 8d7c10e Compare April 3, 2025 15:49
@gagik gagik merged commit 999208b into main Apr 3, 2025
12 of 13 checks passed
@gagik gagik deleted the gagik/add-binary-types branch April 3, 2025 15:49
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.

3 participants