Skip to content

Conversation

@kraenhansen
Copy link
Contributor

@kraenhansen kraenhansen commented Apr 2, 2025

Description

As is

Screenshot 2025-04-02 at 10 42 31

Suggested to be

Screenshot 2025-04-02 at 16 05 46

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

The table view for this is not awesome, but we would have to revisit either the principle of showing copy-pastable code in the cells or the driver API to improve that.

Screenshot 2025-04-02 at 16 09 19 ](url)

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@kraenhansen kraenhansen self-assigned this Apr 2, 2025
@kraenhansen kraenhansen requested a review from Copilot April 2, 2025 09:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds special handling for BSON Binary values with the vector sub-type, specifically addressing different vector types (Int8, Float32, and PackedBit) by formatting their serialized representations.

  • Introduces a new branch for values with the Binary.SUBTYPE_VECTOR
  • Implements separate formatting logic for Int8, Float32, and PackedBit vectors
Comments suppressed due to low confidence (1)

packages/compass-components/src/components/bson-value.tsx:190

  • The vector handling block does not explicitly handle unexpected vector types. Consider adding an 'else' clause to safely manage vector types that are not Int8, Float32, or PackedBit.
}

const vectorType = value.buffer[0];
if (vectorType === Binary.VECTOR_TYPE.Int8) {
const truncatedSerializedBuffer = truncate(
value.toInt8Array().slice(0, 100).toString(),
Copy link

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Relying on the default toString() conversion for arrays may lead to inconsistent formatting. Consider using a method like join(', ') for clearer and more predictable output.

Suggested change
value.toInt8Array().slice(0, 100).toString(),
value.toInt8Array().slice(0, 100).join(', '),

Copilot uses AI. Check for mistakes.
@kraenhansen kraenhansen force-pushed the kh/display-binary-vector-sub-type-8257 branch from 5139d5e to 6c66e57 Compare April 2, 2025 09:52
@kraenhansen kraenhansen requested a review from gagik April 2, 2025 10:05
@lerouxb lerouxb changed the title Add special handling of vector sub-type COMPASS-8257 feat: add special handling of vector sub-type COMPASS-8257 Apr 2, 2025
@github-actions github-actions bot added the feat label Apr 2, 2025
@gagik gagik marked this pull request as ready for review April 4, 2025 08:40
@gagik
Copy link
Contributor

gagik commented Apr 4, 2025

Going to take over to get this finalized.

@gagik gagik merged commit 7b8af62 into main Apr 4, 2025
66 checks passed
@gagik gagik deleted the kh/display-binary-vector-sub-type-8257 branch April 4, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants