From f7a35c8865bf897ea727edf97b8b3b996a2f5419 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 15 Sep 2006 10:45:12 +0000 Subject: [PATCH] Rename rec_rm to rec_free. Annotate the recindex.h file a bit. --- index/extract.c | 4 ++-- index/recindex.c | 14 +++++++------- index/recindex.h | 43 ++++++++++++++++++++++++++++++++++++++++--- index/recindxp.h | 4 +++- index/retrieve.c | 10 +++++----- index/zinfo.c | 14 +++++++------- 6 files changed, 64 insertions(+), 25 deletions(-) diff --git a/index/extract.c b/index/extract.c index 8189504..12db319 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.229 2006-09-08 14:40:52 adam Exp $ +/* $Id: extract.c,v 1.230 2006-09-15 10:45:12 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -742,7 +742,7 @@ ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, } rec_del (zh->reg->records, &rec); } - rec_rm (&rec); + rec_free(&rec); logRecord(zh); return ZEBRA_OK; } diff --git a/index/recindex.c b/index/recindex.c index 95a4474..69237da 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -1,4 +1,4 @@ -/* $Id: recindex.c,v 1.51 2006-08-14 10:40:15 adam Exp $ +/* $Id: recindex.c,v 1.52 2006-09-15 10:45:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -591,7 +591,7 @@ static ZEBRA_RES rec_cache_flush(Records p, int saveCount) for (i = 0; icache_cur - saveCount; i++) { struct record_cache_entry *e = p->record_cache + i; - rec_rm(&e->rec); + rec_free(&e->rec); } /* i still being used ... */ for (j = 0; jhead.no_records)--; if ((recp = rec_cache_lookup(p, (*recpp)->sysno, recordFlagDelete))) { - rec_rm(recp); + rec_free(recp); *recp = *recpp; } else { ret = rec_cache_insert(p, *recpp, recordFlagDelete); - rec_rm(recpp); + rec_free(recpp); } zebra_mutex_unlock(&p->mutex); *recpp = NULL; @@ -915,20 +915,20 @@ ZEBRA_RES rec_put(Records p, Record *recpp) zebra_mutex_lock(&p->mutex); if ((recp = rec_cache_lookup(p, (*recpp)->sysno, recordFlagWrite))) { - rec_rm(recp); + rec_free(recp); *recp = *recpp; } else { ret = rec_cache_insert(p, *recpp, recordFlagWrite); - rec_rm(recpp); + rec_free(recpp); } zebra_mutex_unlock(&p->mutex); *recpp = NULL; return ret; } -void rec_rm(Record *recpp) +void rec_free(Record *recpp) { int i; diff --git a/index/recindex.h b/index/recindex.h index 86bb465..6310a24 100644 --- a/index/recindex.h +++ b/index/recindex.h @@ -1,4 +1,4 @@ -/* $Id: recindex.h,v 1.28 2006-08-14 10:40:15 adam Exp $ +/* $Id: recindex.h,v 1.29 2006-09-15 10:45:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -43,20 +43,57 @@ typedef struct record_info { typedef struct records_info *Records; -Record rec_cp(Record rec); +/** \brief marks record for deletion (on file storage) + \param p records handle + \param recpp record pointer + \returns ZEBRA_OK / ZEBRA_FAIL +*/ ZEBRA_RES rec_del(Records p, Record *recpp); -void rec_rm(Record *recpp); + +/** \brief frees record (from memory) + \param recpp record pointer +*/ +void rec_free(Record *recpp); + +/** \brief puts record (writes into file storage) + \param p records handle + \param recpp record pointer + \returns ZEBRA_OK / ZEBRA_FAIL +*/ ZEBRA_RES rec_put(Records p, Record *recpp); + +/** \brief creates new record (to be written to file storage) + \param p records handle + \returns record pointer (or NULL on error) +*/ Record rec_new(Records p); +/** \brief gets record - with given system number + \param p records handle + \param sysno system ID (external number) + \returns record pointer (or NULL on error) +*/ Record rec_get(Records p, SYSNO sysno); + +/** \brief gets root record + \param p records handle + \returns record pointer (or NULL on error) +*/ Record rec_get_root(Records p); ZEBRA_RES rec_close (Records *p); + +/** \brief opens records system + \param bfs block file storage + \param rw read-write flag(0=read only, 1=write) + \param compression_method REC_COMPRESS_ type +*/ Records rec_open(BFiles bfs, int rw, int compression_method); + char *rec_strdup(const char *s, size_t *len); void rec_prstat(Records p); SYSNO rec_sysno_to_int(SYSNO sysno); +/** \brief compression types */ #define REC_COMPRESS_NONE 0 #define REC_COMPRESS_BZIP2 1 diff --git a/index/recindxp.h b/index/recindxp.h index 1ecb6b4..cf5a306 100644 --- a/index/recindxp.h +++ b/index/recindxp.h @@ -1,4 +1,4 @@ -/* $Id: recindxp.h,v 1.19 2006-08-14 10:40:15 adam Exp $ +/* $Id: recindxp.h,v 1.20 2006-09-15 10:45:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -80,6 +80,8 @@ struct record_index_entry { int size; /* size of record or 0 if free entry */ }; +Record rec_cp(Record rec); + YAZ_END_CDECL /* * Local variables: diff --git a/index/retrieve.c b/index/retrieve.c index 5c28b2a..e59ccaa 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $Id: retrieve.c,v 1.44 2006-08-22 13:39:27 adam Exp $ +/* $Id: retrieve.c,v 1.45 2006-09-15 10:45:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -155,7 +155,7 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, *rec_lenp = rec->size[recInfo_storeData]; *rec_bufp = (char *) odr_malloc(odr, *rec_lenp); memcpy(*rec_bufp, rec->info[recInfo_storeData], *rec_lenp); - rec_rm (&rec); + rec_free(&rec); stream.destroy(&stream); return 0; } @@ -178,7 +178,7 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, { yaz_log (YLOG_WARN|YLOG_ERRNO, "Retrieve fail; missing file: %s", full_rep); - rec_rm (&rec); + rec_free(&rec); stream.destroy(&stream); return 14; } @@ -190,7 +190,7 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, *rec_lenp = recordAttr->recordSize; *rec_bufp = (char *) odr_malloc(odr, *rec_lenp); stream.readf(&stream, *rec_bufp, *rec_lenp); - rec_rm (&rec); + rec_free(&rec); stream.destroy(&stream); return 0; } @@ -259,7 +259,7 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, stream.destroy(&stream); - rec_rm (&rec); + rec_free(&rec); *addinfo = retrieveCtrl.addinfo; return retrieveCtrl.diagnostic; diff --git a/index/zinfo.c b/index/zinfo.c index 9684111..669f366 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.68 2006-08-14 10:40:15 adam Exp $ +/* $Id: zinfo.c,v 1.69 2006-09-15 10:45:13 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -491,7 +491,7 @@ ZebraExplainInfo zebraExplain_open( yaz_log(YLOG_DEBUG, "read runnumber=" ZINT_FORMAT, zei->runNumber); *zdip = NULL; } - rec_rm(&trec); + rec_free(&trec); } else /* create initial targetInfo */ { @@ -543,7 +543,7 @@ ZebraExplainInfo zebraExplain_open( trec->size[recInfo_storeData] = sgml_len; rec_put(records, &trec); - rec_rm(&trec); + rec_free(&trec); } zebraExplain_newDatabase(zei, "IR-Explain-1", 0); @@ -693,7 +693,7 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, } *zsuip = NULL; zad->readFlag = 0; - rec_rm (&rec); + rec_free(&rec); } static void zebraExplain_readDatabase (ZebraExplainInfo zei, @@ -738,7 +738,7 @@ static void zebraExplain_readDatabase (ZebraExplainInfo zei, np->child->u.data.len); } zdi->readFlag = 0; - rec_rm (&rec); + rec_free(&rec); } int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *update_handle) @@ -762,12 +762,12 @@ int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *update_handle) rec = rec_get(zei->records, zad->sysno); (*zei->updateFunc)(zei->updateHandle, rec, 0); - rec_rm(&rec); + rec_free(&rec); } /* remove database record keys and delete it */ rec = rec_get (zei->records, zdi->sysno); (*zei->updateFunc)(zei->updateHandle, rec, 0); - rec_rm(&rec); + rec_free(&rec); /* remove from list */ *zdip = zdi->next; -- 1.7.10.4