28 #define DBNAME_CUSTOMER 1 29 #define DBNAME_ORDER 2 32 #define DBIDX_CUSTOMER 0 36 #define MAX_CUSTOMERS 4 64 { 1,
"Alan Antonov Corp." },
65 { 2,
"Barry Broke Inc." },
66 { 3,
"Carl Caesar Lat." },
67 { 4,
"Doris Dove Brd." }
114 cursor[i].create(&db[i]);
130 db[0].
insert(&key, &record);
144 record.
set_size(
sizeof(orders[i].assignee));
145 record.
set_data(orders[i].assignee);
147 db[1].
insert(&key, &record);
160 key.
set_data(&orders[i].customer_id);
183 cursor[0].
move_next(&cust_key, &cust_record);
190 std::cerr <<
"cursor.move_next() failed: " << e.
get_string()
199 std::cout <<
"customer " << customer->
id <<
" ('" 200 << customer->
name <<
"')" << std::endl;
216 cursor[2].
find(&c2o_key);
222 std::cerr <<
"cursor.find() failed: " << e.
get_string()
229 cursor[2].
move(0, &c2o_record);
234 order_id = *(
int *)c2o_record.
get_data();
242 ord_record = db[1].
find(&ord_key);
244 std::cout <<
" order: " << order_id <<
" (assigned to " 245 << (
char *)ord_record.
get_data() <<
")" << std::endl;
252 cursor[2].
move(&c2o_key, &c2o_record,
260 std::cerr <<
"cursor.move() failed: " << e.
get_string()
273 std::cout <<
"success!" << std::endl;
284 std::cerr <<
"run_demo() failed with unexpected error " int main(int argc, char **argv)
void create(const char *filename, uint32_t flags=0, uint32_t mode=0644, const ups_parameter_t *param=0)
void set_size(uint32_t size)
ups_status_t get_errno() const
db create_db(uint16_t name, uint32_t flags=0, const ups_parameter_t *param=0)
#define UPS_PARAM_RECORD_SIZE
void insert(txn *t, key *k, record *r, uint32_t flags=0)
const char * get_string() const
void move(key *k, record *r, uint32_t flags=0)
void move_next(key *k=0, record *r=0)
#define UPS_ONLY_DUPLICATES
void set_size(uint16_t size)
#define UPS_ENABLE_DUPLICATE_KEYS
void set_data(void *data)
record find(txn *t, key *k, uint32_t flags=0)
void set_data(void *data)
void find(key *k, record *r=0, uint32_t flags=0)
#define UPS_PARAM_KEY_TYPE
#define UPS_KEY_NOT_FOUND