-/* $Id: zsets.c,v 1.110 2006-08-14 10:40:15 adam Exp $
- Copyright (C) 1995-2006
+/* $Id: zsets.c,v 1.115 2007-01-15 15:10:17 adam Exp $
+ Copyright (C) 1995-2007
Index Data ApS
This file is part of the Zebra server.
static int log_level_searchterms=0;
static int log_level_resultsets=0;
-static void loglevels()
+static void loglevels(void)
{
if (log_level_set)
return;
log_level_set = 1;
}
+
ZEBRA_RES resultSetSearch(ZebraHandle zh, NMEM nmem, NMEM rset_nmem,
Z_RPNQuery *rpn, ZebraSet sset)
{
sort_sequence->specs[i] = 0;
attrset = oid_getentbyoid (rpn->attributeSetId);
+
+ rpn_get_top_approx_limit(zh, rpn->RPNStructure, &sset->approx_limit);
+
res = rpn_search_top(zh, rpn->RPNStructure, attrset->value,
nmem, rset_nmem,
sort_sequence,
struct sortKeyInfo {
int relation;
-#if 0
- int attrUse;
-#else
int ord;
-#endif
int numerical;
+ int index_type;
};
void resultSetInsertSort(ZebraHandle zh, ZebraSet sset,
struct zset_sort_info *sort_info = sset->sort_info;
int i, j;
- sortIdx_sysno (zh->reg->sortIdx, sysno);
+ zebra_sort_sysno(zh->reg->sort_index, sysno);
for (i = 0; i<num_criteria; i++)
{
char *this_entry_buf = tmp_cmp_buf[i];
memset(this_entry_buf, '\0', SORT_IDX_ENTRYSIZE);
if (criteria[i].ord != -1)
{
- sortIdx_type(zh->reg->sortIdx, criteria[i].ord);
- sortIdx_read(zh->reg->sortIdx, this_entry_buf);
+ zebra_sort_type(zh->reg->sort_index, criteria[i].ord);
+ zebra_sort_read(zh->reg->sort_index, this_entry_buf);
}
}
i = sort_info->num_entries;
cmp_buf[j] + i * SORT_IDX_ENTRYSIZE;
if (criteria[j].numerical)
{
- double diff = atof(this_entry_buf) - atof(other_entry_buf);
- rel = 0;
+ char this_entry_org[1024];
+ char other_entry_org[1024];
+ double diff;
+ int index_type = criteria[j].index_type;
+ zebra_term_untrans(zh, index_type, this_entry_org,
+ this_entry_buf);
+ zebra_term_untrans(zh, index_type, other_entry_org,
+ other_entry_buf);
+ diff = atof(this_entry_org) - atof(other_entry_org);
+
if (diff > 0.0)
rel = 1;
else if (diff < 0.0)
rel = -1;
+ else
+ rel = 0;
}
else
{
sort_criteria[i].ord =
zebraExplain_lookup_attr_str(zh->reg->zei,
zinfo_index_category_sort,
- 's',
- sk->u.sortField);
+ -1, sk->u.sortField);
if (sks->which != Z_SortKeySpec_null
&& sort_criteria[i].ord == -1)
{
case Z_SortKey_sortAttributes:
yaz_log(log_level_sort, "key %d is of type sortAttributes", i+1);
res = zebra_sort_get_ord(zh, sk->u.sortAttributes,
+
&sort_criteria[i].ord,
&sort_criteria[i].numerical);
if (sks->which != Z_SortKeySpec_null && res != ZEBRA_OK)
return ZEBRA_FAIL;
break;
}
+ if (zebraExplain_lookup_ord(zh->reg->zei, sort_criteria[i].ord,
+ &sort_criteria[i].index_type,
+ 0, 0))
+ {
+ zebra_setError(zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
+ return ZEBRA_FAIL;
+ }
}
/* allocate space for each cmpare buf + one extra for tmp comparison */
for (i = 0; i<num_criteria; i++)