-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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. |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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/Serialization/Serializers/BsonVectorSerializer.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
/// <summary> | ||
/// Represents a serializer for <see cref="BsonVectorToCollectionSerializer{TItemCollection, T}"/>. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Co-authored-by: Ferdinando Papale <[email protected]>
No description provided.