X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzinfo.c;h=4f5509b8ed379e241764f3957f461585eb41faac;hb=5adb31268b057741850de38eafd42baf8dc947ea;hp=cceff987dd48a272bb982650123747076cd5226a;hpb=0f6cf21e0feb7059bbd7576a44ac61470eb09d0b;p=idzebra-moved-to-github.git diff --git a/index/zinfo.c b/index/zinfo.c index cceff98..4f5509b 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,68 +1,9 @@ /* - * Copyright (C) 1994-1999, Index Data + * Copyright (C) 1994-2002, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Log: zinfo.c,v $ - * Revision 1.17 1999-07-14 10:53:51 adam - * Updated various routines to handle missing explain schema. - * - * Revision 1.16 1999/05/26 07:49:13 adam - * C++ compilation. - * - * Revision 1.15 1999/01/25 13:47:54 adam - * Fixed bug. - * - * Revision 1.14 1998/11/04 16:31:32 adam - * Fixed bug regarding recordBytes in databaseInfo. - * - * Revision 1.13 1998/11/03 10:17:09 adam - * Fixed bug regarding creation of some data1 nodes for Explain records. - * - * Revision 1.12 1998/10/13 20:37:11 adam - * Changed the way attribute sets are saved in Explain database to - * reflect "dynamic" OIDs. - * - * Revision 1.11 1998/06/09 12:16:48 adam - * Implemented auto-generation of CategoryList records. - * - * Revision 1.10 1998/06/08 14:43:15 adam - * Added suport for EXPLAIN Proxy servers - added settings databasePath - * and explainDatabase to facilitate this. Increased maximum number - * of databases and attributes in one register. - * - * Revision 1.9 1998/06/02 12:10:27 adam - * Fixed bug related to attributeDetails. - * - * Revision 1.8 1998/05/20 10:12:20 adam - * Implemented automatic EXPLAIN database maintenance. - * Modified Zebra to work with ASN.1 compiled version of YAZ. - * - * Revision 1.7 1998/03/05 08:45:13 adam - * New result set model and modular ranking system. Moved towards - * descent server API. System information stored as "SGML" records. - * - * Revision 1.6 1998/02/17 10:29:27 adam - * Moved towards 'automatic' EXPLAIN database. - * - * Revision 1.5 1997/10/27 14:33:05 adam - * Moved towards generic character mapping depending on "structure" - * field in abstract syntax file. Fixed a few memory leaks. Fixed - * bug with negative integers when doing searches with relational - * operators. - * - * Revision 1.4 1997/09/25 14:57:08 adam - * Added string.h. - * - * Revision 1.3 1996/05/22 08:21:59 adam - * Added public ZebDatabaseInfo structure. - * - * Revision 1.2 1996/05/14 06:16:41 adam - * Compact use/set bytes used in search service. - * - * Revision 1.1 1996/05/13 14:23:07 adam - * Work on compaction of set/use bytes in dictionary. - * + * $Id: zinfo.c,v 1.24 2002-02-20 23:07:54 adam Exp $ */ #include @@ -179,16 +120,11 @@ static data1_node *data1_add_tag (data1_handle dh, data1_node *at, const char *tag, NMEM nmem) { data1_node *partag = get_parent_tag(dh, at); - data1_node *res = data1_mk_node (dh, nmem); + data1_node *res = data1_mk_node_type (dh, nmem, DATA1N_tag); data1_element *e = NULL; res->parent = at; - res->which = DATA1N_tag; res->u.tag.tag = data1_insert_string (dh, res, nmem, tag); - res->u.tag.node_selected = 0; - res->u.tag.make_variantlist = 0; - res->u.tag.no_data_requested = 0; - res->u.tag.get_bytes = -1; if (partag) e = partag->u.tag.element; @@ -331,17 +267,16 @@ static Record createRecord (Records records, int *sysno) return rec; } -void zebraExplain_close (ZebraExplainInfo zei, int writeFlag, - int (*updateH)(Record drec, data1_node *n)) +void zebraExplain_flush (ZebraExplainInfo zei, int writeFlag, void *handle) { - struct zebDatabaseInfoB *zdi; - - logf (LOG_DEBUG, "zebraExplain_close wr=%d", writeFlag); if (!zei) - return; + return; + zei->updateHandle = handle; if (writeFlag) { + struct zebDatabaseInfoB *zdi; zebAccessObject o; + /* write each database info record */ for (zdi = zei->databaseInfo; zdi; zdi = zdi->next) { @@ -370,8 +305,17 @@ void zebraExplain_close (ZebraExplainInfo zei, int writeFlag, zdi->databaseName, 0); } zebraExplain_writeTarget (zei, 0); - } +} + +void zebraExplain_close (ZebraExplainInfo zei, int writeFlag) +{ +#if ZINFO_DEBUG + logf (LOG_LOG, "zebraExplain_close wr=%d", writeFlag); +#endif + if (!zei) + return; + zebraExplain_flush (zei, writeFlag, zei->updateHandle); nmem_destroy (zei->nmem); } @@ -454,7 +398,9 @@ ZebraExplainInfo zebraExplain_open ( struct tm *tm; NMEM nmem = nmem_create (); - logf (LOG_DEBUG, "zebraExplain_open wr=%d", writeFlag); +#if ZINFO_DEBUG + logf (LOG_LOG, "zebraExplain_open wr=%d", writeFlag); +#endif zei = (ZebraExplainInfo) nmem_malloc (nmem, sizeof(*zei)); zei->updateHandle = updateHandle; zei->updateFunc = updateFunc; @@ -480,16 +426,19 @@ ZebraExplainInfo zebraExplain_open ( zdip = &zei->databaseInfo; trec = rec_get (records, 1); /* get "root" record */ + zei->ordinalSU = 1; + zei->runNumber = 0; + zebraExplain_mergeAccessInfo (zei, 0, &zei->accessInfo); if (trec) /* targetInfo already exists ... */ { data1_node *node_tgtinfo, *node_zebra, *node_list, *np; zei->data1_target = read_sgml_rec (zei->dh, zei->nmem, trec); - if (!zei->data1_target) + if (!zei->data1_target || !zei->data1_target->u.root.absyn) { - rec_rm (&trec); - nmem_destroy(zei->nmem); + logf (LOG_FATAL, "Explain schema missing. Check profilePath"); + nmem_destroy (zei->nmem); return 0; } #if ZINFO_DEBUG @@ -502,9 +451,15 @@ ZebraExplainInfo zebraExplain_open ( node_zebra = data1_search_tag (zei->dh, node_tgtinfo->child, "zebraInfo"); - node_list = data1_search_tag (zei->dh, node_zebra->child, - "databaseList"); - for (np = node_list->child; np; np = np->next) + np = 0; + if (node_zebra) + { + node_list = data1_search_tag (zei->dh, node_zebra->child, + "databaseList"); + if (node_list) + np = node_list->child; + } + for (; np; np = np->next) { data1_node *node_name = NULL; data1_node *node_id = NULL; @@ -551,25 +506,26 @@ ZebraExplainInfo zebraExplain_open ( zdip = &(*zdip)->next; } - np = data1_search_tag (zei->dh, node_zebra->child, - "ordinalSU"); - np = np->child; - assert (np && np->which == DATA1N_data); - zei->ordinalSU = atoi_n (np->u.data.data, np->u.data.len); - - np = data1_search_tag (zei->dh, node_zebra->child, - "runNumber"); - np = np->child; - assert (np && np->which == DATA1N_data); - zei->runNumber = atoi_n (np->u.data.data, np->u.data.len); - *zdip = NULL; + if (node_zebra) + { + np = data1_search_tag (zei->dh, node_zebra->child, + "ordinalSU"); + np = np->child; + assert (np && np->which == DATA1N_data); + zei->ordinalSU = atoi_n (np->u.data.data, np->u.data.len); + + np = data1_search_tag (zei->dh, node_zebra->child, + "runNumber"); + np = np->child; + assert (np && np->which == DATA1N_data); + zei->runNumber = atoi_n (np->u.data.data, np->u.data.len); + *zdip = NULL; + } rec_rm (&trec); } else /* create initial targetInfo */ { data1_node *node_tgtinfo; - zei->ordinalSU = 1; - zei->runNumber = 0; *zdip = NULL; if (writeFlag) @@ -585,9 +541,9 @@ ZebraExplainInfo zebraExplain_open ( "1\n" "Zebra\n" "\n" ); - - if (!zei->data1_target) + if (!zei->data1_target || !zei->data1_target->u.root.absyn) { + logf (LOG_FATAL, "Explain schema missing. Check profilePath"); nmem_destroy (zei->nmem); return 0; } @@ -738,7 +694,7 @@ static void zebraExplain_readDatabase (ZebraExplainInfo zei, { zdi->recordCount = atoi_n (np->child->u.data.data, np->child->u.data.len); - } + } zdi->readFlag = 0; rec_rm (&rec); } @@ -1345,6 +1301,25 @@ int zebraExplain_lookupSU (ZebraExplainInfo zei, int set, int use) return -1; } +int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, + const char **db, int *set, int *use) +{ + struct zebDatabaseInfoB *zdb; + for (zdb = zei->databaseInfo; zdb; zdb = zdb->next) + { + struct zebSUInfoB *zsui = zdb->attributeDetails->SUInfo; + for ( ;zsui; zsui = zsui->next) + if (zsui->info.ordinal == ord) + { + *db = zdb->databaseName; + *set = zsui->info.set; + *use = zsui->info.use; + return 0; + } + } + return -1; +} + zebAccessObject zebraExplain_announceOid (ZebraExplainInfo zei, zebAccessObject *op, Odr_oid *oid)