MCPcopy Create free account
hub / github.com/alibaba/zvec / Initialize

Method Initialize

src/binding/python/model/python_collection.cc:115–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void 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
144void ZVecPyCollection::bind_db_methods(
145 py::class_<Collection, Collection::Ptr> &col) {

Callers

nothing calls this directly

Calls 5

unwrap_expectedFunction · 0.85
pathMethod · 0.45
schemaMethod · 0.45
optionsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected