MCPcopy Create free account
hub / github.com/TuGraph-family/tugraph-db / register_python_api

Function register_python_api

src/python/python_api.cpp:136–1891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136void register_python_api(pybind11::module& m) {
137 //======================================
138 // Register data types
139 //======================================
140 pybind11::class_<FieldSpec> field(m, "FieldSpec", "Field specification.");
141 field.def(pybind11::init<>())
142 .def(pybind11::init<const std::string&, FieldType, bool>(),
143 "Defines a FieldSpec with its name (type:str), type "
144 "(type:FieldType) and nullable (type:bool).",
145 pybind11::arg("name"), pybind11::arg("type"), pybind11::arg("nullable"),
146 pybind11::call_guard<SignalsGuard>())
147 .def_readwrite("name", &FieldSpec::name, "Name of this field.")
148 .def_readwrite("type", &FieldSpec::type,
149 "Type of this field, INT8, INT16, ..., POINT, LINESTRING,"
150 "POLYGON, SPATIAL, FLOAT_VECTOR")
151 .def_readwrite("nullable", &FieldSpec::optional, "Whether this field can be null.")
152 .def("__repr__", [](const FieldSpec& a) {
153 return fma_common::StringFormatter::Format("(name:{}, type:{}, nullable:{})", a.name,
154 a.type, a.optional);
155 });
156
157 pybind11::class_<EdgeUid>(m, "EdgeUid", "Edge identifier.")
158 .def(pybind11::init<>(),
159 pybind11::call_guard<SignalsGuard>())
160 .def(pybind11::init<int64_t, int64_t, uint16_t, int64_t, int64_t>(),
161 "Defines a EdgeUid with (src_id, dst_id, label_id, primary_id, edge_id).",
162 pybind11::arg("src_id"), pybind11::arg("dst_id"), pybind11::arg("label_id"),
163 pybind11::arg("primary_id"), pybind11::arg("edge_id"),
164 pybind11::call_guard<SignalsGuard>())
165 .def_readwrite("src", &EdgeUid::src, "Source vertex ID.")
166 .def_readwrite("dst", &EdgeUid::dst, "Destination vertex ID.")
167 .def_readwrite("lid", &EdgeUid::lid, "Label ID of the edge.")
168 .def_readwrite("tid", &EdgeUid::tid, "Temporal ID of the edge.")
169 .def_readwrite("eid", &EdgeUid::eid, "ID of the edge.")
170 .def("__repr__",
171 [](const EdgeUid& a) {
172 return fma_common::StringFormatter::Format(
173 "(src:{}, dst:{}, lid:{}, tid:{}, eid:{})", a.src, a.dst, a.lid, a.tid,
174 a.eid);
175 })
176 .def("__str__", [](const EdgeUid& a) {
177 return fma_common::StringFormatter::Format("{}_{}_{}_{}_{}", a.src, a.dst, a.lid, a.tid,
178 a.eid);
179 });
180
181 pybind11::enum_<lgraph_api::IndexType>(m, "IndexType")
182 .value("NonuniqueIndex", IndexType::NonuniqueIndex, "NonuniqueIndex")
183 .value("GlobalUniqueIndex", IndexType::GlobalUniqueIndex, "GlobalUniqueIndex")
184 .value("PairUniqueIndex", IndexType::PairUniqueIndex, "PairUniqueIndex")
185 .export_values();
186
187 pybind11::class_<IndexSpec>(m, "IndexSpec", "Index specification.")
188 .def(pybind11::init<>(),
189 pybind11::call_guard<SignalsGuard>())
190 .def(pybind11::init<const std::string&, const std::string&, IndexType>(),
191 "Defines an IndexSpec with its label_name:str, field_name:str and "
192 "type:int.",
193 pybind11::arg("label_name"), pybind11::arg("field_name"), pybind11::arg("type"),

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 15

FieldDataToPyObjFunction · 0.85
ObjectToFieldDataFunction · 0.85
PointClass · 0.85
LineStringClass · 0.85
PolygonClass · 0.85
SpatialClass · 0.85
PyDictToVectorsFunction · 0.85
FieldDataVectorToPyListFunction · 0.85
FieldDataMapToPyDictFunction · 0.85
ConvertToLocalMethod · 0.80
TimePointMethod · 0.80
ConvertToUTCMethod · 0.80

Tested by

no test coverage detected