| 208 | } |
| 209 | |
| 210 | codegen::ParamConst variable_to_param_const(const common::Variable& var, |
| 211 | BuildingContext& ctx) { |
| 212 | codegen::ParamConst param_const; |
| 213 | if (var.has_property()) { |
| 214 | auto& var_property = var.property(); |
| 215 | if (var_property.has_label()) { |
| 216 | param_const.var_name = "label"; |
| 217 | param_const.expr_var_name = "label"; |
| 218 | param_const.type = codegen::DataType::kLabelId; |
| 219 | } else if (var_property.has_key()) { |
| 220 | param_const.var_name = var.property().key().name(); |
| 221 | param_const.expr_var_name = var.property().key().name(); |
| 222 | param_const.type = |
| 223 | common_data_type_pb_2_data_type(var.node_type().data_type()); |
| 224 | } else if (var_property.has_id()) { |
| 225 | param_const.var_name = ctx.GetNextVarName(); |
| 226 | param_const.expr_var_name = ctx.GetNextVarName(); |
| 227 | param_const.type = codegen::DataType::kGlobalVertexId; |
| 228 | } else { |
| 229 | LOG(FATAL) << "Unexpected property type: " << var_property.DebugString(); |
| 230 | } |
| 231 | } else { // var.tag() could be null or not |
| 232 | // check is vertex or is edge from node_type |
| 233 | if (var.has_node_type()) { |
| 234 | auto node_type = var.node_type(); |
| 235 | param_const.var_name = ctx.GetNextVarName(); |
| 236 | param_const.expr_var_name = param_const.var_name; |
| 237 | if (node_type.type_case() == common::IrDataType::kDataType) { |
| 238 | param_const.type = |
| 239 | common_data_type_pb_2_data_type(node_type.data_type()); |
| 240 | } else { |
| 241 | auto graph_type = node_type.graph_type(); |
| 242 | if (graph_type.element_opt() == |
| 243 | common::GraphDataType::GraphElementOpt:: |
| 244 | GraphDataType_GraphElementOpt_VERTEX) { |
| 245 | param_const.type = codegen::DataType::kGlobalVertexId; |
| 246 | } else if (graph_type.element_opt() == |
| 247 | common::GraphDataType::GraphElementOpt:: |
| 248 | GraphDataType_GraphElementOpt_EDGE) { |
| 249 | param_const.type = codegen::DataType::kEdgeId; |
| 250 | } else { |
| 251 | LOG(FATAL) << "Unexpect graph type"; |
| 252 | } |
| 253 | } |
| 254 | } else { |
| 255 | LOG(FATAL) |
| 256 | << "Node type is not given when converting variable to param const"; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return param_const; |
| 261 | } |
| 262 | |
| 263 | std::string interval_to_str(const common::Extract::Interval& interval) { |
| 264 | switch (interval) { |
no test coverage detected