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

Method Initialize

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

Source from the content-addressed store, hash-verified

48}
49
50void 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
73void ZVecPyCollection::bind_db_methods(
74 py::class_<Collection, Collection::Ptr> &col) {

Callers

nothing calls this directly

Calls 5

unwrap_expectedFunction · 0.85
PathMethod · 0.80
SchemaMethod · 0.80
OptionsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected