From 0912d7cd382d578f045ef8f2cd1e092b3747d6e5 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Tue, 16 Jan 2001 16:56:15 +0000 Subject: [PATCH] Searching in my isam-d --- index/trunc.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- rset/Makefile.am | 4 +-- rset/Makefile.in | 7 ++-- 3 files changed, 109 insertions(+), 7 deletions(-) diff --git a/index/trunc.c b/index/trunc.c index 118344c..167c562 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: trunc.c,v $ - * Revision 1.18 2000-05-18 12:01:36 adam + * Revision 1.19 2001-01-16 16:56:15 heikki + * Searching in my isam-d + * + * Revision 1.18 2000/05/18 12:01:36 adam * System call times(2) used again. More 64-bit fixes. * * Revision 1.17 2000/03/15 15:00:30 adam @@ -77,6 +80,7 @@ #if ZMBOL #include #include +#include #if NEW_TRUNC #include #endif @@ -359,6 +363,60 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, heap_close (ti); xfree (ispt); } + + else if (zi->service->isamd) + { + ISAMD_PP *ispt; + int i; + struct trunc_info *ti; + + ispt = (ISAMD_PP *) xmalloc (sizeof(*ispt) * (to-from)); + + ti = heap_init (to-from, sizeof(struct it_key), + key_compare_it); + for (i = to-from; --i >= 0; ) + { + ispt[i] = isamd_pp_open (zi->service->isamd, isam_p[from+i]); + if (isamd_pp_read (ispt[i], ti->tmpbuf)) + heap_insert (ti, ti->tmpbuf, i); + else + isamd_pp_close (ispt[i]); + } + while (ti->heapnum) + { + int n = ti->indx[ti->ptr[1]]; + + rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]); +#if 0 +/* section that preserve all keys */ + heap_delete (ti); + if (isamd_pp_read (ispt[n], ti->tmpbuf)) + heap_insert (ti, ti->tmpbuf, n); + else + isamd_pp_close (ispt[n]); +#else +/* section that preserve all keys with unique sysnos */ + while (1) + { + if (!isamd_pp_read (ispt[n], ti->tmpbuf)) + { + heap_delete (ti); + isamd_pp_close (ispt[n]); + break; + } + if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > 1) + { + heap_delete (ti); + heap_insert (ti, ti->tmpbuf, n); + break; + } + } +#endif + } + heap_close (ti); + xfree (ispt); + } + #endif else if (zi->service->isams) { @@ -402,6 +460,9 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, heap_close (ti); xfree (ispt); } + else + logf (LOG_WARN, "Unknown isam set in rset_trunc_r"); + rset_close (result, result_rsfd); return result; } @@ -438,6 +499,17 @@ static int isamc_trunc_cmp (const void *p1, const void *p2) return d; return isc_block (i1) - isc_block (i2); } +static int isamd_trunc_cmp (const void *p1, const void *p2) +{ + ISAMD_P i1 = *(ISAMD_P*) p1; + ISAMD_P i2 = *(ISAMD_P*) p2; + int d; + + d = isamd_type (i1) - isamd_type (i2); + if (d) + return d; + return isamd_block (i1) - isamd_block (i2); +} #endif RSET rset_trunc (ZebraHandle zi, ISAMS_P *isam_p, int no, @@ -505,10 +577,39 @@ RSET rset_trunc (ZebraHandle zi, ISAMS_P *isam_p, int no, #endif qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp); } + else if (zi->service->isamd) + { + if (no == 1) + { + rset_isamd_parms parms; + + parms.pos = *isam_p; + parms.is = zi->service->isamd; + parms.rset_term = rset_term_create (term, length, flags); + return rset_create (rset_kind_isamd, &parms); + } +#if NEW_TRUNC_NOT_DONE_FOR_ISAM_D + else if (no < 10000) + { + rset_m_or_parms parms; + + parms.key_size = sizeof(struct it_key); + parms.cmp = key_compare_it; + parms.isc = 0; + parms.isamd=zi->service->isamd; + parms.isam_positions = isam_p; + parms.no_isam_positions = no; + parms.no_save_positions = 100000; + parms.rset_term = rset_term_create (term, length, flags); + return rset_create (rset_kind_m_or, &parms); + } +#endif + qsort (isam_p, no, sizeof(*isam_p), isamd_trunc_cmp); + } #endif else { - logf (LOG_WARN, "Neither isam / isamc / isams set in rset_trunc"); + logf (LOG_WARN, "Unknown isam set in rset_trunc"); return rset_create (rset_kind_null, NULL); } return rset_trunc_r (zi, term, length, flags, isam_p, 0, no, 100); diff --git a/rset/Makefile.am b/rset/Makefile.am index c1992f9..e7fb2a5 100644 --- a/rset/Makefile.am +++ b/rset/Makefile.am @@ -1,8 +1,8 @@ -## $Id: Makefile.am,v 1.1 2000-04-05 09:49:36 adam Exp $ +## $Id: Makefile.am,v 1.2 2001-01-16 16:56:15 heikki Exp $ noinst_LIBRARIES = librset.a librset_a_SOURCES = rset.c rstemp.c rsisam.c rsnull.c rsbool.c \ - rsisamc.c rsm_or.c rsisams.c + rsisamc.c rsm_or.c rsisams.c rsisamd.c INCLUDES = -I$(srcdir)/../include @YAZINC@ diff --git a/rset/Makefile.in b/rset/Makefile.in index b4cff96..3c1e831 100644 --- a/rset/Makefile.in +++ b/rset/Makefile.in @@ -75,7 +75,7 @@ yazconfig = @yazconfig@ noinst_LIBRARIES = librset.a -librset_a_SOURCES = rset.c rstemp.c rsisam.c rsnull.c rsbool.c rsisamc.c rsm_or.c rsisams.c +librset_a_SOURCES = rset.c rstemp.c rsisam.c rsnull.c rsbool.c rsisamc.c rsm_or.c rsisams.c rsisamd.c INCLUDES = -I$(srcdir)/../include @YAZINC@ @@ -88,7 +88,7 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ librset_a_LIBADD = librset_a_OBJECTS = rset.o rstemp.o rsisam.o rsnull.o rsbool.o \ -rsisamc.o rsm_or.o rsisams.o +rsisamc.o rsm_or.o rsisams.o rsisamd.o AR = ar CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -102,7 +102,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = gtar GZIP_ENV = --best DEP_FILES = .deps/rsbool.P .deps/rset.P .deps/rsisam.P .deps/rsisamc.P \ -.deps/rsisams.P .deps/rsm_or.P .deps/rsnull.P .deps/rstemp.P +.deps/rsisamd.P .deps/rsisams.P .deps/rsm_or.P .deps/rsnull.P \ +.deps/rstemp.P SOURCES = $(librset_a_SOURCES) OBJECTS = $(librset_a_OBJECTS) -- 1.7.10.4