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();
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,
RSET zebra_create_rset_isam(ZebraHandle zh, NMEM rset_nmem, struct rset_key_control *kctl, int scope, ISAM_P pos, TERMID termid)
ISAMB_PP isamb_pp_open(ISAMB isamb, ISAM_P pos, int scope)
void isamb_pp_close(ISAMB_PP pp)
int isamb_pp_read(ISAMB_PP pp, void *buf)
int isamc_pp_read(ISAMC_PP pp, void *buf)
void isamc_pp_close(ISAMC_PP pp)
ISAMC_PP isamc_pp_open(ISAMC is, ISAM_P pos)
int isams_pp_read(ISAMS_PP pp, void *buf)
void isams_pp_close(ISAMS_PP pp)
ISAMS_PP isams_pp_open(ISAMS is, ISAM_P pos)
int key_compare(const void *p1, const void *p2)
const char * res_get(Res r, const char *name)
const char * res_get_def(Res r, const char *name, const char *def)
void rset_delete(RSET rs)
Destructor RSETs.
RSET rset_create_or(NMEM nmem, struct rset_key_control *kcontrol, int scope, TERMID termid, int no_rsets, RSET *rsets)
#define rset_read(rfd, buf, term)
RSET rsisamb_create(NMEM nmem, struct rset_key_control *kcontrol, int scope, ISAMB is, ISAM_P pos, TERMID term)
TERMID rset_term_create(const char *name, int length, const char *flags, int type, NMEM nmem, struct ord_list *ol, int reg_type, zint hits_limit, const char *ref_id)
Creates a TERMID entry.
RSET rset_create_null(NMEM nmem, struct rset_key_control *kcontrol, TERMID term)
#define rset_write(rfd, buf)
RSET rset_create_temp(NMEM nmem, struct rset_key_control *kcontrol, int scope, const char *temp_path, TERMID term)
#define rset_open(rs, wflag)
void rset_close(RSFD rfd)
Closes a result set RFD handle.
int(* cmp)(const void *p1, const void *p2)
struct zebra_register * reg
static void heap_insert(struct trunc_info *ti, const char *buf, int indx)
static struct trunc_info * heap_init(int size, int key_size, int(*cmp)(const void *p1, const void *p2))
RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no, const char *term, int length, const char *flags, int preserve_position, int term_type, NMEM rset_nmem, struct rset_key_control *kctrl, int scope, struct ord_list *ol, const char *index_type, zint hits_limit, const char *term_ref_id)
static int isams_trunc_cmp(const void *p1, const void *p2)
static int isamc_trunc_cmp(const void *p1, const void *p2)
static void heap_swap(struct trunc_info *ti, int i1, int i2)
static RSET rset_trunc_r(ZebraHandle zi, const char *term, int length, const char *flags, ISAM_P *isam_p, int from, int to, int merge_chunk, int preserve_position, int term_type, NMEM rset_nmem, struct rset_key_control *kctrl, int scope, TERMID termid)
static void heap_delete(struct trunc_info *ti)
static void heap_close(struct trunc_info *ti)