Skip to content

Conversation

caseyclements
Copy link
Contributor

@caseyclements caseyclements commented Apr 3, 2025

Please complete the following before merging:

  • Update changelog.
  • Test changes in at least one language driver.
  • Test these changes against all server versions and topologies (including standalone, replica set, sharded
    clusters, and serverless).

@caseyclements caseyclements requested a review from a team as a code owner April 3, 2025 23:10
@caseyclements caseyclements requested review from dariakp and removed request for a team April 3, 2025 23:10
@caseyclements
Copy link
Contributor Author

mongo-python-driver pull-request #2261

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -184,6 +184,7 @@ Drivers MUST validate vector metadata and raise an error if any invariant is vio

- Padding MUST be 0 for all dtypes where padding doesn’t apply, and MUST be within \[0, 7\] for PACKED_BIT.
- A PACKED_BIT vector MUST NOT be empty if padding is in the range \[1, 7\].
- For a PACKED_BIT vector, bits lower than the given padding (those ignored) must be zero.
Copy link

Choose a reason for hiding this comment

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

For what it's worth, it could be helpful adding some specificity about bit order here since the description is correct only if bits are interpreted in the opposite order used for packed_bit encoding. (packed_bit is otherwise MSB first, but this is referring to the LSB as 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to. Would you please suggest a short alternative? Any longer description that you'd like to make should be done in a new PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest rewording to avoid "lower":

Suggested change
- For a PACKED_BIT vector, bits lower than the given padding (those ignored) must be zero.
- For a PACKED_BIT vector, ignored bits must be zero.

I expect the phrase "The least-significant bits are ignored." above clarifies which bits are ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @kevinAlbs. Updated.

Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

Thank you for the change.

@@ -184,6 +184,7 @@ Drivers MUST validate vector metadata and raise an error if any invariant is vio

- Padding MUST be 0 for all dtypes where padding doesn’t apply, and MUST be within \[0, 7\] for PACKED_BIT.
- A PACKED_BIT vector MUST NOT be empty if padding is in the range \[1, 7\].
- For a PACKED_BIT vector, bits lower than the given padding (those ignored) must be zero.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for Encoding and Decoding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. That's what we came to, and exceptions are thrown in the Python implementation in both cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, it's specified a few lines after:
Drivers MUST perform this validation when...

@caseyclements caseyclements requested review from kevinAlbs and a user April 8, 2025 12:59
Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM with a test expectation fix and suggested rewording.

@@ -184,6 +184,7 @@ Drivers MUST validate vector metadata and raise an error if any invariant is vio

- Padding MUST be 0 for all dtypes where padding doesn’t apply, and MUST be within \[0, 7\] for PACKED_BIT.
- A PACKED_BIT vector MUST NOT be empty if padding is in the range \[1, 7\].
- For a PACKED_BIT vector, bits lower than the given padding (those ignored) must be zero.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest rewording to avoid "lower":

Suggested change
- For a PACKED_BIT vector, bits lower than the given padding (those ignored) must be zero.
- For a PACKED_BIT vector, ignored bits must be zero.

I expect the phrase "The least-significant bits are ignored." above clarifies which bits are ignored.

@@ -18,26 +18,35 @@
"dtype_hex": "0x10",
"dtype_alias": "PACKED_BIT",
"padding": 0,
"canonical_bson": "1600000005766563746F7200040000000910007F0700"
"canonical_bson": "1600000005766563746F7200040000000910007F0800"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"canonical_bson": "1600000005766563746F7200040000000910007F0800"
"canonical_bson": "1600000005766563746F7200040000000910007F0700"

@dariakp dariakp requested review from nbbeeken and removed request for dariakp April 8, 2025 20:10
Copy link
Member

@vbabanin vbabanin left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

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

LGTM

@caseyclements caseyclements merged commit 43d2c7b into mongodb:master Apr 9, 2025
5 checks passed
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.

5 participants