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

Function FieldDataToPyObj

src/python/python_api.cpp:83–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83inline pybind11::object FieldDataToPyObj(const FieldData& data) {
84 switch (data.type) {
85 case FieldType::NUL:
86 return pybind11::none();
87 case FieldType::BOOL:
88 return pybind11::bool_(data.data.boolean);
89 case FieldType::INT8:
90 return pybind11::int_(data.data.int8);
91 case FieldType::INT16:
92 return pybind11::int_(data.data.int16);
93 case FieldType::INT32:
94 return pybind11::int_(data.data.int32);
95 case FieldType::INT64:
96 return pybind11::int_(data.data.int64);
97 case FieldType::FLOAT:
98 return pybind11::float_(data.data.sp);
99 case FieldType::DOUBLE:
100 return pybind11::float_(data.data.dp);
101 case FieldType::DATE:
102 return pybind11::cast(
103 data.AsDate().operator lgraph_api::DateTime().ConvertToUTC().TimePoint());
104 case FieldType::DATETIME:
105 return pybind11::cast(data.AsDateTime().ConvertToUTC().TimePoint());
106 case FieldType::STRING:
107 return pybind11::str(*data.data.buf);
108 case FieldType::BLOB:
109 return pybind11::bytes(*data.data.buf);
110 case FieldType::POINT:
111 case FieldType::LINESTRING:
112 case FieldType::POLYGON:
113 case FieldType::SPATIAL:
114 return pybind11::str(*data.data.buf);
115 case FieldType::FLOAT_VECTOR:
116 return pybind11::cast(data.AsFloatVector());
117 }
118 FMA_ASSERT(false);
119 return pybind11::none();
120}
121
122inline pybind11::list FieldDataVectorToPyList(const std::vector<FieldData>& v) {
123 pybind11::list l;

Callers 3

FieldDataVectorToPyListFunction · 0.85
FieldDataMapToPyDictFunction · 0.85
register_python_apiFunction · 0.85

Calls 5

TimePointMethod · 0.80
ConvertToUTCMethod · 0.80
AsDateMethod · 0.45
AsDateTimeMethod · 0.45
AsFloatVectorMethod · 0.45

Tested by

no test coverage detected