struct zset_sort_entry *new_entry = NULL;
struct zset_sort_info *sort_info = sset->sort_info;
int i, j;
+ WRBUF w = wrbuf_alloc();
zebra_sort_sysno(zh->reg->sort_index, sysno);
for (i = 0; i<num_criteria; i++)
yaz_log(log_level_sort, "pre zebra_sort_type ord is %d",
criteria[i].ord[database_no]);
zebra_sort_type(zh->reg->sort_index, criteria[i].ord[database_no]);
- zebra_sort_read(zh->reg->sort_index, this_entry_buf);
+ wrbuf_rewind(w);
+ if (zebra_sort_read(zh->reg->sort_index, w))
+ {
+ int off = 0;
+ while (off != wrbuf_len(w))
+ {
+ size_t l = strlen(wrbuf_buf(w)+off);
+ assert(off < wrbuf_len(w));
+
+ if (l >= SORT_IDX_ENTRYSIZE)
+ l = SORT_IDX_ENTRYSIZE-1;
+ if (off == 0)
+ {
+ memcpy(this_entry_buf, wrbuf_buf(w)+off, l);
+ this_entry_buf[l] = '\0';
+ }
+ else if (criteria[i].relation == 'A')
+ {
+ if (strcmp(wrbuf_buf(w)+off, this_entry_buf) < 0)
+ {
+ memcpy(this_entry_buf, wrbuf_buf(w)+off, l);
+ this_entry_buf[l] = '\0';
+ }
+ }
+ else if (criteria[i].relation == 'D')
+ {
+ if (strcmp(wrbuf_buf(w)+off, this_entry_buf) > 0)
+ {
+ memcpy(this_entry_buf, wrbuf_buf(w)+off, l);
+ this_entry_buf[l] = '\0';
+ }
+ }
+ off += 1 + strlen(wrbuf_buf(w)+off);
+ }
+ }
}
else
{
yaz_log(log_level_sort, "criteria[i].ord is -1 so not reading from sort index");
}
}
+ wrbuf_destroy(w);
i = sort_info->num_entries;
while (--i >= 0)
{
#if 0
yaz_log(YLOG_LOG, "sysno=" ZINT_FORMAT " database_no=%d", this_sys,
database_no);
-#endif
ord_list_print(termid->ol);
+#endif
resultSetInsertSort(zh, sset, database_no,
sort_criteria, num_criteria, psysno, cmp_buf,
tmp_cmp_buf);