31 #define DATABASE_NAME 1 36 printf(
"%s() returned error %d: %s\n", foo, st,
ups_strerror(st));
46 int record_type,
uint32_t record_size,
const char *reserved)
69 const void *record_data,
uint32_t record_size)
82 const void *record_data_list,
size_t list_length)
85 *pcount += list_length;
103 const void *record_data,
uint32_t record_size)
105 assert(record_size ==
sizeof(
uint32_t));
106 return *(
uint32_t *)record_data == 10;
124 error(
"ups_env_create", st);
131 error(
"ups_env_create_db", st);
137 for (
int i = 0; i < 10000; i++) {
144 error(
"ups_db_insert", st);
156 memset(&agg, 0,
sizeof(agg));
157 agg.
name =
"mycount";
166 error(
"uqi_register_plugin", st);
172 memset(&pred, 0,
sizeof(pred));
174 pred.
name =
"equals10";
178 error(
"uqi_register_plugin", st);
182 st =
uqi_select(env,
"mycount($record) FROM DATABASE 1 " 183 "WHERE equals10($record)", &result);
185 error(
"uqi_select", st);
190 printf(
"mycount($record): %lu\n", *(
uint64_t *)record.
data);
197 error(
"ups_env_close", st);
199 printf(
"success!\n");
#define ups_make_record(PTR, SIZE)
static void mycount_results(void *state, uqi_result_t *result)
uqi_plugin_aggregate_many_function agg_many
UPS_EXPORT const char *UPS_CALLCONV ups_strerror(ups_status_t status)
int main(int argc, char **argv)
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)
unsigned __int64 uint64_t
uqi_plugin_predicate_function pred
Include file for upscaledb Query Interface.
#define UQI_PLUGIN_AGGREGATE
void error(const char *foo, ups_status_t st)
UPS_EXPORT void UPS_CALLCONV uqi_result_add_row(uqi_result_t *result, const void *key_data, uint32_t key_size, const void *record_data, uint32_t record_size)
UPS_EXPORT ups_status_t UPS_CALLCONV uqi_select(ups_env_t *env, const char *query, uqi_result_t **result)
uqi_plugin_cleanup_function cleanup
UPS_EXPORT void UPS_CALLCONV uqi_result_get_record(uqi_result_t *result, uint32_t row, ups_record_t *record)
#define UPS_PARAM_RECORD_TYPE
UPS_EXPORT void UPS_CALLCONV uqi_result_close(uqi_result_t *result)
Include file for upscaledb embedded database.
uqi_plugin_aggregate_single_function agg_single
uqi_plugin_init_function init
uqi_plugin_result_function results
#define UQI_PLUGIN_PREDICATE
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)
static void mycount_single(void *state, const void *key_data, uint32_t key_size, const void *record_data, uint32_t record_size)
struct uqi_result_t uqi_result_t
UPS_EXPORT ups_status_t UPS_CALLCONV uqi_register_plugin(uqi_plugin_t *descriptor)
static void mycount_many(void *state, const void *key_data_list, const void *record_data_list, size_t list_length)
#define UPS_RECORD_NUMBER32
static void * mycount_init(int flags, int key_type, uint32_t key_size, int record_type, uint32_t record_size, const char *reserved)
static void mycount_cleanup(void *state)
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)
#define UPS_PARAM_KEY_TYPE
struct ups_env_t ups_env_t
static int equals10_predicate(void *state, const void *key_data, uint32_t key_size, const void *record_data, uint32_t record_size)