29 #define DATABASE_NAME 1 32 main(
int argc,
char **argv) {
46 memset(&key, 0,
sizeof(key));
47 memset(&record, 0,
sizeof(record));
49 printf(
"This sample uses upscaledb and duplicate keys to list all words " 50 "in the\noriginal order, together with their line number.\n");
51 printf(
"Reading from stdin...\n");
56 printf(
"ups_env_create() failed with error %d\n", st);
62 printf(
"ups_env_create_db() failed with error %d\n", st);
70 while (fgets(line,
sizeof(line), stdin)) {
71 char *start = line, *p;
78 while ((p = strtok(start,
" \t\r\n"))) {
82 record.
data = &lineno;
83 record.
size =
sizeof(lineno);
87 printf(
"ups_db_insert() failed with error %d\n", st);
99 printf(
"ups_cursor_create() failed with error %d\n", st);
111 printf(
"ups_cursor_next() failed with error %d\n", st);
117 printf(
"%s: appeared in line %u\n", (
const char *)key.
data,
118 *(
unsigned *)record.
data);
128 printf(
"ups_env_close() failed with error %d\n", st);
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_close(ups_env_t *env, uint32_t flags)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_db_insert(ups_db_t *db, ups_txn_t *txn, ups_key_t *key, ups_record_t *record, uint32_t flags)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_move(ups_cursor_t *cursor, ups_key_t *key, ups_record_t *record, uint32_t flags)
Include file for upscaledb embedded database.
#define UPS_PARAM_RECORD_SIZE
struct ups_cursor_t ups_cursor_t
int main(int argc, char **argv)
#define UPS_ENABLE_DUPLICATE_KEYS
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_create(ups_env_t **env, const char *filename, uint32_t flags, uint32_t mode, const ups_parameter_t *param)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_create_db(ups_env_t *env, ups_db_t **db, uint16_t name, uint32_t flags, const ups_parameter_t *params)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_create(ups_cursor_t **cursor, ups_db_t *db, ups_txn_t *txn, uint32_t flags)
#define UPS_KEY_NOT_FOUND
struct ups_env_t ups_env_t