| 219 | } |
| 220 | |
| 221 | Status Signature::Compute() { |
| 222 | if (map.size() > kMaxGraphSize) { |
| 223 | return Status( |
| 224 | error::INVALID_ARGUMENT, |
| 225 | absl::StrFormat( |
| 226 | "A graph of %d nodes is too big for signature computation, " |
| 227 | "the maximal supported node count is %d.", |
| 228 | map.size(), kMaxGraphSize)); |
| 229 | } |
| 230 | |
| 231 | // The value that will be assigned next as the unique node id. |
| 232 | // This also means that all the entries in nodes at indexes less than this |
| 233 | // have been finalized and don't need to be touched any more. |
| 234 | size_t next_node_id = 0; |
| 235 | |
| 236 | sig_short = 0; |
| 237 | sig_full.resize(0); // Keep the storage. |
| 238 | |
| 239 | // The main signature generation. |
| 240 | PrepareNodes(); |
| 241 | FindUniqueHashes(&next_node_id); |
| 242 | while (next_node_id < map.size()) { |
| 243 | ComputeOneRound(next_node_id); |
| 244 | FindUniqueHashes(&next_node_id); |
| 245 | } |
| 246 | |
| 247 | OrderLinks(); |
| 248 | |
| 249 | return Status::OK(); |
| 250 | } |
| 251 | |
| 252 | void Signature::PrepareNodes() { |
| 253 | nodes.resize(0); // Keep the storage. |