| 397 | } |
| 398 | |
| 399 | void streamGetEdgeID(stream *s, int first, streamID *edge_id) |
| 400 | { |
| 401 | raxIterator ri; |
| 402 | raxStart(&ri, s->rax); |
| 403 | int empty; |
| 404 | if (first) { |
| 405 | raxSeek(&ri, "^", NULL, 0); |
| 406 | empty = !raxNext(&ri); |
| 407 | } else { |
| 408 | raxSeek(&ri, "$", NULL, 0); |
| 409 | empty = !raxPrev(&ri); |
| 410 | } |
| 411 | |
| 412 | if (empty) { |
| 413 | /* Stream is empty, mark edge ID as lowest/highest possible. */ |
| 414 | edge_id->ms = first ? UINT64_MAX : 0; |
| 415 | edge_id->seq = first ? UINT64_MAX : 0; |
| 416 | raxStop(&ri); |
| 417 | return; |
| 418 | } |
| 419 | |
| 420 | unsigned char *lp = (unsigned char*)ri.data; |
| 421 | |
| 422 | /* Read the master ID from the radix tree key. */ |
| 423 | streamID master_id; |
| 424 | streamDecodeID(ri.key, &master_id); |
| 425 | |
| 426 | /* Construct edge ID. */ |
| 427 | lpGetEdgeStreamID(lp, first, &master_id, edge_id); |
| 428 | |
| 429 | raxStop(&ri); |
| 430 | } |
| 431 | |
| 432 | /* Adds a new item into the stream 's' having the specified number of |
| 433 | * field-value pairs as specified in 'numfields' and stored into 'argv'. |
no test coverage detected