X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=index%2Frecindex.c;h=09cc7084f06e94026c6be1803c79d19f4d0d4754;hb=4e2fc80e64f3d7895a871ea5b08aa80045a59f2c;hp=6f06cd561fb56d2f80308a3d4684c761746bd7e4;hpb=226fb73f42a86cc30ff4f27eb452ab3f6c19ae01;p=idzebra-moved-to-github.git diff --git a/index/recindex.c b/index/recindex.c index 6f06cd5..09cc708 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -4,7 +4,15 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recindex.c,v $ - * Revision 1.10 1995-12-06 12:41:24 adam + * Revision 1.12 1995-12-07 17:38:47 adam + * Work locking mechanisms for concurrent updates/commit. + * + * Revision 1.11 1995/12/06 13:58:26 adam + * Improved flushing of records - all flushes except the last one + * don't write the last accessed. Also flush takes place if record + * info occupy more than about 256k. + * + * Revision 1.10 1995/12/06 12:41:24 adam * New command 'stat' for the index program. * Filenames can be read from stdin by specifying '-'. * Bug fix/enhancement of the transformation from terms to regular @@ -300,10 +308,13 @@ Records rec_open (int rw) return p; } -static void rec_cache_flush (Records p) +static void rec_cache_flush (Records p, int saveCount) { - int i; - for (i = 0; icache_cur; i++) + int i, j; + + if (saveCount >= p->cache_cur) + saveCount = 0; + for (i = 0; icache_cur - saveCount; i++) { struct record_cache_entry *e = p->record_cache + i; switch (e->flag) @@ -322,7 +333,10 @@ static void rec_cache_flush (Records p) } rec_rm (&e->rec); } - p->cache_cur = 0; + for (j = 0; jrecord_cache+j, p->record_cache+i, + sizeof(*p->record_cache)); + p->cache_cur = saveCount; } static Record *rec_cache_lookup (Records p, int sysno, @@ -347,7 +361,20 @@ static void rec_cache_insert (Records p, Record rec, enum recordCacheFlag flag) struct record_cache_entry *e; if (p->cache_cur == p->cache_max) - rec_cache_flush (p); + rec_cache_flush (p, 1); + else if (p->cache_cur > 2) + { + int i, j; + int used = 0; + for (i = 0; icache_cur; i++) + { + Record r = (p->record_cache + i)->rec; + for (j = 0; jsize[j]; + } + if (used > 256000) + rec_cache_flush (p, 1); + } assert (p->cache_cur < p->cache_max); e = p->record_cache + (p->cache_cur)++; @@ -362,7 +389,7 @@ void rec_close (Records *pp) assert (p); - rec_cache_flush (p); + rec_cache_flush (p, 0); xfree (p->record_cache); if (p->rw) @@ -475,6 +502,7 @@ void rec_del (Records p, Record *recpp) { Record *recp; + (p->head.no_records)--; if ((recp = rec_cache_lookup (p, (*recpp)->sysno, recordFlagDelete))) { rec_rm (recp);