Skip to content
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

CSHARP-5202: BSON Binary Vector Subtype Support #1581

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

BorisDog
Copy link
Contributor

No description provided.

@BorisDog BorisDog requested a review from a team as a code owner December 27, 2024 00:28
@BorisDog BorisDog requested review from JamesKovacs, papafe and sanych-sun and removed request for a team and JamesKovacs December 27, 2024 00:28
Copy link
Contributor

@papafe papafe left a comment

Choose a reason for hiding this comment

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

Overall it makes sense, I just got some notes/questions

}

/// <summary>
/// Represents a vector of bit values.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use the term "packed bit"?

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, rephrased.

src/MongoDB.Bson/ObjectModel/BsonVector.cs Outdated Show resolved Hide resolved
}

/// <summary>
/// Represents a serializer for <see cref="BsonVectorToCollectionSerializer{TItemCollection, T}"/>.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the wrong type

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, fixed.

_ => throw new ArgumentOutOfRangeException(nameof(bsonVectorDataType), bsonVectorDataType, "Unsupported vector datatype.")
};

if (!supportedTypes.Contains(typeof(T)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't supportedTypes always a list with one element? Do we expect it to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I think we should plan to support other types of avoid double conversion.
But for now I've removed the array, so we don't have such "dead code".

}
else
{
throw new NotSupportedException("Little Endian architecture is not supported yet.");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this exception should be referencing "Big Endian" instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

{
case BsonVectorDataType.Float32:
{
if (elements is not float[] floatArray)
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this already verified by the Validate method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically yes. But for minimizing the chance for future bugs and for completeness, I'd prefer to validate the input again.
Also technically this method can be reused outside the current scope and decoupled from ValidateDataType.

Made it private.

BorisDog and others added 2 commits January 2, 2025 14:59
Co-authored-by: Ferdinando Papale <[email protected]>
@BorisDog BorisDog requested a review from papafe January 2, 2025 23:00
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.

2 participants