PHPC-2474: Support Binary vector subtype#1853
Conversation
There was a problem hiding this comment.
In the python implementation, the Binary class has a from_vector static method. You have certainly considered this solution, of having only a factory method instead of a new class. But the new methods toArray and getVectorType are specific to this binary type, so having a dedicated class makes sense. But if you create a new Binary($raw, Binary::TYPE_VECTOR) instance with the vector type from the raw binary data, you don't have this methods. The current state doesn't allow creating a BinaryVector from raw data. I think you would have to wrap in into a BSON Document and encode/decode it to get a BinaryVector instance. I don't find any other binary type that would require a specific class.
I see 3 possible implementations:
- Add
Binary::fromVector(array $vector, VectorType $vectorType)andtoArray()to the existingBinaryclass CreateBinaryVectorclass that extendsBinary(current state of this PR).CreateBinaryVectorclass that implementsBinaryInterface, \JsonSerializable, Type, \Stringable.
We need to compare pro/con of each solution.
7843292 to
3bf3458
Compare
726240f to
6ffd63d
Compare
4df67fd to
1649670
Compare
|
One failing test appears to be from Atlas connectivity tests failing to connect to a serverless cluster. Per PHPLIB-1667, I expect that should have been removed; however, I don't see a related PHPC ticket. Please review ignoring that particular test failure and I'll address that with a separate PR and ticket. |
alcaeus
left a comment
There was a problem hiding this comment.
LGTM. No objection to adding corpus tests in a follow-up PR.
22ddb35 to
acc9413
Compare
| @@ -0,0 +1,18 @@ | |||
| --TEST-- | |||
| MongoDB\BSON\Binary unserialization requires valid vector data (__serialize and __unserialize) | |||
There was a problem hiding this comment.
Note: this complements bson-binary-set_state_error-004.phpt
acc9413 to
0c56e9f
Compare
0c56e9f to
6bd8a44
Compare
* v2.x: (39 commits) Bump tests/drivers-evergreen-tools from `61cb4e9` to `5514d6a` (#1908) Bump tests/drivers-evergreen-tools from `514927f` to `61cb4e9` (#1906) Bump tests/drivers-evergreen-tools from `ebe98d0` to `514927f` (#1905) PHPC-2649: Update to libmongocrypt 1.17.0 (#1904) PHPC-2654: Update to libmongoc 2.2.1 (#1900) Bump tests/drivers-evergreen-tools from `c92d062` to `ebe98d0` (#1903) Bump actions/cache from 4 to 5 (#1902) Bump tests/drivers-evergreen-tools from `c83e428` to `c92d062` (#1899) Bump tests/drivers-evergreen-tools from `cb019f7` to `c83e428` (#1898) Bump actions/checkout from 5 to 6 (#1895) Bump tests/drivers-evergreen-tools from `f8ab2a5` to `cb019f7` (#1896) PHPC-2634: Binary vector corpus tests (#1892) Bump tests/drivers-evergreen-tools from `1dcbfe4` to `f8ab2a5` (#1891) PHPC-2638 and PHPC-2630: Bump to libmongoc 2.1.2 and libmongocrypt 1.16.0 (#1868) Fix git submodule command in CONTRIBUTING.md PHPC-2627: Use appropriate return type for zend_object_iterator_funcs.valid (#1890) Bump github/codeql-action from 3 to 4 (#1889) Bump tests/drivers-evergreen-tools from `3b3f081` to `1dcbfe4` (#1878) PHPC-2474: Support Binary vector subtype (#1853) Upload test results to codecov.io (#1857) ...
* v2.x: (40 commits) PHPC-2664: Drop Windows x86 builds (#1911) Bump tests/drivers-evergreen-tools from `61cb4e9` to `5514d6a` (#1908) Bump tests/drivers-evergreen-tools from `514927f` to `61cb4e9` (#1906) Bump tests/drivers-evergreen-tools from `ebe98d0` to `514927f` (#1905) PHPC-2649: Update to libmongocrypt 1.17.0 (#1904) PHPC-2654: Update to libmongoc 2.2.1 (#1900) Bump tests/drivers-evergreen-tools from `c92d062` to `ebe98d0` (#1903) Bump actions/cache from 4 to 5 (#1902) Bump tests/drivers-evergreen-tools from `c83e428` to `c92d062` (#1899) Bump tests/drivers-evergreen-tools from `cb019f7` to `c83e428` (#1898) Bump actions/checkout from 5 to 6 (#1895) Bump tests/drivers-evergreen-tools from `f8ab2a5` to `cb019f7` (#1896) PHPC-2634: Binary vector corpus tests (#1892) Bump tests/drivers-evergreen-tools from `1dcbfe4` to `f8ab2a5` (#1891) PHPC-2638 and PHPC-2630: Bump to libmongoc 2.1.2 and libmongocrypt 1.16.0 (#1868) Fix git submodule command in CONTRIBUTING.md PHPC-2627: Use appropriate return type for zend_object_iterator_funcs.valid (#1890) Bump github/codeql-action from 3 to 4 (#1889) Bump tests/drivers-evergreen-tools from `3b3f081` to `1dcbfe4` (#1878) PHPC-2474: Support Binary vector subtype (#1853) ...
* v2.x: (40 commits) PHPC-2664: Drop Windows x86 builds (#1911) Bump tests/drivers-evergreen-tools from `61cb4e9` to `5514d6a` (#1908) Bump tests/drivers-evergreen-tools from `514927f` to `61cb4e9` (#1906) Bump tests/drivers-evergreen-tools from `ebe98d0` to `514927f` (#1905) PHPC-2649: Update to libmongocrypt 1.17.0 (#1904) PHPC-2654: Update to libmongoc 2.2.1 (#1900) Bump tests/drivers-evergreen-tools from `c92d062` to `ebe98d0` (#1903) Bump actions/cache from 4 to 5 (#1902) Bump tests/drivers-evergreen-tools from `c83e428` to `c92d062` (#1899) Bump tests/drivers-evergreen-tools from `cb019f7` to `c83e428` (#1898) Bump actions/checkout from 5 to 6 (#1895) Bump tests/drivers-evergreen-tools from `f8ab2a5` to `cb019f7` (#1896) PHPC-2634: Binary vector corpus tests (#1892) Bump tests/drivers-evergreen-tools from `1dcbfe4` to `f8ab2a5` (#1891) PHPC-2638 and PHPC-2630: Bump to libmongoc 2.1.2 and libmongocrypt 1.16.0 (#1868) Fix git submodule command in CONTRIBUTING.md PHPC-2627: Use appropriate return type for zend_object_iterator_funcs.valid (#1890) Bump github/codeql-action from 3 to 4 (#1889) Bump tests/drivers-evergreen-tools from `3b3f081` to `1dcbfe4` (#1878) PHPC-2474: Support Binary vector subtype (#1853) ...
https://jira.mongodb.org/browse/PHPC-2474