X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=3cd3a10ea8180bc3b80800af0ab0d232ab8a0cd0;hb=bb96b42dc69e6dfa37ee277333e6de0df85fb070;hp=577b99a1d606a0a92b06bed5ad8e0008bff25600;hpb=88d48fdfa040774186998d2e318ae69b11591884;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 577b99a..3cd3a10 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -3,7 +3,21 @@ * All rights reserved. * * $Log: zebraapi.c,v $ - * Revision 1.40 2000-11-29 15:21:31 adam + * Revision 1.44 2001-10-15 19:53:43 adam + * POSIX thread updates. First work on term sets. + * + * Revision 1.43 2000/12/05 12:22:53 adam + * Termlist source implemented (so that we can index values of XML/SGML + * attributes). + * + * Revision 1.42 2000/12/05 10:01:44 adam + * Fixed bug regarding user-defined attribute sets. + * + * Revision 1.41 2000/12/01 17:59:08 adam + * Fixed bug regarding online updates on WIN32. + * When zebra.cfg is not available the server will not abort. + * + * Revision 1.40 2000/11/29 15:21:31 adam * Fixed problem with passwd db. * * Revision 1.39 2000/11/29 14:24:01 adam @@ -214,8 +228,12 @@ static int zebra_register_lock (ZebraHandle zh, int rw) logf (LOG_LOG, "Register in read/write mode"); else if (zh->service->registerState == state) { + logf (LOG_DEBUG, "registerChange = %ld lastChange = %ld", + (long) zh->service->registerChange, (long)lastChange); if (zh->service->registerChange >= lastChange) + { return 0; + } logf (LOG_LOG, "Register completely updated since last access"); } else if (zh->service->registerState == -1) @@ -297,7 +315,7 @@ ZebraService zebra_start (const char *configName) if (!(zh->res = res_open (zh->configName))) { logf (LOG_WARN, "Failed to read resources `%s'", zh->configName); - return zh; +// return zh; } zebra_chdir (zh); zebra_server_lock_init (zh); @@ -495,7 +513,11 @@ void zebra_stop(ZebraService zs) return ; yaz_log (LOG_LOG, "zebra_stop"); - assert (!zs->sessions); + zebra_mutex_cond_lock (&zs->session_lock); + while (zs->sessions) + zebra_close (zs->sessions); + + zebra_mutex_cond_unlock (&zs->session_lock); zebra_mutex_cond_destroy (&zs->session_lock); @@ -646,16 +668,15 @@ void zebra_records_retrieve (ZebraHandle zh, ODR stream, { for (i = 0; ierrCode = 13; - zh->errString = nmem_strdup (stream->mem, num_str); - break; + recs[i].errCode = 0; + recs[i].format = VAL_SUTRS; + recs[i].len = strlen(poset[i].term); + recs[i].buf = poset[i].term; + recs[i].base = poset[i].db; } - else + else if (poset[i].sysno) { recs[i].errCode = zebra_record_fetch (zh, poset[i].sysno, poset[i].score, @@ -665,6 +686,15 @@ void zebra_records_retrieve (ZebraHandle zh, ODR stream, &recs[i].base); recs[i].errString = NULL; } + else + { + char num_str[20]; + + sprintf (num_str, "%d", pos_array[i]); + zh->errCode = 13; + zh->errString = nmem_strdup (stream->mem, num_str); + break; + } } zebraPosSetDestroy (zh, poset, num_recs); } @@ -870,6 +900,7 @@ static void extract_add_index_string (RecWord *p, const char *string, int diff = 0; int *pseqno = &p->seqnos[p->reg_type]; ZebraHandle zh = p->extractCtrl->handle; + ZebraExplainInfo zei = zh->service->zei; struct recKeys *keys = &zh->keys; if (keys->buf_used+1024 > keys->buf_max) @@ -905,6 +936,21 @@ static void extract_add_index_string (RecWord *p, const char *string, *dst++ = lead; +#if SU_SCHEME + if ((lead & 3) < 3) + { + int ch = zebraExplain_lookupSU (zei, attrSet, attrUse); + if (ch < 0) + { + ch = zebraExplain_addSU (zei, attrSet, attrUse); + yaz_log (LOG_LOG, "addSU set=%d use=%d SU=%d", + attrSet, attrUse, ch); + } + assert (ch > 0); + memcpy (dst, &ch, sizeof(ch)); + dst += sizeof(ch); + } +#else if (!(lead & 1)) { memcpy (dst, &attrSet, sizeof(attrSet)); @@ -915,6 +961,7 @@ static void extract_add_index_string (RecWord *p, const char *string, memcpy (dst, &attrUse, sizeof(attrUse)); dst += sizeof(attrUse); } +#endif *dst++ = p->reg_type; memcpy (dst, string, length); dst += length; @@ -1250,10 +1297,14 @@ static void extract_flushWriteKeys (ZebraHandle zh) static void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno, int cmd, struct recKeys *reckeys) { +#if SU_SCHEME +#else unsigned char attrSet = (unsigned char) -1; unsigned short attrUse = (unsigned short) -1; +#endif int seqno = 0; int off = 0; + int ch = 0; ZebraExplainInfo zei = zh->service->zei; if (!zh->key_buf) @@ -1270,10 +1321,17 @@ static void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno, { const char *src = reckeys->buf + off; struct it_key key; - int lead, ch; + int lead; lead = *src++; +#if SU_SCHEME + if ((lead & 3) < 3) + { + memcpy (&ch, src, sizeof(ch)); + src += sizeof(ch); + } +#else if (!(lead & 1)) { memcpy (&attrSet, src, sizeof(attrSet)); @@ -1284,18 +1342,21 @@ static void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno, memcpy (&attrUse, src, sizeof(attrUse)); src += sizeof(attrUse); } +#endif if (zh->key_buf_used + 1024 > (zh->ptr_top-zh->ptr_i)*sizeof(char*)) extract_flushWriteKeys (zh); ++(zh->ptr_i); (zh->key_buf)[zh->ptr_top - zh->ptr_i] = (char*)zh->key_buf + zh->key_buf_used; - +#if SU_SCHEME +#else ch = zebraExplain_lookupSU (zei, attrSet, attrUse); if (ch < 0) ch = zebraExplain_addSU (zei, attrSet, attrUse); +#endif assert (ch > 0); zh->key_buf_used += - key_SU_code (ch,((char*)zh->key_buf) + zh->key_buf_used); + key_SU_encode (ch,((char*)zh->key_buf) + zh->key_buf_used); while (*src) ((char*)zh->key_buf) [(zh->key_buf_used)++] = *src++;