| 48 | } |
| 49 | |
| 50 | void ZVecPyCollection::Initialize(pybind11::module_ &m) { |
| 51 | py::class_<Collection, Collection::Ptr> collection(m, "_Collection"); |
| 52 | bind_db_methods(collection); |
| 53 | bind_ddl_methods(collection); |
| 54 | bind_dml_methods(collection); |
| 55 | bind_dql_methods(collection); |
| 56 | collection.def(py::pickle( |
| 57 | [](const Collection &c) { |
| 58 | return py::make_tuple(c.Path(), c.Schema(), c.Options()); |
| 59 | }, |
| 60 | [](py::tuple t) { |
| 61 | if (t.size() != 3) { |
| 62 | throw std::runtime_error("Invalid tuple size for Collection pickle"); |
| 63 | } |
| 64 | std::string path = t[0].cast<std::string>(); |
| 65 | auto schema = t[1].cast<CollectionSchema>(); |
| 66 | CollectionOptions options = t[2].cast<CollectionOptions>(); |
| 67 | auto result = Collection::Open(path, options); |
| 68 | // auto result = Collection::CreateAndOpen(path, schema, options); |
| 69 | return unwrap_expected(result); |
| 70 | })); |
| 71 | } |
| 72 | |
| 73 | void ZVecPyCollection::bind_db_methods( |
| 74 | py::class_<Collection, Collection::Ptr> &col) { |
nothing calls this directly
no test coverage detected