Skip to content

Commit 5bd682d

Browse files
authored
Merge pull request #15 from tidesdb/addition-merge-cursor-c
addition of merge cursor reference in C section
2 parents 5aa155a + 205eb2b commit 5bd682d

File tree

1 file changed

+9
-7
lines changed
  • src/content/docs/reference

1 file changed

+9
-7
lines changed

src/content/docs/reference/c.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,18 +497,20 @@ tidesdb_txn_free(txn);
497497
### Cursor Operations
498498
Cursors allow you to iterate through key-value pairs in a column family.
499499
500+
> You can use a `tidesdb_merge_cursor` if you want all keys to be sorted from all sources.
501+
500502
#### Initializing a Cursor
501503
```c
502504
/*
503505
* Initialize a cursor to iterate through key-value pairs
504506
* A cursor allows bi-directional sequential access to the TidesDB isntance contents
505507
*/
506-
tidesdb_cursor_t *cursor = NULL;
508+
tidesdb_cursor_t *cursor = NULL; /* or tidesdb_merge_cursor_t */
507509
tidesdb_err_t *err = tidesdb_cursor_init(
508510
tdb, /* TidesDB instance */
509511
"users", /* Column family name */
510512
&cursor /* Cursor pointer */
511-
);
513+
); /* or tidesdb_merge_cursor_init */
512514
513515
if (err != NULL) {
514516
printf("Error initializing cursor: %s (code: %d)\n", err->message, err->code);
@@ -533,7 +535,7 @@ do {
533535
&key_size, /* Output key size */
534536
&value, /* Output value */
535537
&value_size /* Output value size */
536-
);
538+
); /* or tidesdb_merge_cursor_get */
537539

538540
if (err != NULL) {
539541
printf("Error getting cursor value: %s (code: %d)\n", err->message, err->code);
@@ -546,7 +548,7 @@ do {
546548
/* Free the key and value when done to prevent memory leaks */
547549
free(key);
548550
free(value);
549-
} while ((err = tidesdb_cursor_next(cursor)) == NULL);
551+
} while ((err = tidesdb_cursor_next(cursor)) == NULL); /* or tidesdb_merge_cursor_next */
550552

551553
/*
552554
* Check if we reached the end of the cursor or if there was an error
@@ -569,7 +571,7 @@ do {
569571
&key_size, /* Output key size */
570572
&value, /* Output value */
571573
&value_size /* Output value size */
572-
);
574+
); /* or tidesdb_merge_cursor_get */
573575

574576
if (err != NULL) {
575577
printf("Error getting cursor value: %s (code: %d)\n", err->message, err->code);
@@ -582,7 +584,7 @@ do {
582584
/* Free the key and value when done */
583585
free(key);
584586
free(value);
585-
} while ((err = tidesdb_cursor_prev(cursor)) == NULL);
587+
} while ((err = tidesdb_cursor_prev(cursor)) == NULL); /* or tidesdb_merge_cursor_prev */
586588

587589
/* Check if we reached the start of the cursor or if there was an error */
588590
if (err != NULL && err->code != TIDESDB_ERR_AT_START_OF_CURSOR) {
@@ -593,7 +595,7 @@ if (err != NULL && err->code != TIDESDB_ERR_AT_START_OF_CURSOR) {
593595

594596
#### Freeing a Cursor
595597
```c
596-
tidesdb_cursor_free(cursor);
598+
tidesdb_cursor_free(cursor); /* or tidesdb_merge_cursor_free
597599
```
598600
599601
### Compaction Operations

0 commit comments

Comments
 (0)