X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=4b4c25f85a3d466e85046bea33ab5148cf0d8713;hb=dc017c2fd1686d5a1bb5b04c45f11c69da60421a;hp=974e2deb9a4b1a48654e24cc2210ed229a04d1fb;hpb=ce3907338568fce46c5751e7e1091a5ad1c8e291;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index 974e2de..4b4c25f 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -4,7 +4,15 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zsets.c,v $ - * Revision 1.15 1998-03-05 08:45:14 adam + * Revision 1.17 1998-06-23 15:33:36 adam + * Added feature to specify sort criteria in query (type 7 specifies + * sort flags). + * + * Revision 1.16 1998/05/20 10:12:24 adam + * Implemented automatic EXPLAIN database maintenance. + * Modified Zebra to work with ASN.1 compiled version of YAZ. + * + * Revision 1.15 1998/03/05 08:45:14 adam * New result set model and modular ranking system. Moved towards * descent server API. System information stored as "SGML" records. * @@ -88,6 +96,7 @@ struct zset_sort_entry { struct zset_sort_info { int max_entries; int num_entries; + struct zset_sort_entry *all_entries; struct zset_sort_entry **entries; }; @@ -123,8 +132,10 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov, s->sort_info->max_entries = 1000; s->sort_info->entries = xmalloc (sizeof(*s->sort_info->entries) * s->sort_info->max_entries); + s->sort_info->all_entries = xmalloc (sizeof(*s->sort_info->all_entries) * + s->sort_info->max_entries); for (i = 0; i < s->sort_info->max_entries; i++) - s->sort_info->entries[i] = xmalloc (sizeof(**s->sort_info->entries)); + s->sort_info->entries[i] = s->sort_info->all_entries + i; resultSetRank (zh, s->sort_info, rset, hits); return s; } @@ -146,11 +157,10 @@ void resultSetDestroy (ZebraHandle zh) for (s = zh->sets; s; s = s1) { - int i; s1 = s->next; - for (i = 0; i < s->sort_info->max_entries; i++) - xfree (s->sort_info->entries[i]); + xfree (s->sort_info->all_entries); + xfree (s->sort_info->entries); xfree (s->sort_info); rset_delete (s->rset); @@ -283,12 +293,12 @@ void resultSetInsertSort (ZebraHandle zh, ZebraSet sset, } if (!rel) break; - if (criteria[j].relation == 'D') + if (criteria[j].relation == 'A') { if (rel > 0) break; } - else if (criteria[j].relation == 'A') + else if (criteria[j].relation == 'D') { if (rel < 0) break; @@ -357,9 +367,9 @@ void resultSetInsertRank (ZebraHandle zh, struct zset_sort_info *sort_info, } void resultSetSort (ZebraHandle zh, ODR stream, - int num_input_setnames, char **input_setnames, - char *output_setname, Z_SortKeySpecList *sort_sequence, - int *sort_status) + int num_input_setnames, const char **input_setnames, + const char *output_setname, + Z_SortKeySpecList *sort_sequence, int *sort_status) { ZebraSet sset; RSET rset; @@ -380,17 +390,19 @@ void resultSetSort (ZebraHandle zh, ODR stream, zh->errCode = 230; return; } + logf (LOG_DEBUG, "result set sort input=%s output=%s", + *input_setnames, output_setname); sset = resultSetGet (zh, input_setnames[0]); if (!sset) { zh->errCode = 30; - zh->errString = input_setnames[0]; + zh->errString = nmem_strdup (stream->mem, input_setnames[0]); return; } if (!(rset = sset->rset)) { zh->errCode = 30; - zh->errString = input_setnames[0]; + zh->errString = nmem_strdup (stream->mem, input_setnames[0]); return; } num_criteria = sort_sequence->num_specs;