X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Ftrunc.c;h=d1deaa100dd49399bf62dacff6e07174651bebac;hb=af7bc27d33843a8e667022f24589450c39f907f2;hp=4a0de3980a3aeca5be02725d4a4a93068d0ed561;hpb=0ac0f444414651f31406b227b64a447fd324ac4a;p=idzebra-moved-to-github.git diff --git a/index/trunc.c b/index/trunc.c index 4a0de39..d1deaa1 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -4,7 +4,20 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: trunc.c,v $ - * Revision 1.1 1996-11-04 14:07:40 adam + * Revision 1.4 1996-12-23 15:30:44 adam + * Work on truncation. + * Bug fix: result sets weren't deleted after server shut down. + * + * Revision 1.3 1996/12/20 11:07:14 adam + * Multi-or result set. + * + * Revision 1.2 1996/11/08 11:10:28 adam + * Buffers used during file match got bigger. + * Compressed ISAM support everywhere. + * Bug fixes regarding masking characters in queries. + * Redesigned Regexp-2 queries. + * + * Revision 1.1 1996/11/04 14:07:40 adam * Moved truncation code to trunc.c. * */ @@ -17,6 +30,12 @@ #include #include +#define NEW_TRUNC 1 + +#if NEW_TRUNC +#include +#endif + struct trunc_info { int *ptr; int *indx; @@ -145,7 +164,7 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to, merge_chunk); rscur++; } - ti = heap_init (rscur, sizeof(struct it_key), key_compare); + ti = heap_init (rscur, sizeof(struct it_key), key_compare_it); for (i = rscur; --i >= 0; ) { rsfd[i] = rset_open (rset[i], RSETF_READ|RSETF_SORT_SYSNO); @@ -193,7 +212,7 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to, ispt = xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), - key_compare); + key_compare_it); for (i = to-from; --i >= 0; ) { ispt[i] = is_position (zi->isam, isam_p[from+i]); @@ -207,7 +226,7 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to, int n = ti->indx[ti->ptr[1]]; rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]); -#if 0 +#if 1 /* section that preserve all keys */ heap_delete (ti); if (is_readkey (ispt[n], ti->tmpbuf)) @@ -245,11 +264,11 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to, ispt = xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), - key_compare); + key_compare_it); for (i = to-from; --i >= 0; ) { ispt[i] = isc_pp_open (zi->isamc, isam_p[from+i]); - if (isc_read_key (ispt[i], ti->tmpbuf)) + if (isc_pp_read (ispt[i], ti->tmpbuf)) heap_insert (ti, ti->tmpbuf, i); else isc_pp_close (ispt[i]); @@ -270,7 +289,7 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to, /* section that preserve all keys with unique sysnos */ while (1) { - if (!isc_read_key (ispt[n], ti->tmpbuf)) + if (!isc_pp_read (ispt[n], ti->tmpbuf)) { heap_delete (ti); isc_pp_close (ispt[n]); @@ -318,6 +337,7 @@ static int isamc_trunc_cmp (const void *p1, const void *p2) RSET rset_trunc (ZServerInfo *zi, ISAM_P *isam_p, int no) { + logf (LOG_LOG, "rset_trunc no=%d", no); if (zi->isam) { if (no < 1) @@ -344,6 +364,21 @@ RSET rset_trunc (ZServerInfo *zi, ISAM_P *isam_p, int no) parms.is = zi->isamc; return rset_create (rset_kind_isamc, &parms); } +#if NEW_TRUNC + else if (no < 200) + { + rset_m_or_parms parms; + + logf (LOG_LOG, "new_trunc"); + parms.key_size = sizeof(struct it_key); + parms.cmp = key_compare_it; + parms.isc = zi->isamc; + parms.isam_positions = isam_p; + parms.no_isam_positions = no; + parms.no_save_positions = 100; + return rset_create (rset_kind_m_or, &parms); + } +#endif qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp); } else