| 87 | } |
| 88 | |
| 89 | void TraversalToString |
| 90 | ( |
| 91 | const OpBase *op, |
| 92 | sds *buf, |
| 93 | const AlgebraicExpression *ae |
| 94 | ) { |
| 95 | ASSERT(op != NULL); |
| 96 | ASSERT(ae != NULL); |
| 97 | ASSERT(buf != NULL); |
| 98 | |
| 99 | *buf = sdscatprintf(*buf, "%s | ", op->name); |
| 100 | |
| 101 | // this edge should be printed right-to-left if the edge matrix is transposed |
| 102 | const char *edge = AlgebraicExpression_Edge(ae); |
| 103 | const char *src_alias = AlgebraicExpression_Src(ae); |
| 104 | const char *dest_alias = AlgebraicExpression_Dest(ae); |
| 105 | |
| 106 | bool transpose = (edge && AlgebraicExpression_Transposed(ae)); |
| 107 | bool same_alias = !strcmp(src_alias, dest_alias); |
| 108 | |
| 109 | AlgebraicExpression *clone = AlgebraicExpression_Clone(ae); |
| 110 | |
| 111 | //-------------------------------------------------------------------------- |
| 112 | // print source labels |
| 113 | //-------------------------------------------------------------------------- |
| 114 | |
| 115 | *buf = sdscatprintf(*buf, "(%s", src_alias); |
| 116 | char *src_labels = ae_labels_src(&clone); |
| 117 | *buf = sdscatprintf(*buf, "%s", src_labels); |
| 118 | if(!same_alias) { |
| 119 | sdsfree(src_labels); |
| 120 | } |
| 121 | |
| 122 | *buf = sdscatprintf(*buf, ")"); |
| 123 | |
| 124 | //-------------------------------------------------------------------------- |
| 125 | // print edge |
| 126 | //-------------------------------------------------------------------------- |
| 127 | |
| 128 | if(edge) { |
| 129 | QGEdge *e = QueryGraph_GetEdgeByAlias(op->plan->query_graph, edge); |
| 130 | ASSERT(e != NULL); |
| 131 | if(transpose) { |
| 132 | *buf = sdscatprintf(*buf, "<-"); |
| 133 | QGEdge_ToString(e, buf); |
| 134 | *buf = sdscatprintf(*buf, "-"); |
| 135 | } else { |
| 136 | *buf = sdscatprintf(*buf, "-"); |
| 137 | QGEdge_ToString(e, buf); |
| 138 | *buf = sdscatprintf(*buf, "->"); |
| 139 | } |
| 140 | } else { |
| 141 | *buf = sdscatprintf(*buf, "->"); |
| 142 | } |
| 143 | |
| 144 | //-------------------------------------------------------------------------- |
| 145 | // print dest labels |
| 146 | //-------------------------------------------------------------------------- |
no test coverage detected