| 113 | } |
| 114 | |
| 115 | void ZVecPyCollection::Initialize(pybind11::module_ &m) { |
| 116 | py::class_<GroupResult>(m, "_GroupResult") |
| 117 | .def_readonly("group_by_value", &GroupResult::group_by_value_) |
| 118 | .def_readonly("docs", &GroupResult::docs_); |
| 119 | |
| 120 | bind_iterator(m); |
| 121 | |
| 122 | py::class_<Collection, Collection::Ptr> collection(m, "_Collection"); |
| 123 | bind_db_methods(collection); |
| 124 | bind_ddl_methods(collection); |
| 125 | bind_dml_methods(collection); |
| 126 | bind_dql_methods(collection); |
| 127 | collection.def(py::pickle( |
| 128 | [](const Collection &c) { |
| 129 | return py::make_tuple(c.path(), c.schema(), c.options()); |
| 130 | }, |
| 131 | [](py::tuple t) { |
| 132 | if (t.size() != 3) { |
| 133 | throw std::runtime_error("Invalid tuple size for Collection pickle"); |
| 134 | } |
| 135 | std::string path = t[0].cast<std::string>(); |
| 136 | auto schema = t[1].cast<CollectionSchema>(); |
| 137 | CollectionOptions options = t[2].cast<CollectionOptions>(); |
| 138 | auto result = Collection::Open(path, options); |
| 139 | // auto result = Collection::CreateAndOpen(path, schema, options); |
| 140 | return unwrap_expected(result); |
| 141 | })); |
| 142 | } |
| 143 | |
| 144 | void ZVecPyCollection::bind_db_methods( |
| 145 | py::class_<Collection, Collection::Ptr> &col) { |
nothing calls this directly
no test coverage detected