35 #include <yaz/snprintf.h>
38 #define KEY_SIZE (1+sizeof(struct it_key))
39 #define INP_NAME_MAX 768
61 #if PR_KEY_LOW || PR_KEY_TOP
63 static void pkey(
const char *b,
int mode)
74 yaz_snprintf(fname, fname_size,
"%s/key%d.tmp", pre,
no);
79 int nr = 0, r = 0,
fd;
84 yaz_snprintf(fname,
sizeof(fname),
"%s/key%d.tmp", pre, f->
no);
91 yaz_log(YLOG_WARN|YLOG_ERRNO,
"cannot open %s", fname);
96 if ((f->
length = lseek(
fd, 0L, SEEK_END)) == (off_t) -1)
98 yaz_log(YLOG_WARN|YLOG_ERRNO,
"cannot seek %s", fname);
103 if (lseek(
fd, f->
offset, SEEK_SET) == -1)
105 yaz_log(YLOG_WARN|YLOG_ERRNO,
"cannot seek %s", fname);
109 while (f->
chunk - nr > 0)
118 yaz_log(YLOG_WARN|YLOG_ERRNO,
"read of %s", fname);
140 f = (
struct key_file *) xmalloc(
sizeof(*f));
148 f->
buf = (
unsigned char *) xmalloc(f->
chunk);
173 const char *src = srcbuf;
201 for (j = 0; j < c; j++)
211 memcpy(&k, key+i,
sizeof(k));
213 yaz_log(YLOG_LOG,
"00 KEY");
216 return i +
sizeof(
struct it_key);
226 int (*
cmp)(
const void *p1,
const void *p2);
239 hi = (
struct heap_info *) xmalloc(
sizeof(*hi));
255 int (*
cmp)(
const void *p1,
const void *p2))
263 xmalloc(
sizeof(*hi->
info.
file) * (1+nkeys));
264 hi->
info.
buf = (
char **) xmalloc(
sizeof(*hi->
info.
buf) * (1+nkeys));
265 hi->
ptr = (
int *) xmalloc(
sizeof(*hi->
ptr) * (1+nkeys));
267 for (i = 0; i<= nkeys; i++)
278 for (i = 0; i<=nkeys; i++)
291 hi->
ptr[i1] = hi->
ptr[i2];
298 int cur = 1, child = 2;
304 while (child <= hi->heapnum) {
305 if (child < hi->heapnum &&
369 const char *index_type;
372 yaz_log(YLOG_LOG,
"ord=%d", ord);
375 const char *string_index;
378 ord, &index_type, &db, &string_index);
382 yaz_log(YLOG_LOG,
"ord=%d index_type=%s index=%s term=%s",
383 ord, index_type, string_index, dst);
422 yaz_log(YLOG_LOG,
"DUP level=%d", p->
look_level);
423 pkey(*dst, *insertMode);
433 else if (p->
ret == -1)
435 char *dst_1 = p->
key_1;
451 char *dst_2 = p->
key_2;
497 yaz_log(YLOG_LOG,
"TOP");
498 pkey(*dst, *insertMode);
511 *insertMode = p->
key[0];
512 memcpy(*dst, p->
key+1,
sizeof(
struct it_key));
515 pkey(*dst, *insertMode);
517 (*dst) +=
sizeof(
struct it_key);
529 *insertMode = p->
key[0];
530 memcpy(*dst, p->
key+1,
sizeof(
struct it_key));
533 pkey(*dst, *insertMode);
535 (*dst) +=
sizeof(
struct it_key);
557 memcpy(&isamc_p, dict_info+1,
sizeof(
ISAM_P));
569 if (isamc_p2 != isamc_p)
571 sizeof(
ISAM_P), &isamc_p2);
581 sizeof(
ISAM_P), &isamc_p);
611 memcpy(&isamc_p, dict_info+1,
sizeof(
ISAM_P));
623 if (isamc_p2 != isamc_p)
625 sizeof(
ISAM_P), &isamc_p2);
635 sizeof(
ISAM_P), &isamc_p);
666 yaz_log(YLOG_FATAL,
"isams doesn't support this kind of update");
684 time_t now, remaining;
693 remaining = (time_t) ((now - p->
startTime)*
695 if (remaining <= 130)
696 yaz_log(YLOG_LOG,
"Merge %2.1f%% completed; %ld seconds remaining",
699 yaz_log(YLOG_LOG,
"Merge %2.1f%% completed; %ld minutes remaining",
728 if (access(fname,
R_OK) == -1)
735 kf = (
struct key_file **) xmalloc((1+nkeys) *
sizeof(*kf));
740 for (i = 1; i<=nkeys; i++)
751 for (i = 1; i<=nkeys; i++)
780 for (i = 1; i<=nkeys; i++)
785 for (i = 1; i<=nkeys; i++)
790 yaz_log(YLOG_LOG,
"Iterations: isam/dict "
793 yaz_log(YLOG_LOG,
"Dict: inserts/updates/deletions: "
char * dict_lookup(Dict dict, const char *p)
lookup item in dictionary
int dict_delete(Dict dict, const char *p)
deletes item from dictionary
int dict_insert(Dict dict, const char *p, int userlen, void *userinfo)
insert item into dictionary
int zebra_term_untrans(ZebraHandle zh, const char *index_type, char *dst, const char *src)
void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *data)
void isamc_merge(ISAMC is, ISAM_P *pos, ISAMC_I *data)
struct ISAMS_I_s * ISAMS_I
ISAM_P isams_merge(ISAMS is, ISAMS_I data)
int key_SU_decode(int *ch, const unsigned char *out)
void iscz1_decode(void *vp, char **dst, const char **src)
int key_qsort_compare(const void *p1, const void *p2)
int key_compare(const void *p1, const void *p2)
void key_logdump_txt(int logmask, const void *p, const char *txt)
void iscz1_reset(void *vp)
void key_block_destroy(zebra_key_block_t *pp)
int key_block_get_no_files(zebra_key_block_t p)
const char * res_get_def(Res r, const char *name, const char *def)
int(* read_item)(void *clientData, char **dst, int *insertMode)
int(* read_item)(void *clientData, char **dst, int *insertMode)
char prev_name[INP_NAME_MAX]
char cur_name[INP_NAME_MAX]
struct zebra_register * reg
int(* cmp)(const void *p1, const void *p2)
struct heap_info::@14 info
zint mem[IT_KEY_LEVEL_MAX]
void(* readHandler)(struct key_file *keyp, void *rinfo)
zebra_key_block_t key_block
struct zebra_register * reg
int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord, const char **index_type, const char **db, const char **string_index)