--- /dev/null
+/* $Id: orddict.h,v 1.1 2006-01-19 13:31:08 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data ApS
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#ifndef ORDDICT_H
+#define ORDDICT_H
+
+#include <yaz/yconfig.h>
+#include <idzebra/dict.h>
+
+YAZ_BEGIN_CDECL
+
+
+typedef struct zebra_ord_dict *Zebra_ord_dict;
+
+Zebra_ord_dict zebra_ord_dict_open(Dict s);
+void zebra_ord_dict_close(Zebra_ord_dict zod);
+char *zebra_ord_dict_lookup (Zebra_ord_dict zod, int ord,
+ const char *p);
+
+YAZ_END_CDECL
+#endif
-/* $Id: zsets.c,v 1.97 2006-01-12 13:21:45 adam Exp $
+/* $Id: zsets.c,v 1.98 2006-01-19 13:31:08 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int num_bases;
char **basenames;
Z_RPNQuery *rpn;
+ Z_SortKeySpecList *sortSpec;
struct zset_sort_info *sort_info;
struct zebra_set_term_entry *term_entries;
int term_entries_max;
if (!s->rset_nmem)
s->rset_nmem=nmem_create();
resultSetSearch(zh, nmem, s->rset_nmem, s->rpn, s);
+ if (s->rset && s->sortSpec)
+ {
+ int sort_status;
+ yaz_log(log_level_resultsets, "resort %s", name);
+ resultSetSortSingle (zh, nmem, s, s->rset, s->sortSpec,
+ &sort_status);
+ }
nmem_destroy (nmem);
}
return s;
new_entry->score = score;
}
-static Z_RPNQuery *copy_RPNQuery(Z_RPNQuery *src_rpn, NMEM dst)
+static Z_RPNQuery *copy_RPNQuery(Z_RPNQuery *src, NMEM nmem)
+{
+ Z_RPNQuery *dst = 0;
+ ODR encode = odr_createmem(ODR_ENCODE);
+ ODR decode = odr_createmem(ODR_DECODE);
+
+ if (z_RPNQuery(encode, &src, 0, 0))
+ {
+ int len;
+ char *buf = odr_getbuf(encode, &len, 0);
+
+ if (buf)
+ {
+ odr_setbuf(decode, buf, len, 0);
+ z_RPNQuery(decode, &dst, 0, 0);
+ }
+ }
+ nmem_transfer(nmem, decode->mem);
+ odr_destroy(encode);
+ odr_destroy(decode);
+ return dst;
+}
+
+static Z_SortKeySpecList *copy_SortKeySpecList(Z_SortKeySpecList *src, NMEM nmem)
{
- Z_RPNQuery *dst_rpn = 0;
+ Z_SortKeySpecList *dst = 0;
ODR encode = odr_createmem(ODR_ENCODE);
ODR decode = odr_createmem(ODR_DECODE);
- if (z_RPNQuery(encode, &src_rpn, 0, 0))
+ if (z_SortKeySpecList(encode, &src, 0, 0))
{
int len;
char *buf = odr_getbuf(encode, &len, 0);
if (buf)
{
odr_setbuf(decode, buf, len, 0);
- z_RPNQuery(decode, &dst_rpn, 0, 0);
+ z_SortKeySpecList(decode, &dst, 0, 0);
}
}
- nmem_transfer(dst, decode->mem);
+ nmem_transfer(nmem, decode->mem);
odr_destroy(encode);
odr_destroy(decode);
- return dst_rpn;
+ return dst;
}
ZebraSet resultSetClone(ZebraHandle zh, const char *setname,
}
if (strcmp (output_setname, input_setnames[0]))
sset = resultSetClone(zh, output_setname, sset);
+ sset->sortSpec = copy_SortKeySpecList(sort_sequence, sset->nmem);
return resultSetSortSingle (zh, nmem, sset, rset, sort_sequence,
sort_status);
}