-## $Id: Makefile.am,v 1.7 2002-02-20 17:30:01 adam Exp $
+## $Id: Makefile.am,v 1.8 2002-02-20 23:07:54 adam Exp $
noinst_PROGRAMS = apitest kdump
libzebra.a: $(libzebra_a_OBJECTS) $(libzebra_a_DEPENDENCIES)
-test ! -d atmp && mkdir atmp
+ -rm -f libzebra.a
mkdir atmp; for i in $(libzebra_a_LIBADD); do cd atmp; ar x ../$$i; cd ..; done
- ar qc libzebra.a $(libzebra_a_OBJECTS) libzebra.a atmp/*.o
+ ar cru libzebra.a $(libzebra_a_OBJECTS) libzebra.a atmp/*.o
$(RANLIB) libzebra.a
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: extract.c,v 1.110 2002-02-20 17:30:01 adam Exp $
+ * $Id: extract.c,v 1.111 2002-02-20 23:07:54 adam Exp $
*/
#include <stdio.h>
#include <assert.h>
}
/* match criteria */
-
if (! *sysno)
{
/* new record */
{
struct sortKey *sk;
ZebraHandle zh = p->extractCtrl->handle;
- struct sortKey *sortKeys = zh->sortKeys;
- for (sk = sortKeys; sk; sk = sk->next)
+ for (sk = zh->sortKeys; sk; sk = sk->next)
if (sk->attrSet == p->attrSet && sk->attrUse == p->attrUse)
return;
sk = (struct sortKey *) xmalloc (sizeof(*sk));
- sk->next = sortKeys;
- sortKeys = sk;
+ sk->next = zh->sortKeys;
+ zh->sortKeys = sk;
sk->string = (char *) xmalloc (length);
sk->length = length;
xfree (sk);
sk = sk_next;
}
+ yaz_log (LOG_LOG, "extract_flushSortKeys");
*skp = 0;
}
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss, Heikki Levanto
*
- * $Id: kinput.c,v 1.45 2002-02-20 17:30:01 adam Exp $
+ * $Id: kinput.c,v 1.46 2002-02-20 23:07:54 adam Exp $
*
* Bugs
* - Allocates a lot of memory for the merge process, but never releases it.
close (fd);
}
+void key_file_destroy (struct key_file *f)
+{
+ xfree (f->buf);
+ xfree (f->prev_name);
+ xfree (f);
+}
+
struct key_file *key_file_init (int no, int chunk, Res res)
{
struct key_file *f;
return hi;
}
+void key_heap_destroy (struct heap_info *hi, int nkeys)
+{
+ int i;
+ yaz_log (LOG_LOG, "key_heap_destroy");
+ for (i = 0; i<=nkeys; i++)
+ xfree (hi->info.buf[i]);
+
+ xfree (hi->info.buf);
+ xfree (hi->ptr);
+ xfree (hi->info.file);
+ xfree (hi);
+}
+
static void key_heap_swap (struct heap_info *hi, int i1, int i2)
{
int swap;
logf (LOG_LOG, "Deletions. . . .%7d", no_deletions);
logf (LOG_LOG, "Insertions . . .%7d", no_insertions);
zh->key_file_no = 0;
-}
-void key_input (ZebraHandle zh, int nkeys, int cache, Res res)
-
-{
- struct key_file **kf;
- char rbuf[1024];
- int i, r;
- struct heap_info *hi;
- struct progressInfo progressInfo;
-
- if (nkeys < 0)
- {
- char fname[1024];
- nkeys = 0;
- while (1)
- {
- getFnameTmp (res, fname, nkeys+1);
- if (access (fname, R_OK) == -1)
- break;
- nkeys++;
- }
- if (!nkeys)
- return ;
- }
- kf = (struct key_file **) xmalloc ((1+nkeys) * sizeof(*kf));
- progressInfo.totalBytes = 0;
- progressInfo.totalOffset = 0;
- time (&progressInfo.startTime);
- time (&progressInfo.lastTime);
- for (i = 1; i<=nkeys; i++)
- {
- kf[i] = key_file_init (i, 8192, res);
- kf[i]->readHandler = progressFunc;
- kf[i]->readInfo = &progressInfo;
- progressInfo.totalBytes += kf[i]->length;
- progressInfo.totalOffset += kf[i]->buf_size;
- }
- hi = key_heap_init (nkeys, key_qsort_compare);
- hi->dict = zh->service->dict;
- hi->isams = zh->service->isams;
-#if ZMBOL
- hi->isam = zh->service->isam;
- hi->isamc = zh->service->isamc;
- hi->isamd = zh->service->isamd;
-#endif
-
+ key_heap_destroy (hi, nkeys);
for (i = 1; i<=nkeys; i++)
- if ((r = key_file_read (kf[i], rbuf)))
- key_heap_insert (hi, rbuf, r, kf[i]);
- if (hi->isams)
- heap_inps (hi);
-#if ZMBOL
- else if (hi->isamc)
- heap_inpc (hi);
- else if (hi->isam)
- heap_inp (hi);
- else if (hi->isamd)
- heap_inpd (hi);
-#endif
-
- for (i = 1; i<=nkeys; i++)
- {
- getFnameTmp (res, rbuf, i);
- unlink (rbuf);
- }
- logf (LOG_LOG, "Iterations . . .%7d", no_iterations);
- logf (LOG_LOG, "Distinct words .%7d", no_diffs);
- logf (LOG_LOG, "Updates. . . . .%7d", no_updates);
- logf (LOG_LOG, "Deletions. . . .%7d", no_deletions);
- logf (LOG_LOG, "Insertions . . .%7d", no_insertions);
-
- /* xmalloc_trav("unfreed"); while hunting leaks */
+ key_file_destroy (kf[i]);
+ xfree (kf);
}
+
* Copyright (C) 1995-2002, Index Data
* All rights reserved.
*
- * $Id: zebraapi.c,v 1.45 2002-02-20 17:30:01 adam Exp $
+ * $Id: zebraapi.c,v 1.46 2002-02-20 23:07:54 adam Exp $
*/
#include <assert.h>
static void zebra_flush_reg (ZebraHandle zh)
{
- if (zh->service->matchDict)
- dict_close (zh->service->matchDict);
- zh->service->matchDict = 0;
zebraExplain_flush (zh->service->zei, 1, zh);
extract_flushWriteKeys (zh);
zs->recTypes = recTypes_init (zs->dh);
recTypes_default_handlers (zs->recTypes);
- zs->records = NULL;
zs->zebra_maps = zebra_maps_open (zs->res);
zs->rank_classes = NULL;
zs->dict = 0;
zs->sortIdx = 0;
zs->isams = 0;
+ zs->matchDict = 0;
#if ZMBOL
zs->isam = 0;
zs->isamc = 0;
zs->isamd = 0;
#endif
zs->zei = 0;
+ zs->matchDict = 0;
zebraRankInstall (zs, rank1_class);
logf (LOG_WARN, "rec_open");
return -1;
}
+ if (rw)
+ {
+ zs->matchDict = dict_open (zs->bfs, GMATCH_DICT, 50, 1, 0);
+ }
if (!(zs->dict = dict_open (zs->bfs, FNAME_DICT, 80, rw, 0)))
{
logf (LOG_WARN, "dict_open");
{
zebraExplain_close (zs->zei, 0);
dict_close (zs->dict);
+ if (zs->matchDict)
+ dict_close (zs->matchDict);
sortIdx_close (zs->sortIdx);
if (zs->isams)
isams_close (zs->isams);
char val;
int seqno;
- zebra_flush_reg (zh);
(zh->trans_no)++;
if (zh->trans_no != 1)
+ {
+ zebra_flush_reg (zh);
return 0;
+ }
zebra_get_state (&val, &seqno);
if (val == 'd')
zebra_set_state ('d', seqno);
zebra_register_activate (zh, 1, rval ? 1 : 0);
- zh->service->matchDict = dict_open (zh->service->bfs, GMATCH_DICT,
- 50, 1, 0);
zh->seqno = seqno;
}
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: zinfo.c,v 1.23 2002-02-20 17:30:01 adam Exp $
+ * $Id: zinfo.c,v 1.24 2002-02-20 23:07:54 adam Exp $
*/
#include <stdlib.h>
void zebraExplain_flush (ZebraExplainInfo zei, int writeFlag, void *handle)
{
+ if (!zei)
+ return;
zei->updateHandle = handle;
if (writeFlag)
{
/*
- * $Id: t2.c,v 1.1 2002-02-20 17:30:02 adam Exp $
+ * $Id: t2.c,v 1.2 2002-02-20 23:07:54 adam Exp $
*/
#include <zebraapi.h>
zebra_close (zh);
zebra_stop (zs);
+ odr_destroy (odr_input);
+ odr_destroy (odr_output);
+
nmem_exit ();
xmalloc_trav ("x");
exit (0);