| 138 | } |
| 139 | |
| 140 | void ZVecPySchemas::bind_collection_stats(py::module_ &m) { |
| 141 | pybind11::class_<CollectionStats>(m, "CollectionStats") |
| 142 | .def(pybind11::init<>()) |
| 143 | .def_property_readonly( |
| 144 | "doc_count", [](const CollectionStats &c) { return c.doc_count; }) |
| 145 | .def_property_readonly( |
| 146 | "index_completeness", |
| 147 | [](const CollectionStats &c) { return c.index_completeness; }) |
| 148 | .def("__repr__", [](const CollectionStats &c) { |
| 149 | std::string map_str = "{"; |
| 150 | bool first = true; |
| 151 | for (const auto &[k, v] : c.index_completeness) { |
| 152 | if (!first) map_str += ", "; |
| 153 | map_str += "\"" + k + "\":" + std::to_string(v); |
| 154 | first = false; |
| 155 | } |
| 156 | map_str += "}"; |
| 157 | return "{\"doc_count\":" + std::to_string(c.doc_count) + |
| 158 | ", \"index_completeness\":" + map_str + "}"; |
| 159 | }); |
| 160 | } |
| 161 | |
| 162 | } // namespace zvec |
nothing calls this directly
no test coverage detected