1 /* $Id: zsets.c,v 1.89 2005-06-09 10:39:53 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
33 #include <yaz/diagbib1.h>
36 #define SORT_IDX_ENTRYSIZE 64
37 #define ZSET_SORT_MAX_LEVEL 3
39 struct zebra_set_term_entry {
51 NMEM rset_nmem; /* for creating the rsets in */
56 struct zset_sort_info *sort_info;
57 struct zebra_set_term_entry *term_entries;
59 struct zebra_set *next;
62 zint cache_position; /* last position */
63 RSFD cache_rfd; /* rfd (NULL if not existing) */
64 zint cache_psysno; /* sysno for last position */
65 zint approx_limit; /* limit before we do approx */
68 struct zset_sort_entry {
71 char buf[ZSET_SORT_MAX_LEVEL][SORT_IDX_ENTRYSIZE];
74 struct zset_sort_info {
77 struct zset_sort_entry *all_entries;
78 struct zset_sort_entry **entries;
81 static int log_level_set=0;
82 static int log_level_sort=0;
83 static int log_level_searchhits=0;
84 static int log_level_searchterms=0;
85 static int log_level_resultsets=0;
87 static void loglevels()
91 log_level_sort = yaz_log_module_level("sorting");
92 log_level_searchhits = yaz_log_module_level("searchhits");
93 log_level_searchterms = yaz_log_module_level("searchterms");
94 log_level_resultsets = yaz_log_module_level("resultsets");
98 ZEBRA_RES resultSetSearch(ZebraHandle zh, NMEM nmem, NMEM rset_nmem,
99 Z_RPNQuery *rpn, ZebraSet sset)
103 Z_SortKeySpecList *sort_sequence;
105 ZEBRA_RES res = ZEBRA_OK;
109 sort_sequence = (Z_SortKeySpecList *)
110 nmem_malloc(nmem, sizeof(*sort_sequence));
111 sort_sequence->num_specs = 10; /* FIXME - Hard-coded number */
112 sort_sequence->specs = (Z_SortKeySpec **)
113 nmem_malloc(nmem, sort_sequence->num_specs *
114 sizeof(*sort_sequence->specs));
115 for (i = 0; i<sort_sequence->num_specs; i++)
116 sort_sequence->specs[i] = 0;
118 attrset = oid_getentbyoid (rpn->attributeSetId);
119 res = rpn_search_top(zh, rpn->RPNStructure, attrset->value,
122 sset->num_bases, sset->basenames,
129 for (i = 0; sort_sequence->specs[i]; i++)
131 sort_sequence->num_specs = i;
132 rset->hits_limit = sset->approx_limit;
135 res = resultSetRank (zh, sset, rset, rset_nmem);
139 res = resultSetSortSingle (zh, nmem, sset, rset,
140 sort_sequence, &sort_status);
147 ZEBRA_RES resultSetAddRPN (ZebraHandle zh, NMEM m, Z_RPNQuery *rpn,
148 int num_bases, char **basenames,
157 zebraSet = resultSetAdd(zh, setname, 1);
160 zebraSet->locked = 1;
163 zebraSet->rset_nmem = nmem_create();
165 zebraSet->num_bases = num_bases;
166 zebraSet->basenames =
167 nmem_malloc (zebraSet->nmem, num_bases * sizeof(*zebraSet->basenames));
168 for (i = 0; i<num_bases; i++)
169 zebraSet->basenames[i] = nmem_strdup(zebraSet->nmem, basenames[i]);
171 res = resultSetSearch(zh, zebraSet->nmem, zebraSet->rset_nmem,
173 zh->hits = zebraSet->hits;
176 zebraSet->locked = 0;
182 void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type,
183 const char *db, int set,
184 int use, const char *term)
186 assert(zh); /* compiler shut up */
188 s->nmem = nmem_create ();
189 if (!s->term_entries)
192 s->term_entries_max = 1000;
194 nmem_malloc (s->nmem, s->term_entries_max *
195 sizeof(*s->term_entries));
196 for (i = 0; i < s->term_entries_max; i++)
197 s->term_entries[i].term = 0;
199 if (s->hits < s->term_entries_max)
201 s->term_entries[s->hits].reg_type = reg_type;
202 s->term_entries[s->hits].db = nmem_strdup (s->nmem, db);
203 s->term_entries[s->hits].set = set;
204 s->term_entries[s->hits].use = use;
205 s->term_entries[s->hits].term = nmem_strdup (s->nmem, term);
210 ZebraSet resultSetAdd(ZebraHandle zh, const char *name, int ov)
215 for (s = zh->sets; s; s = s->next)
216 if (!strcmp (s->name, name))
223 yaz_log(log_level_resultsets, "updating result set %s", name);
224 if (!ov || s->locked)
229 rset_close(s->cache_rfd);
230 rset_delete (s->rset);
233 nmem_destroy (s->rset_nmem);
235 nmem_destroy (s->nmem);
239 const char *sort_max_str = zebra_get_resource(zh, "sortmax", "1000");
241 yaz_log(log_level_resultsets, "adding result set %s", name);
242 s = (ZebraSet) xmalloc (sizeof(*s));
245 s->name = (char *) xmalloc (strlen(name)+1);
246 strcpy (s->name, name);
248 s->sort_info = (struct zset_sort_info *)
249 xmalloc (sizeof(*s->sort_info));
250 s->sort_info->max_entries = atoi(sort_max_str);
251 if (s->sort_info->max_entries < 2)
252 s->sort_info->max_entries = 2;
254 s->sort_info->entries = (struct zset_sort_entry **)
255 xmalloc (sizeof(*s->sort_info->entries) *
256 s->sort_info->max_entries);
257 s->sort_info->all_entries = (struct zset_sort_entry *)
258 xmalloc (sizeof(*s->sort_info->all_entries) *
259 s->sort_info->max_entries);
260 for (i = 0; i < s->sort_info->max_entries; i++)
261 s->sort_info->entries[i] = s->sort_info->all_entries + i;
270 s->cache_position = 0;
272 s->approx_limit = zh->approx_limit;
276 ZebraSet resultSetGet(ZebraHandle zh, const char *name)
280 for (s = zh->sets; s; s = s->next)
281 if (!strcmp (s->name, name))
283 if (!s->term_entries && !s->rset && s->rpn)
285 NMEM nmem = nmem_create ();
286 yaz_log(log_level_resultsets, "research %s", name);
288 s->rset_nmem=nmem_create();
289 resultSetSearch(zh, nmem, s->rset_nmem, s->rpn, s);
297 void resultSetInvalidate (ZebraHandle zh)
299 ZebraSet s = zh->sets;
301 yaz_log(log_level_resultsets, "invalidating result sets");
302 for (; s; s = s->next)
307 rset_close(s->cache_rfd);
308 rset_delete (s->rset);
312 s->cache_position = 0;
314 nmem_destroy(s->rset_nmem);
319 void resultSetDestroy(ZebraHandle zh, int num, char **names,int *statuses)
321 ZebraSet * ss = &zh->sets;
325 for (i = 0; i<num; i++)
326 statuses[i] = Z_DeleteStatus_resultSetDidNotExist;
333 for (i = 0; i<num; i++)
334 if (!strcmp (s->name, names[i]))
337 statuses[i] = Z_DeleteStatus_success;
346 xfree (s->sort_info->all_entries);
347 xfree (s->sort_info->entries);
348 xfree (s->sort_info);
351 nmem_destroy (s->nmem);
355 rset_close(s->cache_rfd);
356 rset_delete (s->rset);
359 nmem_destroy(s->rset_nmem);
368 ZebraMetaRecord *zebra_meta_records_create_range(ZebraHandle zh,
373 zint *pos = pos_small;
377 if (num > 10000 || num <= 0)
381 pos = xmalloc(sizeof(*pos) * num);
383 for (i = 0; i<num; i++)
386 mr = zebra_meta_records_create(zh, name, num, pos);
393 ZebraMetaRecord *zebra_meta_records_create(ZebraHandle zh, const char *name,
394 int num, zint *positions)
397 ZebraMetaRecord *sr = 0;
400 struct zset_sort_info *sort_info;
404 if (!(sset = resultSetGet (zh, name)))
406 if (!(rset = sset->rset))
408 if (!sset->term_entries)
410 sr = (ZebraMetaRecord *) xmalloc (sizeof(*sr) * num);
411 for (i = 0; i<num; i++)
418 if (positions[i] <= sset->term_entries_max)
420 sr[i].term = sset->term_entries[positions[i]-1].term;
421 sr[i].db = sset->term_entries[positions[i]-1].db;
427 sr = (ZebraMetaRecord *) xmalloc (sizeof(*sr) * num);
428 for (i = 0; i<num; i++)
435 sort_info = sset->sort_info;
440 for (i = 0; i<num; i++)
442 position = positions[i];
443 if (position > 0 && position <= sort_info->num_entries)
445 yaz_log(log_level_sort, "got pos=" ZINT_FORMAT
446 " (sorted)", position);
447 sr[i].sysno = sort_info->entries[position-1]->sysno;
448 sr[i].score = sort_info->entries[position-1]->score;
452 /* did we really get all entries using sort ? */
453 for (i = 0; i<num; i++)
458 if (i < num) /* nope, get the rest, unsorted - sorry */
467 position = sort_info->num_entries;
468 while (num_i < num && positions[num_i] <= position)
471 if (sset->cache_rfd &&
472 num_i < num && positions[num_i] > sset->cache_position)
474 position = sset->cache_position;
475 rfd = sset->cache_rfd;
476 psysno = sset->cache_psysno;
481 rset_close(sset->cache_rfd);
482 rfd = rset_open (rset, RSETF_READ);
484 while (num_i < num && rset_read (rfd, &key, 0))
486 zint this_sys = key.mem[0];
487 if (this_sys != psysno)
492 /* determine we alreay have this in our set */
493 for (i = sort_info->num_entries; --i >= 0; )
494 if (psysno == sort_info->entries[i]->sysno)
500 assert (num_i < num);
501 if (position == positions[num_i])
503 sr[num_i].sysno = psysno;
504 yaz_log(log_level_sort, "got pos=" ZINT_FORMAT " (unsorted)", position);
505 sr[num_i].score = -1;
510 sset->cache_position = position;
511 sset->cache_psysno = psysno;
512 sset->cache_rfd = rfd;
518 void zebra_meta_records_destroy (ZebraHandle zh, ZebraMetaRecord *records,
521 assert(zh); /* compiler shut up about unused arg */
531 void resultSetInsertSort (ZebraHandle zh, ZebraSet sset,
532 struct sortKeyInfo *criteria, int num_criteria,
535 struct zset_sort_entry this_entry;
536 struct zset_sort_entry *new_entry = NULL;
537 struct zset_sort_info *sort_info = sset->sort_info;
540 sortIdx_sysno (zh->reg->sortIdx, sysno);
541 for (i = 0; i<num_criteria; i++)
543 sortIdx_type (zh->reg->sortIdx, criteria[i].attrUse);
544 sortIdx_read (zh->reg->sortIdx, this_entry.buf[i]);
546 i = sort_info->num_entries;
550 for (j = 0; j<num_criteria; j++)
552 if (criteria[j].numerical)
554 double diff = atof(this_entry.buf[j]) -
555 atof(sort_info->entries[i]->buf[j]);
564 rel = memcmp (this_entry.buf[j], sort_info->entries[i]->buf[j],
572 if (criteria[j].relation == 'A')
577 else if (criteria[j].relation == 'D')
584 j = sort_info->max_entries;
588 if (sort_info->num_entries == j)
591 j = (sort_info->num_entries)++;
592 new_entry = sort_info->entries[j];
595 sort_info->entries[j] = sort_info->entries[j-1];
598 sort_info->entries[i] = new_entry;
600 for (i = 0; i<num_criteria; i++)
601 memcpy (new_entry->buf[i], this_entry.buf[i], SORT_IDX_ENTRYSIZE);
602 new_entry->sysno = sysno;
603 new_entry->score = -1;
606 void resultSetInsertRank (ZebraHandle zh, struct zset_sort_info *sort_info,
607 zint sysno, int score, int relation)
609 struct zset_sort_entry *new_entry = NULL;
611 assert(zh); /* compiler shut up about unused arg */
613 i = sort_info->num_entries;
618 rel = score - sort_info->entries[i]->score;
625 else if (relation == 'A')
632 j = sort_info->max_entries;
636 if (sort_info->num_entries == j)
639 j = (sort_info->num_entries)++;
641 new_entry = sort_info->entries[j];
644 sort_info->entries[j] = sort_info->entries[j-1];
647 sort_info->entries[i] = new_entry;
649 new_entry->sysno = sysno;
650 new_entry->score = score;
653 ZEBRA_RES resultSetSort(ZebraHandle zh, NMEM nmem,
654 int num_input_setnames, const char **input_setnames,
655 const char *output_setname,
656 Z_SortKeySpecList *sort_sequence, int *sort_status)
661 if (num_input_setnames == 0)
663 zebra_setError(zh, YAZ_BIB1_NO_RESULT_SET_NAME_SUPPLIED_ON_SORT, 0);
666 if (num_input_setnames > 1)
668 zebra_setError(zh, YAZ_BIB1_SORT_TOO_MANY_INPUT_RESULTS, 0);
673 yaz_log(log_level_sort, "result set sort input=%s output=%s",
674 *input_setnames, output_setname);
675 sset = resultSetGet (zh, input_setnames[0]);
678 zebra_setError(zh, YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
682 if (!(rset = sset->rset))
684 zebra_setError(zh, YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
688 if (strcmp (output_setname, input_setnames[0]))
690 rset = rset_dup (rset);
691 sset = resultSetAdd (zh, output_setname, 1);
694 return resultSetSortSingle (zh, nmem, sset, rset, sort_sequence,
698 ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem,
699 ZebraSet sset, RSET rset,
700 Z_SortKeySpecList *sort_sequence,
708 struct sortKeyInfo sort_criteria[3];
715 assert(nmem); /* compiler shut up about unused param */
716 sset->sort_info->num_entries = 0;
718 rset_getterms(rset, 0, 0, &n);
719 terms = (TERMID *) nmem_malloc(nmem, sizeof(*terms)*n);
720 rset_getterms(rset, terms, n, &numTerms);
723 num_criteria = sort_sequence->num_specs;
724 if (num_criteria > 3)
726 for (i = 0; i < num_criteria; i++)
728 Z_SortKeySpec *sks = sort_sequence->specs[i];
731 if (*sks->sortRelation == Z_SortKeySpec_ascending)
732 sort_criteria[i].relation = 'A';
733 else if (*sks->sortRelation == Z_SortKeySpec_descending)
734 sort_criteria[i].relation = 'D';
737 zebra_setError(zh, YAZ_BIB1_ILLEGAL_SORT_RELATION, 0);
740 if (sks->sortElement->which == Z_SortElement_databaseSpecific)
742 zebra_setError(zh, YAZ_BIB1_DATABASE_SPECIFIC_SORT_UNSUPP, 0);
745 else if (sks->sortElement->which != Z_SortElement_generic)
747 zebra_setError(zh, YAZ_BIB1_SORT_ILLEGAL_SORT, 0);
750 sk = sks->sortElement->u.generic;
753 case Z_SortKey_sortField:
754 yaz_log(log_level_sort, "key %d is of type sortField",
756 zebra_setError(zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
758 case Z_SortKey_elementSpec:
759 yaz_log(log_level_sort, "key %d is of type elementSpec",
761 zebra_setError(zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
763 case Z_SortKey_sortAttributes:
764 yaz_log(log_level_sort, "key %d is of type sortAttributes", i+1);
765 sort_criteria[i].attrUse =
766 zebra_maps_sort (zh->reg->zebra_maps,
767 sk->u.sortAttributes,
768 &sort_criteria[i].numerical);
769 yaz_log(log_level_sort, "use value = %d", sort_criteria[i].attrUse);
770 if (sort_criteria[i].attrUse == -1)
773 zh, YAZ_BIB1_USE_ATTRIBUTE_REQUIRED_BUT_NOT_SUPPLIED, 0);
776 if (sortIdx_type (zh->reg->sortIdx, sort_criteria[i].attrUse))
779 zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
785 rfd = rset_open (rset, RSETF_READ);
786 while (rset_read (rfd, &key, &termid))
788 zint this_sys = key.mem[0];
789 if (log_level_searchhits)
790 key_logdump_txt(log_level_searchhits, &key, termid->name);
792 if (this_sys != psysno)
796 resultSetInsertSort (zh, sset,
797 sort_criteria, num_criteria, psysno);
801 yaz_log(log_level_sort, ZINT_FORMAT " keys, " ZINT_FORMAT " sysnos, sort",
803 for (i = 0; i < numTerms; i++)
804 yaz_log(log_level_sort, "term=\"%s\" type=%s count=" ZINT_FORMAT,
805 terms[i]->name, terms[i]->flags, terms[i]->rset->hits_count);
806 *sort_status = Z_SortResponse_success;
810 RSET resultSetRef(ZebraHandle zh, const char *resultSetId)
814 if ((s = resultSetGet (zh, resultSetId)))
819 ZEBRA_RES resultSetRank(ZebraHandle zh, ZebraSet zebraSet,
820 RSET rset, NMEM nmem)
829 ZebraRankClass rank_class;
830 struct zset_sort_info *sort_info;
831 const char *rank_handler_name = res_get_def(zh->res, "rank", "rank-1");
835 sort_info = zebraSet->sort_info;
836 sort_info->num_entries = 0;
838 rset_getterms(rset, 0, 0, &n);
839 terms = (TERMID *) nmem_malloc(nmem, sizeof(*terms)*n);
840 rset_getterms(rset, terms, n, &numTerms);
842 rank_class = zebraRankLookup(zh, rank_handler_name);
845 yaz_log(YLOG_WARN, "No such rank handler: %s", rank_handler_name);
846 zebra_setError(zh, YAZ_BIB1_UNSUPP_SEARCH, "Cannot find rank handler");
851 RSFD rfd = rset_open(rset, RSETF_READ);
852 struct rank_control *rc = rank_class->control;
857 (*rc->begin) (zh->reg, rank_class->class_handle, rset, nmem,
860 while (rset_read(rfd, &key, &termid))
862 zint this_sys = key.mem[0];
863 zint seqno = key.mem[key.len-1];
865 if (log_level_searchhits)
866 key_logdump_txt(log_level_searchhits, &key, termid->name);
867 if (this_sys != psysno)
869 if (rfd->counted_items >= rset->hits_limit)
873 score = (*rc->calc) (handle, psysno);
874 resultSetInsertRank (zh, sort_info, psysno, score, 'A');
879 (*rc->add) (handle, CAST_ZINT_TO_INT(seqno), termid);
883 score = (*rc->calc)(handle, psysno);
884 resultSetInsertRank(zh, sort_info, psysno, score, 'A');
887 (*rc->end) (zh->reg, handle);
890 zebraSet->hits = rset->hits_count;
892 yaz_log(log_level_searchterms, ZINT_FORMAT " keys, "
893 ZINT_FORMAT " sysnos, rank", kno, zebraSet->hits);
894 for (i = 0; i < numTerms; i++)
896 yaz_log(log_level_searchterms, "term=\"%s\" type=%s count="
898 terms[i]->name, terms[i]->flags, terms[i]->rset->hits_count);
903 ZebraRankClass zebraRankLookup(ZebraHandle zh, const char *name)
905 ZebraRankClass p = zh->reg->rank_classes;
906 while (p && strcmp (p->control->name, name))
908 if (p && !p->init_flag)
910 if (p->control->create)
911 p->class_handle = (*p->control->create)(zh);
917 void zebraRankInstall(struct zebra_register *reg, struct rank_control *ctrl)
919 ZebraRankClass p = (ZebraRankClass) xmalloc (sizeof(*p));
920 p->control = (struct rank_control *) xmalloc (sizeof(*p->control));
921 memcpy (p->control, ctrl, sizeof(*p->control));
922 p->control->name = xstrdup (ctrl->name);
924 p->next = reg->rank_classes;
925 reg->rank_classes = p;
928 void zebraRankDestroy(struct zebra_register *reg)
930 ZebraRankClass p = reg->rank_classes;
933 ZebraRankClass p_next = p->next;
934 if (p->init_flag && p->control->destroy)
935 (*p->control->destroy)(reg, p->class_handle);
936 xfree(p->control->name);
941 reg->rank_classes = NULL;
944 static int trav_rset_for_termids(RSET rset, TERMID *termid_array,
945 zint *hits_array, int *approx_array)
949 for (i = 0; i<rset->no_children; i++)
950 no += trav_rset_for_termids(rset->children[i],
951 (termid_array ? termid_array + no : 0),
952 (hits_array ? hits_array + no : 0),
953 (approx_array ? approx_array + no : 0));
957 termid_array[no] = rset->term;
959 hits_array[no] = rset->hits_count;
961 approx_array[no] = rset->hits_approx;
963 yaz_log(YLOG_LOG, "rset=%p term=%s count=" ZINT_FORMAT,
964 rset, rset->term->name, rset->hits_count);
971 ZEBRA_RES zebra_result_set_term_no(ZebraHandle zh, const char *setname,
974 ZebraSet sset = resultSetGet(zh, setname);
978 *num_terms = trav_rset_for_termids(sset->rset, 0, 0, 0);
984 ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname,
985 int no, zint *count, int *approx,
986 char *termbuf, size_t *termlen)
988 ZebraSet sset = resultSetGet(zh, setname);
991 int num_terms = trav_rset_for_termids(sset->rset, 0, 0, 0);
992 if (no >= 0 && no < num_terms)
994 TERMID *term_array = xmalloc(num_terms * sizeof(*term_array));
995 zint *hits_array = xmalloc(num_terms * sizeof(*hits_array));
996 int *approx_array = xmalloc(num_terms * sizeof(*approx_array));
998 trav_rset_for_termids(sset->rset, term_array,
999 hits_array, approx_array);
1002 *count = hits_array[no];
1004 *approx = approx_array[no];
1007 char *inbuf = term_array[no]->name;
1008 size_t inleft = strlen(inbuf);
1009 size_t outleft = *termlen - 1;
1011 if (zh->iconv_from_utf8 != 0)
1013 char *outbuf = termbuf;
1016 ret = yaz_iconv(zh->iconv_from_utf8, &inbuf, &inleft,
1018 if (ret == (size_t)(-1))
1021 *termlen = outbuf - termbuf;
1025 if (inleft > outleft)
1028 memcpy(termbuf, inbuf, *termlen);
1030 termbuf[*termlen] = '\0';
1035 xfree(approx_array);
1042 ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname,
1043 zint sysno, zebra_snippets *snippets)
1045 ZebraSet sset = resultSetGet(zh, setname);
1046 yaz_log(YLOG_LOG, "zebra_get_hit_vector setname=%s zysno=" ZINT_FORMAT,
1052 struct rset_key_control *kc = zebra_key_control_create(zh);
1053 NMEM nmem = nmem_create();
1055 RSET rsets[2], rset_comb;
1056 RSET rset_temp = rstemp_create(nmem, kc, kc->scope,
1057 res_get (zh->res, "setTmpDir"),0 );
1060 RSFD rsfd = rset_open(rset_temp, RSETF_WRITE);
1067 rset_write (rsfd, &key);
1070 rsets[0] = rset_temp;
1071 rsets[1] = rset_dup(sset->rset);
1073 rset_comb = rsmulti_and_create(nmem, kc, kc->scope, 2, rsets);
1075 rsfd = rset_open(rset_comb, RSETF_READ);
1077 while (rset_read(rsfd, &key, &termid))
1081 struct ord_list *ol;
1082 for (ol = termid->ol; ol; ol = ol->next)
1084 zebra_snippets_append(snippets, key.mem[key.len-1],
1086 ol->ord, termid->name);
1092 rset_delete(rset_comb);