35 int (*
cmp)(
const void *p1,
const void *p2);
53 int cur = 1, child = 2;
56 while (child <= ti->heapnum) {
57 if (child < ti->heapnum &&
59 ti->
heap[ti->
ptr[1+child]]) > 0)
81 while (parent && (*ti->
cmp)(ti->
heap[ti->
ptr[parent]],
91 int (*
cmp)(
const void *p1,
101 ti->
indx = (
int *) xmalloc(size *
sizeof(*ti->
indx));
102 ti->
heap = (
char **) xmalloc(size *
sizeof(*ti->
heap));
103 ti->
ptr = (
int *) xmalloc(size *
sizeof(*ti->
ptr));
106 ti->
buf = (
char *) xmalloc(size * ti->
keysize);
107 for (i = size; --i >= 0; )
127 const char *flags,
ISAM_P *isam_p,
int from,
int to,
128 int merge_chunk,
int preserve_position,
129 int term_type, NMEM rset_nmem,
141 if (to - from > merge_chunk)
145 int i, i_add = (to-from)/merge_chunk + 1;
148 int rsmax = (to-from)/i_add + 1;
149 int cmp_border = preserve_position ? 0 : 1;
150 NMEM rset_nmem_sub = nmem_create();
153 rset = (
RSET *) xmalloc(
sizeof(*rset) * rsmax);
154 rsfd = (
RSFD *) xmalloc(
sizeof(*rsfd) * rsmax);
156 for (i = from; i < to; i += i_add)
161 merge_chunk, preserve_position,
162 term_type, rset_nmem_sub,
167 merge_chunk, preserve_position,
168 term_type, rset_nmem_sub,
173 for (i = rscur; --i >= 0; )
211 nmem_destroy(rset_nmem_sub);
219 ispt = (
ISAMC_PP *) xmalloc(
sizeof(*ispt) * (to-from));
223 for (i = to-from; --i >= 0; )
237 if (preserve_position)
274 ispt = (
ISAMS_PP *) xmalloc(
sizeof(*ispt) * (to-from));
278 for (i = to-from; --i >= 0; )
317 ispt = (
ISAMB_PP *) xmalloc(
sizeof(*ispt) * (to-from));
321 for (i = to-from; --i >= 0; )
323 if (isam_p[from+i]) {
338 if (preserve_position)
369 yaz_log(YLOG_WARN,
"Unknown isam set in rset_trunc_r");
404 const char *term,
int length,
const char *flags,
405 int preserve_position,
int term_type, NMEM rset_nmem,
407 struct ord_list *ol,
const char *index_type,
408 zint hits_limit,
const char *term_ref_id)
413 int trunc_limit = atoi(
res_get_def(zh->
res,
"trunclimit",
"10000"));
416 *index_type, hits_limit, term_ref_id);
422 scope, *isam_p, termid);
423 else if (zh->
reg->
isamb && no > 1 && no < trunc_limit)
426 RSET *rsets = xmalloc(no*
sizeof(
RSET));
428 for (i = 0; i<no; i++)
442 result =
rset_trunc_r(zh, term, length, flags, isam_p, 0, no, trunc_chunk,
443 preserve_position, term_type, rset_nmem, kctrl,