IDZEBRA  2.2.7
kinput.c
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include <fcntl.h>
24 #ifdef WIN32
25 #include <io.h>
26 #endif
27 #if HAVE_UNISTD_H
28 #include <unistd.h>
29 #endif
30 #include <stdlib.h>
31 #include <string.h>
32 #include <stdio.h>
33 #include <assert.h>
34 
35 #include <yaz/snprintf.h>
36 #include "index.h"
37 
38 #define KEY_SIZE (1+sizeof(struct it_key))
39 #define INP_NAME_MAX 768
40 
41 struct key_file {
42  int no; /* file no */
43  off_t offset; /* file offset */
44  unsigned char *buf; /* buffer block */
45  size_t buf_size; /* number of read bytes in block */
46  size_t chunk; /* number of bytes allocated */
47  size_t buf_ptr; /* current position in buffer */
48  char *prev_name; /* last word read */
50  off_t length; /* length of file */
51  /* handler invoked in each read */
52  void (*readHandler)(struct key_file *keyp, void *rinfo);
53  void *readInfo;
55 };
56 
57 
58 #define PR_KEY_LOW 0
59 #define PR_KEY_TOP 0
60 
61 #if PR_KEY_LOW || PR_KEY_TOP
62 
63 static void pkey(const char *b, int mode)
64 {
65  key_logdump_txt(YLOG_LOG, b, mode ? "i" : "d");
66 }
67 #endif
68 
69 void extract_get_fname_tmp(ZebraHandle zh, char *fname, size_t fname_size, int no)
70 {
71  const char *pre;
72 
73  pre = res_get_def(zh->res, "keyTmpDir", ".");
74  yaz_snprintf(fname, fname_size, "%s/key%d.tmp", pre, no);
75 }
76 
78 {
79  int nr = 0, r = 0, fd;
80  char fname[1024];
81  const char *pre;
82 
83  pre = res_get_def(f->res, "keyTmpDir", ".");
84  yaz_snprintf(fname, sizeof(fname), "%s/key%d.tmp", pre, f->no);
85  fd = open(fname, O_BINARY|O_RDONLY);
86 
87  f->buf_ptr = 0;
88  f->buf_size = 0;
89  if (fd == -1)
90  {
91  yaz_log(YLOG_WARN|YLOG_ERRNO, "cannot open %s", fname);
92  return ;
93  }
94  if (!f->length)
95  {
96  if ((f->length = lseek(fd, 0L, SEEK_END)) == (off_t) -1)
97  {
98  yaz_log(YLOG_WARN|YLOG_ERRNO, "cannot seek %s", fname);
99  close(fd);
100  return ;
101  }
102  }
103  if (lseek(fd, f->offset, SEEK_SET) == -1)
104  {
105  yaz_log(YLOG_WARN|YLOG_ERRNO, "cannot seek %s", fname);
106  close(fd);
107  return ;
108  }
109  while (f->chunk - nr > 0)
110  {
111  r = read(fd, f->buf + nr, f->chunk - nr);
112  if (r <= 0)
113  break;
114  nr += r;
115  }
116  if (r == -1)
117  {
118  yaz_log(YLOG_WARN|YLOG_ERRNO, "read of %s", fname);
119  close(fd);
120  return;
121  }
122  f->buf_size = nr;
123  if (f->readHandler)
124  (*f->readHandler)(f, f->readInfo);
125  close(fd);
126 }
127 
128 void key_file_destroy(struct key_file *f)
129 {
131  xfree(f->buf);
132  xfree(f->prev_name);
133  xfree(f);
134 }
135 
136 struct key_file *key_file_init(int no, int chunk, Res res)
137 {
138  struct key_file *f;
139 
140  f = (struct key_file *) xmalloc(sizeof(*f));
141  f->res = res;
142  f->decode_handle = iscz1_start();
143  f->no = no;
144  f->chunk = chunk;
145  f->offset = 0;
146  f->length = 0;
147  f->readHandler = NULL;
148  f->buf = (unsigned char *) xmalloc(f->chunk);
149  f->prev_name = (char *) xmalloc(INP_NAME_MAX);
150  *f->prev_name = '\0';
152  return f;
153 }
154 
155 int key_file_getc(struct key_file *f)
156 {
157  if (f->buf_ptr < f->buf_size)
158  return f->buf[(f->buf_ptr)++];
159  if (f->buf_size < f->chunk)
160  return EOF;
161  f->offset += f->buf_size;
163  if (f->buf_ptr < f->buf_size)
164  return f->buf[(f->buf_ptr)++];
165  else
166  return EOF;
167 }
168 
169 int key_file_read(struct key_file *f, char *key)
170 {
171  int i, c;
172  char srcbuf[128];
173  const char *src = srcbuf;
174  char *dst;
175  int j;
176 
177  c = key_file_getc(f);
178  if (c == 0)
179  {
180  strcpy(key, f->prev_name);
181  i = 1+strlen(key);
182  }
183  else if (c == EOF)
184  return 0;
185  else
186  {
187  i = 0;
188  key[i++] = c;
189  while ((c = key_file_getc(f)))
190  {
191  if (i < INP_NAME_MAX-2)
192  key[i++] = c;
193  }
194  key[i++] = '\0';
195  strcpy(f->prev_name, key);
197  }
198  c = key_file_getc(f); /* length + insert/delete combined */
199  key[i++] = c & 128;
200  c = c & 127;
201  for (j = 0; j < c; j++)
202  srcbuf[j] = key_file_getc(f);
203  dst = key + i;
204  iscz1_decode(f->decode_handle, &dst, &src);
205 
206 #if 0
207  /* debugging */
208  if (1)
209  {
210  struct it_key k;
211  memcpy(&k, key+i, sizeof(k));
212  if (!k.mem[1])
213  yaz_log(YLOG_LOG, "00 KEY");
214  }
215 #endif
216  return i + sizeof(struct it_key);
217 }
218 
219 struct heap_info {
220  struct {
221  struct key_file **file;
222  char **buf;
223  } info;
224  int heapnum;
225  int *ptr;
226  int (*cmp)(const void *p1, const void *p2);
234 };
235 
236 static struct heap_info *key_heap_malloc(void)
237 { /* malloc and clear it */
238  struct heap_info *hi;
239  hi = (struct heap_info *) xmalloc(sizeof(*hi));
240  hi->info.file = 0;
241  hi->info.buf = 0;
242  hi->heapnum = 0;
243  hi->ptr = 0;
244  hi->no_diffs = 0;
245  hi->no_diffs = 0;
246  hi->no_updates = 0;
247  hi->no_deletions = 0;
248  hi->no_insertions = 0;
249  hi->no_iterations = 0;
250  return hi;
251 }
252 
254  int nkeys,
255  int (*cmp)(const void *p1, const void *p2))
256 {
257  struct heap_info *hi;
258  int i;
259 
260  hi = key_heap_malloc();
261  hi->zh = zh;
262  hi->info.file = (struct key_file **)
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));
266  hi->cmp = cmp;
267  for (i = 0; i<= nkeys; i++)
268  {
269  hi->ptr[i] = i;
270  hi->info.buf[i] = (char *) xmalloc(INP_NAME_MAX);
271  }
272  return hi;
273 }
274 
275 void key_heap_destroy(struct heap_info *hi, int nkeys)
276 {
277  int i;
278  for (i = 0; i<=nkeys; i++)
279  xfree(hi->info.buf[i]);
280  xfree(hi->info.buf);
281  xfree(hi->ptr);
282  xfree(hi->info.file);
283  xfree(hi);
284 }
285 
286 static void key_heap_swap(struct heap_info *hi, int i1, int i2)
287 {
288  int swap;
289 
290  swap = hi->ptr[i1];
291  hi->ptr[i1] = hi->ptr[i2];
292  hi->ptr[i2] = swap;
293 }
294 
295 
296 static void key_heap_delete(struct heap_info *hi)
297 {
298  int cur = 1, child = 2;
299 
300  assert(hi->heapnum > 0);
301 
302  key_heap_swap(hi, 1, hi->heapnum);
303  hi->heapnum--;
304  while (child <= hi->heapnum) {
305  if (child < hi->heapnum &&
306  (*hi->cmp)(&hi->info.buf[hi->ptr[child]],
307  &hi->info.buf[hi->ptr[child+1]]) > 0)
308  child++;
309  if ((*hi->cmp)(&hi->info.buf[hi->ptr[cur]],
310  &hi->info.buf[hi->ptr[child]]) > 0)
311  {
312  key_heap_swap(hi, cur, child);
313  cur = child;
314  child = 2*cur;
315  }
316  else
317  break;
318  }
319 }
320 
321 static void key_heap_insert(struct heap_info *hi, const char *buf, int nbytes,
322  struct key_file *kf)
323 {
324  int cur, parent;
325 
326  assert(nbytes < INP_NAME_MAX);
327 
328  cur = ++(hi->heapnum);
329  memcpy(hi->info.buf[hi->ptr[cur]], buf, nbytes);
330  hi->info.file[hi->ptr[cur]] = kf;
331 
332  parent = cur/2;
333  while (parent && (*hi->cmp)(&hi->info.buf[hi->ptr[parent]],
334  &hi->info.buf[hi->ptr[cur]]) > 0)
335  {
336  key_heap_swap(hi, cur, parent);
337  cur = parent;
338  parent = cur/2;
339  }
340 }
341 
342 static int heap_read_one(struct heap_info *hi, char *name, char *key)
343 {
344  int n, r;
345  char rbuf[INP_NAME_MAX];
346  struct key_file *kf;
347 
348  if (!hi->heapnum)
349  return 0;
350  n = hi->ptr[1];
351  strcpy(name, hi->info.buf[n]);
352  kf = hi->info.file[n];
353  r = strlen(name);
354  memcpy(key, hi->info.buf[n] + r+1, KEY_SIZE);
355  key_heap_delete(hi);
356  if ((r = key_file_read(kf, rbuf)))
357  key_heap_insert(hi, rbuf, r, kf);
358  hi->no_iterations++;
359  return 1;
360 }
361 
362 
363 /* for debugging only */
364 void zebra_log_dict_entry(ZebraHandle zh, const char *s)
365 {
366  char dst[INP_NAME_MAX+1];
367  int ord;
368  int len = key_SU_decode(&ord, (const unsigned char *) s);
369  const char *index_type;
370 
371  if (!zh)
372  yaz_log(YLOG_LOG, "ord=%d", ord);
373  else
374  {
375  const char *string_index;
376  const char *db = 0;
378  ord, &index_type, &db, &string_index);
379 
380  zebra_term_untrans(zh, index_type, dst, s + len);
381 
382  yaz_log(YLOG_LOG, "ord=%d index_type=%s index=%s term=%s",
383  ord, index_type, string_index, dst);
384  }
385 }
386 
390  char *key;
391  char *key_1, *key_2;
393  int sz_1, sz_2;
394  struct heap_info *hi;
396  int more;
397  int ret;
399 };
400 
401 static int heap_cread_item(void *vp, char **dst, int *insertMode);
402 
403 int heap_cread_item2(void *vp, char **dst, int *insertMode)
404 {
405  struct heap_cread_info *p = (struct heap_cread_info *) vp;
406  int level = 0;
407 
408  if (p->look_level)
409  {
410  if (p->look_level > 0)
411  {
412  *insertMode = 1;
413  p->look_level--;
414  }
415  else
416  {
417  *insertMode = 0;
418  p->look_level++;
419  }
420  memcpy(*dst, p->key_1, p->sz_1);
421 #if PR_KEY_TOP
422  yaz_log(YLOG_LOG, "DUP level=%d", p->look_level);
423  pkey(*dst, *insertMode);
424 #endif
425  (*dst) += p->sz_1;
426  return 1;
427  }
428  if (p->ret == 0) /* lookahead was 0?. Return that in read next round */
429  {
430  p->ret = -1;
431  return 0;
432  }
433  else if (p->ret == -1) /* Must read new item ? */
434  {
435  char *dst_1 = p->key_1;
436  p->ret = heap_cread_item(vp, &dst_1, &p->mode_1);
437  p->sz_1 = dst_1 - p->key_1;
438  }
439  else
440  { /* lookahead in 2 . Now in 1. */
441  p->sz_1 = p->sz_2;
442  p->mode_1 = p->mode_2;
443  memcpy(p->key_1, p->key_2, p->sz_2);
444  }
445  if (p->mode_1)
446  level = 1; /* insert */
447  else
448  level = -1; /* delete */
449  while(1)
450  {
451  char *dst_2 = p->key_2;
452  p->ret = heap_cread_item(vp, &dst_2, &p->mode_2);
453  if (!p->ret)
454  {
455  if (level)
456  break;
457  p->ret = -1;
458  return 0;
459  }
460  p->sz_2 = dst_2 - p->key_2;
461 
462  if (key_compare(p->key_1, p->key_2) == 0)
463  {
464  if (p->mode_2) /* adjust level according to deletes/inserts */
465  level++;
466  else
467  level--;
468  }
469  else
470  {
471  if (level)
472  break;
473  /* all the same. new round .. */
474  p->sz_1 = p->sz_2;
475  p->mode_1 = p->mode_2;
476  memcpy(p->key_1, p->key_2, p->sz_1);
477  if (p->mode_1)
478  level = 1; /* insert */
479  else
480  level = -1; /* delete */
481  }
482  }
483  /* outcome is insert (1) or delete (0) depending on final level */
484  if (level > 0)
485  {
486  *insertMode = 1;
487  level--;
488  }
489  else
490  {
491  *insertMode = 0;
492  level++;
493  }
494  p->look_level = level;
495  memcpy(*dst, p->key_1, p->sz_1);
496 #if PR_KEY_TOP
497  yaz_log(YLOG_LOG, "TOP");
498  pkey(*dst, *insertMode);
499 #endif
500  (*dst) += p->sz_1;
501  return 1;
502 }
503 
504 int heap_cread_item(void *vp, char **dst, int *insertMode)
505 {
506  struct heap_cread_info *p = (struct heap_cread_info *) vp;
507  struct heap_info *hi = p->hi;
508 
509  if (p->first_in_list)
510  {
511  *insertMode = p->key[0];
512  memcpy(*dst, p->key+1, sizeof(struct it_key));
513 #if PR_KEY_LOW
515  pkey(*dst, *insertMode);
516 #endif
517  (*dst) += sizeof(struct it_key);
518  p->first_in_list = 0;
519  return 1;
520  }
521  strcpy(p->prev_name, p->cur_name);
522  if (!(p->more = heap_read_one(hi, p->cur_name, p->key)))
523  return 0;
524  if (*p->cur_name && strcmp(p->cur_name, p->prev_name))
525  {
526  p->first_in_list = 1;
527  return 0;
528  }
529  *insertMode = p->key[0];
530  memcpy(*dst, p->key+1, sizeof(struct it_key));
531 #if PR_KEY_LOW
533  pkey(*dst, *insertMode);
534 #endif
535  (*dst) += sizeof(struct it_key);
536  return 1;
537 }
538 
539 int heap_inpc(struct heap_cread_info *hci, struct heap_info *hi)
540 {
541  ISAMC_I *isamc_i = (ISAMC_I *) xmalloc(sizeof(*isamc_i));
542 
543  isamc_i->clientData = hci;
544  isamc_i->read_item = heap_cread_item2;
545 
546  while (hci->more)
547  {
548  char this_name[INP_NAME_MAX];
549  ISAM_P isamc_p, isamc_p2;
550  char *dict_info;
551 
552  strcpy(this_name, hci->cur_name);
553  assert(hci->cur_name[0]);
554  hi->no_diffs++;
555  if ((dict_info = dict_lookup(hi->reg->dict, hci->cur_name)))
556  {
557  memcpy(&isamc_p, dict_info+1, sizeof(ISAM_P));
558  isamc_p2 = isamc_p;
559  isamc_merge(hi->reg->isamc, &isamc_p2, isamc_i);
560  if (!isamc_p2)
561  {
562  hi->no_deletions++;
563  if (!dict_delete(hi->reg->dict, this_name))
564  abort();
565  }
566  else
567  {
568  hi->no_updates++;
569  if (isamc_p2 != isamc_p)
570  dict_insert(hi->reg->dict, this_name,
571  sizeof(ISAM_P), &isamc_p2);
572  }
573  }
574  else
575  {
576  isamc_p = 0;
577  isamc_merge(hi->reg->isamc, &isamc_p, isamc_i);
578  hi->no_insertions++;
579  if (isamc_p)
580  dict_insert(hi->reg->dict, this_name,
581  sizeof(ISAM_P), &isamc_p);
582  }
583  }
584  xfree(isamc_i);
585  return 0;
586 }
587 
588 int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi)
589 {
590  ISAMC_I *isamc_i = (ISAMC_I *) xmalloc(sizeof(*isamc_i));
591 
592  isamc_i->clientData = hci;
593  isamc_i->read_item = heap_cread_item2;
594 
595  while (hci->more)
596  {
597  char this_name[INP_NAME_MAX];
598  ISAM_P isamc_p, isamc_p2;
599  char *dict_info;
600 
601  strcpy(this_name, hci->cur_name);
602  assert(hci->cur_name[0]);
603  hi->no_diffs++;
604 
605 #if 0
606  assert(hi->zh);
607  zebra_log_dict_entry(hi->zh, hci->cur_name);
608 #endif
609  if ((dict_info = dict_lookup(hi->reg->dict, hci->cur_name)))
610  {
611  memcpy(&isamc_p, dict_info+1, sizeof(ISAM_P));
612  isamc_p2 = isamc_p;
613  isamb_merge(hi->reg->isamb, &isamc_p2, isamc_i);
614  if (!isamc_p2)
615  {
616  hi->no_deletions++;
617  if (!dict_delete(hi->reg->dict, this_name))
618  abort();
619  }
620  else
621  {
622  hi->no_updates++;
623  if (isamc_p2 != isamc_p)
624  dict_insert(hi->reg->dict, this_name,
625  sizeof(ISAM_P), &isamc_p2);
626  }
627  }
628  else
629  {
630  isamc_p = 0;
631  isamb_merge(hi->reg->isamb, &isamc_p, isamc_i);
632  hi->no_insertions++;
633  if (isamc_p)
634  dict_insert(hi->reg->dict, this_name,
635  sizeof(ISAM_P), &isamc_p);
636  }
637  }
638  xfree(isamc_i);
639  return 0;
640 }
641 
642 int heap_inps(struct heap_cread_info *hci, struct heap_info *hi)
643 {
644  ISAMS_I isams_i = (ISAMS_I) xmalloc(sizeof(*isams_i));
645 
646  isams_i->clientData = hci;
647  isams_i->read_item = heap_cread_item;
648 
649  while (hci->more)
650  {
651  char this_name[INP_NAME_MAX];
652  ISAM_P isams_p;
653  char *dict_info;
654 
655  strcpy(this_name, hci->cur_name);
656  assert(hci->cur_name[0]);
657  hi->no_diffs++;
658  if (!(dict_info = dict_lookup(hi->reg->dict, hci->cur_name)))
659  {
660  isams_p = isams_merge(hi->reg->isams, isams_i);
661  hi->no_insertions++;
662  dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isams_p);
663  }
664  else
665  {
666  yaz_log(YLOG_FATAL, "isams doesn't support this kind of update");
667  break;
668  }
669  }
670  xfree(isams_i);
671  return 0;
672 }
673 
674 struct progressInfo {
675  time_t startTime;
676  time_t lastTime;
677  off_t totalBytes;
678  off_t totalOffset;
679 };
680 
681 void progressFunc(struct key_file *keyp, void *info)
682 {
683  struct progressInfo *p = (struct progressInfo *) info;
684  time_t now, remaining;
685 
686  if (keyp->buf_size <= 0 || p->totalBytes <= 0)
687  return ;
688  time (&now);
689 
690  if (now >= p->lastTime+10)
691  {
692  p->lastTime = now;
693  remaining = (time_t) ((now - p->startTime)*
694  ((double) p->totalBytes/p->totalOffset - 1.0));
695  if (remaining <= 130)
696  yaz_log(YLOG_LOG, "Merge %2.1f%% completed; %ld seconds remaining",
697  (100.0*p->totalOffset) / p->totalBytes, (long) remaining);
698  else
699  yaz_log(YLOG_LOG, "Merge %2.1f%% completed; %ld minutes remaining",
700  (100.0*p->totalOffset) / p->totalBytes, (long) remaining/60);
701  }
702  p->totalOffset += keyp->buf_size;
703 }
704 
705 #ifndef R_OK
706 #define R_OK 4
707 #endif
708 
710 {
711  struct key_file **kf = 0;
712  char rbuf[1024];
713  int i, r;
714  struct heap_info *hi;
715  struct progressInfo progressInfo;
716  int nkeys = key_block_get_no_files(zh->reg->key_block);
717 
718  if (nkeys == 0)
719  return;
720 
721  if (nkeys < 0)
722  {
723  char fname[1024];
724  nkeys = 0;
725  while (1)
726  {
727  extract_get_fname_tmp (zh, fname, sizeof fname, nkeys+1);
728  if (access(fname, R_OK) == -1)
729  break;
730  nkeys++;
731  }
732  if (!nkeys)
733  return ;
734  }
735  kf = (struct key_file **) xmalloc((1+nkeys) * sizeof(*kf));
738  time(&progressInfo.startTime);
739  time(&progressInfo.lastTime);
740  for (i = 1; i<=nkeys; i++)
741  {
742  kf[i] = key_file_init(i, 8192, zh->res);
743  kf[i]->readHandler = progressFunc;
744  kf[i]->readInfo = &progressInfo;
745  progressInfo.totalBytes += kf[i]->length;
747  }
748  hi = key_heap_init_file(zh, nkeys, key_qsort_compare);
749  hi->reg = zh->reg;
750 
751  for (i = 1; i<=nkeys; i++)
752  if ((r = key_file_read(kf[i], rbuf)))
753  key_heap_insert(hi, rbuf, r, kf[i]);
754 
755  if (1)
756  {
757  struct heap_cread_info hci;
758 
759  hci.key = (char *) xmalloc(KEY_SIZE);
760  hci.key_1 = (char *) xmalloc(KEY_SIZE);
761  hci.key_2 = (char *) xmalloc(KEY_SIZE);
762  hci.ret = -1;
763  hci.first_in_list = 1;
764  hci.hi = hi;
765  hci.look_level = 0;
766  hci.more = heap_read_one(hi, hci.cur_name, hci.key);
767 
768  if (zh->reg->isams)
769  heap_inps(&hci, hi);
770  if (zh->reg->isamc)
771  heap_inpc(&hci, hi);
772  if (zh->reg->isamb)
773  heap_inpb(&hci, hi);
774 
775  xfree(hci.key);
776  xfree(hci.key_1);
777  xfree(hci.key_2);
778  }
779 
780  for (i = 1; i<=nkeys; i++)
781  {
782  extract_get_fname_tmp (zh, rbuf, sizeof rbuf, i);
783  unlink(rbuf);
784  }
785  for (i = 1; i<=nkeys; i++)
786  key_file_destroy(kf[i]);
787  xfree(kf);
788  if (hi->no_iterations)
789  { /* do not log if nothing happened */
790  yaz_log(YLOG_LOG, "Iterations: isam/dict "
793  yaz_log(YLOG_LOG, "Dict: inserts/updates/deletions: "
796  }
798  key_heap_destroy(hi, nkeys);
799 }
800 /*
801  * Local variables:
802  * c-basic-offset: 4
803  * c-file-style: "Stroustrup"
804  * indent-tabs-mode: nil
805  * End:
806  * vim: shiftwidth=4 tabstop=8 expandtab
807  */
808 
#define O_BINARY
Definition: agrep.c:46
char * dict_lookup(Dict dict, const char *p)
lookup item in dictionary
Definition: lookup.c:100
int dict_delete(Dict dict, const char *p)
deletes item from dictionary
Definition: delete.c:260
int dict_insert(Dict dict, const char *p, int userlen, void *userinfo)
insert item into dictionary
Definition: insert.c:439
int zebra_term_untrans(ZebraHandle zh, const char *index_type, char *dst, const char *src)
Definition: untrans.c:31
void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *data)
Definition: isamb.c:1266
void isamc_merge(ISAMC is, ISAM_P *pos, ISAMC_I *data)
Definition: merge.c:154
zint ISAM_P
Definition: isamc.h:28
struct ISAMS_I_s * ISAMS_I
ISAM_P isams_merge(ISAMS is, ISAMS_I data)
Definition: isams.c:115
void * iscz1_start(void)
Definition: it_key.c:130
int key_SU_decode(int *ch, const unsigned char *out)
Definition: su_codec.c:64
void iscz1_decode(void *vp, char **dst, const char **src)
Definition: it_key.c:238
int key_qsort_compare(const void *p1, const void *p2)
Definition: it_key.c:111
int key_compare(const void *p1, const void *p2)
Definition: it_key.c:74
void key_logdump_txt(int logmask, const void *p, const char *txt)
Definition: it_key.c:38
void iscz1_reset(void *vp)
Definition: it_key.c:146
void iscz1_stop(void *p)
Definition: it_key.c:155
void key_block_destroy(zebra_key_block_t *pp)
Definition: key_block.c:226
int key_block_get_no_files(zebra_key_block_t p)
Definition: key_block.c:411
void key_file_chunk_read(struct key_file *f)
Definition: kinput.c:77
int key_file_read(struct key_file *f, char *key)
Definition: kinput.c:169
void key_heap_destroy(struct heap_info *hi, int nkeys)
Definition: kinput.c:275
#define R_OK
Definition: kinput.c:706
#define KEY_SIZE
Definition: kinput.c:38
int key_file_getc(struct key_file *f)
Definition: kinput.c:155
static int heap_read_one(struct heap_info *hi, char *name, char *key)
Definition: kinput.c:342
void progressFunc(struct key_file *keyp, void *info)
Definition: kinput.c:681
int heap_cread_item2(void *vp, char **dst, int *insertMode)
Definition: kinput.c:403
void extract_get_fname_tmp(ZebraHandle zh, char *fname, size_t fname_size, int no)
Definition: kinput.c:69
static void key_heap_insert(struct heap_info *hi, const char *buf, int nbytes, struct key_file *kf)
Definition: kinput.c:321
#define INP_NAME_MAX
Definition: kinput.c:39
void zebra_log_dict_entry(ZebraHandle zh, const char *s)
Definition: kinput.c:364
int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi)
Definition: kinput.c:588
static int heap_cread_item(void *vp, char **dst, int *insertMode)
Definition: kinput.c:504
void zebra_index_merge(ZebraHandle zh)
Definition: kinput.c:709
static void key_heap_swap(struct heap_info *hi, int i1, int i2)
Definition: kinput.c:286
struct key_file * key_file_init(int no, int chunk, Res res)
Definition: kinput.c:136
static void key_heap_delete(struct heap_info *hi)
Definition: kinput.c:296
struct heap_info * key_heap_init_file(ZebraHandle zh, int nkeys, int(*cmp)(const void *p1, const void *p2))
Definition: kinput.c:253
int heap_inps(struct heap_cread_info *hci, struct heap_info *hi)
Definition: kinput.c:642
static struct heap_info * key_heap_malloc(void)
Definition: kinput.c:236
void key_file_destroy(struct key_file *f)
Definition: kinput.c:128
int heap_inpc(struct heap_cread_info *hci, struct heap_info *hi)
Definition: kinput.c:539
const char * res_get_def(Res r, const char *name, const char *def)
Definition: res.c:313
int(* read_item)(void *clientData, char **dst, int *insertMode)
Definition: isamc.h:53
void * clientData
Definition: isamc.h:54
void * clientData
Definition: isams.h:45
int(* read_item)(void *clientData, char **dst, int *insertMode)
Definition: isams.h:44
int first_in_list
Definition: kinput.c:395
char prev_name[INP_NAME_MAX]
Definition: kinput.c:388
char * key_2
Definition: kinput.c:391
int look_level
Definition: kinput.c:398
struct heap_info * hi
Definition: kinput.c:394
char * key_1
Definition: kinput.c:391
char * key
Definition: kinput.c:390
char cur_name[INP_NAME_MAX]
Definition: kinput.c:389
struct key_file ** file
Definition: kinput.c:221
zint no_updates
Definition: kinput.c:230
zint no_deletions
Definition: kinput.c:231
struct zebra_register * reg
Definition: kinput.c:227
zint no_insertions
Definition: kinput.c:232
int(* cmp)(const void *p1, const void *p2)
Definition: kinput.c:226
zint no_diffs
Definition: kinput.c:229
struct heap_info::@14 info
zint no_iterations
Definition: kinput.c:233
ZebraHandle zh
Definition: kinput.c:228
int heapnum
Definition: kinput.c:224
char ** buf
Definition: kinput.c:222
int * ptr
Definition: kinput.c:225
Definition: it_key.h:30
zint mem[IT_KEY_LEVEL_MAX]
Definition: it_key.h:32
size_t chunk
Definition: kinput.c:46
void * readInfo
Definition: kinput.c:53
off_t length
Definition: kinput.c:50
void * decode_handle
Definition: kinput.c:49
size_t buf_size
Definition: kinput.c:45
int no
Definition: kinput.c:42
char * prev_name
Definition: kinput.c:48
size_t buf_ptr
Definition: kinput.c:47
Res res
Definition: kinput.c:54
void(* readHandler)(struct key_file *keyp, void *rinfo)
Definition: kinput.c:52
unsigned char * buf
Definition: kinput.c:44
off_t offset
Definition: kinput.c:43
time_t startTime
Definition: kinput.c:675
time_t lastTime
Definition: kinput.c:676
off_t totalBytes
Definition: kinput.c:677
off_t totalOffset
Definition: kinput.c:678
Definition: res.c:46
ZebraExplainInfo zei
Definition: index.h:139
zebra_key_block_t key_block
Definition: index.h:153
ISAMS isams
Definition: index.h:129
ISAMB isamb
Definition: index.h:131
ISAMC isamc
Definition: index.h:130
Dict dict
Definition: index.h:132
struct zebra_register * reg
Definition: index.h:174
int fd
Definition: tstlockscope.c:38
long zint
Zebra integer.
Definition: util.h:66
#define ZINT_FORMAT
Definition: util.h:72
int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord, const char **index_type, const char **db, const char **string_index)
Definition: zinfo.c:1478