| 134 | } |
| 135 | |
| 136 | bool Edge::DeSerialize(const char* s, size_t size) { |
| 137 | uint64_t src_id = 0; |
| 138 | uint64_t dst_id = 0; |
| 139 | BytesReader bytes_reader(s, size); |
| 140 | |
| 141 | // parse id |
| 142 | if (!bytes_reader.Read(&src_id) || |
| 143 | !bytes_reader.Read(&dst_id)) { |
| 144 | EULER_LOG(ERROR) << "edge id error"; |
| 145 | return false; |
| 146 | } |
| 147 | if (!bytes_reader.Read(&type_) || // parse type |
| 148 | !bytes_reader.Read(&weight_)) { // parse weight |
| 149 | EULER_LOG(ERROR) << "edge info error, edge_id: " << src_id << "," << dst_id; |
| 150 | return false; |
| 151 | } |
| 152 | |
| 153 | id_ = std::make_tuple(src_id, dst_id, type_); |
| 154 | |
| 155 | // parse uint64 feature |
| 156 | if (!bytes_reader.Read(&uint64_features_idx_)) { |
| 157 | EULER_LOG(ERROR) << "uint64 feature idx list error, edge_id: " |
| 158 | << src_id << "," << dst_id << "," << type_; |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | if (!bytes_reader.Read(&uint64_features_)) { |
| 163 | EULER_LOG(ERROR) << "uint64 feature value list error, edge_id: " |
| 164 | << src_id << "," << dst_id << "," << type_; |
| 165 | return false; |
| 166 | } |
| 167 | |
| 168 | if (!bytes_reader.Read(&float_features_idx_)) { |
| 169 | EULER_LOG(ERROR) << "float feature idx list error, edge_id: " |
| 170 | << src_id << "," << dst_id << "," << type_; |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | if (!bytes_reader.Read(&float_features_)) { |
| 175 | EULER_LOG(ERROR) << "float feature value list error, edge_id: " |
| 176 | << src_id << "," << dst_id << "," << type_; |
| 177 | return false; |
| 178 | } |
| 179 | |
| 180 | if (!bytes_reader.Read(&binary_features_idx_)) { |
| 181 | EULER_LOG(ERROR) << "binary feature idx list error, edge_id: " |
| 182 | << src_id << "," << dst_id << "," << type_; |
| 183 | return false; |
| 184 | } |
| 185 | |
| 186 | if (!bytes_reader.Read(&binary_features_)) { |
| 187 | EULER_LOG(ERROR) << "binary feature value list error, edge_id: " |
| 188 | << src_id << "," << dst_id << "," << type_; |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | return true; |
| 193 | } |