X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=e915543db043543ac6f499110ee15725f92ae168;hb=6ba9698e88c0283e40fa5980a1a6b551fff2d597;hp=2c543df325b4738e209e89dbf7e94d0340ffa2d9;hpb=6b1dece7410af50ba077381066c10c44f0188868;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index 2c543df..e915543 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,5 +1,5 @@ -/* $Id: zsets.c,v 1.98 2006-01-19 13:31:08 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: zsets.c,v 1.103 2006-05-19 13:49:35 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -30,6 +30,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #endif #include "index.h" +#include "rank.h" #include #include @@ -268,6 +269,7 @@ ZebraSet resultSetAdd(ZebraHandle zh, const char *name, int ov) s->rset_nmem = 0; s->nmem = 0; s->rpn = 0; + s->sortSpec = 0; s->cache_position = 0; s->cache_rfd = 0; s->approx_limit = zh->approx_limit; @@ -536,7 +538,11 @@ void zebra_meta_records_destroy (ZebraHandle zh, ZebraMetaRecord *records, struct sortKeyInfo { int relation; +#if 0 int attrUse; +#else + int ord; +#endif int numerical; }; @@ -552,7 +558,7 @@ void resultSetInsertSort (ZebraHandle zh, ZebraSet sset, sortIdx_sysno (zh->reg->sortIdx, sysno); for (i = 0; ireg->sortIdx, criteria[i].attrUse); + sortIdx_type (zh->reg->sortIdx, criteria[i].ord); sortIdx_read (zh->reg->sortIdx, this_entry.buf[i]); } i = sort_info->num_entries; @@ -796,7 +802,6 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, if (zh->m_staticrank) sysno_mem_index = 1; - assert(nmem); /* compiler shut up about unused param */ sset->sort_info->num_entries = 0; @@ -838,8 +843,17 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, case Z_SortKey_sortField: yaz_log(log_level_sort, "key %d is of type sortField", i+1); - zebra_setError(zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0); - return ZEBRA_FAIL; + sort_criteria[i].numerical = 0; + sort_criteria[i].ord = + zebraExplain_lookup_attr_str(zh->reg->zei, 's', + sk->u.sortField); + if (sort_criteria[i].ord == -1) + { + zebra_setError(zh, + YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0); + return ZEBRA_FAIL; + } + break; case Z_SortKey_elementSpec: yaz_log(log_level_sort, "key %d is of type elementSpec", i+1); @@ -847,23 +861,11 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, return ZEBRA_FAIL; case Z_SortKey_sortAttributes: yaz_log(log_level_sort, "key %d is of type sortAttributes", i+1); - sort_criteria[i].attrUse = - zebra_maps_sort (zh->reg->zebra_maps, - sk->u.sortAttributes, - &sort_criteria[i].numerical); - yaz_log(log_level_sort, "use value = %d", sort_criteria[i].attrUse); - if (sort_criteria[i].attrUse == -1) - { - zebra_setError( - zh, YAZ_BIB1_USE_ATTRIBUTE_REQUIRED_BUT_NOT_SUPPLIED, 0); - return ZEBRA_FAIL; - } - if (sortIdx_type (zh->reg->sortIdx, sort_criteria[i].attrUse)) - { - zebra_setError( - zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0); + if (zebra_sort_get_ord(zh, sk->u.sortAttributes, + &sort_criteria[i].ord, + &sort_criteria[i].numerical) + != ZEBRA_OK) return ZEBRA_FAIL; - } break; } } @@ -1200,3 +1202,11 @@ ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname, return ZEBRA_OK; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +