MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / streamGetEdgeID

Function streamGetEdgeID

src/t_stream.cpp:399–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399void 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'.

Callers 1

Calls 7

raxStartFunction · 0.85
raxSeekFunction · 0.85
raxNextFunction · 0.85
raxPrevFunction · 0.85
raxStopFunction · 0.85
streamDecodeIDFunction · 0.85
lpGetEdgeStreamIDFunction · 0.85

Tested by

no test coverage detected