24 #include <sys/times.h>
33 #include <yaz/xmalloc.h>
39 static void log_item(
int level,
const void *b,
const char *txt)
42 memcpy(&x, b,
sizeof(
int));
55 memcpy(&ia, a,
sizeof(
int));
56 memcpy(&ib, b,
sizeof(
int));
69 void code_item(
void *p,
char **dst,
const char **src)
71 memcpy (*dst, *src,
sizeof(
int));
72 (*dst) +=
sizeof(int);
73 (*src) +=
sizeof(int);
92 int code_read(
void *vp,
char **dst,
int *insertMode)
97 if (ri->
no >= ri->
max)
102 memcpy (*dst, &x,
sizeof(
int));
144 memcpy (&x, key_buf,
sizeof(
int));
147 yaz_log(YLOG_WARN,
"isamb_pp_read. n=%d Got %d (expected %d)",
152 yaz_log(
log_level,
"isamb_pp_read. n=%d Got %d",
159 yaz_log(YLOG_WARN,
"ri.max != ri.max (%d != %d)", ri.
val, ri.
max);
195 yaz_log(YLOG_WARN,
"isamb_merge did not return empty list n=%d",
226 for (i = 0; i<ri.
max; i +=2 )
231 if (x != xu && xu != x+1)
233 yaz_log(YLOG_WARN,
"isamb_pp_forward (1). Got %d (expected %d)",
242 for (i = 0; i<ri.
max; i += 100)
247 if (x != xu && xu != x+1)
249 yaz_log(YLOG_WARN,
"isamb_pp_forward (2). Got %d (expected %d)",
295 for (i = 0; i < n; i += chunk)
344 memcpy (*dst, &x,
sizeof(
int));
347 yaz_log(YLOG_DEBUG,
"%d %5d", *insertMode, x);
355 int *freq = malloc(
sizeof(
int) * n);
356 int *
delta = malloc(
sizeof(
int) * n);
358 for (i = 0; i<n; i++)
361 for (j = 0; j<rounds; j++)
363 yaz_log(YLOG_DEBUG,
"round %d", j);
364 for (i = 0; i<n; i++)
367 delta[i] = (rand() % (1+max_dups)) - freq[i];
387 yaz_log(YLOG_DEBUG,
"dump %d", j);
390 yaz_log(YLOG_DEBUG,
"----------------------------");
391 for (i = 0; i<n; i++)
396 for (i = 0; i<n; i++)
399 yaz_log(YLOG_WARN,
"isamb_merge returned 0, but "
400 "freq is non-empty");
411 yaz_log(YLOG_DEBUG,
"test %d", j);
416 memcpy (&x, key_buf,
sizeof(
int));
417 yaz_log(YLOG_DEBUG,
"Got %d", x);
425 yaz_log(YLOG_WARN,
"tst_random: Extra item: %d", x);
430 yaz_log(YLOG_WARN,
"tst_random: Mismatch %d != %d",
443 yaz_log(YLOG_WARN,
"tst_random: Missing item: %d",
idx);
496 yaz_log(YLOG_WARN,
"tst_minsert: isamb_merge should be empty n=%d",
533 int main(
int argc,
char **argv)
540 yaz_log_init_level(YLOG_ALL);
555 yaz_log(YLOG_WARN,
"bfs_create failed");
562 isb =
isamb_open (bfs,
"isamb", 1, &method, 0);
565 yaz_log(YLOG_WARN,
"isamb_open failed");
void bf_reset(BFiles bfs)
Removes register and shadow completely.
BFiles bfs_create(const char *spec, const char *base)
creates a Block files collection
void bfs_destroy(BFiles bfiles)
destroys a block files handle
ISAMB_PP isamb_pp_open(ISAMB isamb, ISAM_P pos, int scope)
ISAMB isamb_open(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, int cache)
void isamb_dump(ISAMB b, ISAM_P pos, void(*pr)(const char *str))
void isamb_close(ISAMB isamb)
int isamb_pp_forward(ISAMB_PP pp, void *buf, const void *untilbuf)
void isamb_pp_close(ISAMB_PP pp)
void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *data)
int isamb_unlink(ISAMB b, ISAM_P pos)
int isamb_pp_read(ISAMB_PP pp, void *buf)
int(* read_item)(void *clientData, char **dst, int *insertMode)
int(* compare_item)(const void *a, const void *b)
void(* log_item)(int logmask, const void *p, const char *txt)
void(* decode)(void *p, char **dst, const char **src)
void(* encode)(void *p, char **dst, const char **src)
void tst_random(ISAMB isb, int n, int rounds, int max_dups)
static void log_item(int level, const void *b, const char *txt)
int main(int argc, char **argv)
void tst_insert(ISAMB isb, int n)
int compare_item(const void *a, const void *b)
void code_item(void *p, char **dst, const char **src)
void tst_append(ISAMB isb, int n)
static void log_pr(const char *txt)
int tst_random_read(void *vp, char **dst, int *insertMode)
void tst_minsert(ISAMB isb, int n)
void tst_forward(ISAMB isb, int n)
int code_read(void *vp, char **dst, int *insertMode)
static void identical_keys_tests(ISAMB isb)