projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Beginnings of facets
[idzebra-moved-to-github.git]
/
index
/
rpnscan.c
diff --git
a/index/rpnscan.c
b/index/rpnscan.c
index
5fd6b38
..
79b12aa
100644
(file)
--- a/
index/rpnscan.c
+++ b/
index/rpnscan.c
@@
-1,4
+1,4
@@
-/* $Id: rpnscan.c,v 1.14 2007-10-29 09:25:40 adam Exp $
+/* $Id: rpnscan.c,v 1.20 2007-11-01 16:01:33 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
Copyright (C) 1995-2007
Index Data ApS
@@
-41,11
+41,9
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define RPN_MAX_ORDS 32
#define RPN_MAX_ORDS 32
-int log_scan = YLOG_LOG;
-
/* convert APT SCAN term to internal cmap */
static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
/* convert APT SCAN term to internal cmap */
static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
- char *termz, int reg_type)
+ char *termz, zebra_map_t zm)
{
char termz0[IT_MAX_WORD];
{
char termz0[IT_MAX_WORD];
@@
-63,7
+61,7
@@
static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
while ((len = (cp_end - cp)) > 0)
{
while ((len = (cp_end - cp)) > 0)
{
- map = zebra_maps_input(zh->reg->zebra_maps, reg_type, &cp, len, 0);
+ map = zebra_maps_input(zm, &cp, len, 0);
if (**map == *CHR_SPACE)
space_map = *map;
else
if (**map == *CHR_SPACE)
space_map = *map;
else
@@
-81,7
+79,7
@@
static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
return ZEBRA_OK;
}
return ZEBRA_OK;
}
-static void count_set(ZebraHandle zh, RSET rset, zint *count)
+static void count_set(ZebraHandle zh, RSET rset, zint *count, zint approx_limit)
{
zint psysno = 0;
struct it_key key;
{
zint psysno = 0;
struct it_key key;
@@
-89,7
+87,7
@@
static void count_set(ZebraHandle zh, RSET rset, zint *count)
yaz_log(YLOG_DEBUG, "count_set");
yaz_log(YLOG_DEBUG, "count_set");
- rset->hits_limit = zh->approx_limit;
+ rset->hits_limit = approx_limit;
*count = 0;
rfd = rset_open(rset, RSETF_READ);
*count = 0;
rfd = rset_open(rset, RSETF_READ);
@@
-181,12
+179,21
@@
static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
Z_AttributesPlusTerm *zapt,
RSET limit_set,
const char *term,
Z_AttributesPlusTerm *zapt,
RSET limit_set,
const char *term,
- int index_type,
+ const char *index_type,
struct scan2_info_entry *ar, int ord_no,
ZebraScanEntry *glist, int pos)
{
int i;
RSET rset = 0;
struct scan2_info_entry *ar, int ord_no,
ZebraScanEntry *glist, int pos)
{
int i;
RSET rset = 0;
+ zint approx_limit = zh->approx_limit;
+ AttrType global_hits_limit_attr;
+ int l;
+ attr_init_APT(&global_hits_limit_attr, zapt, 12);
+
+ l = attr_find(&global_hits_limit_attr, NULL);
+ if (l != -1)
+ approx_limit = l;
+
for (i = 0; i < ord_no; i++)
{
if (ar[i].isam_p && strcmp(wrbuf_cstr(ar[i].term), term) == 0)
for (i = 0; i < ord_no; i++)
{
if (ar[i].isam_p && strcmp(wrbuf_cstr(ar[i].term), term) == 0)
@@
-202,7
+209,7
@@
static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
wrbuf_buf(ar[i].term), wrbuf_len(ar[i].term),
NULL, 1, zapt->term->which, nmem,
kc, kc->scope, ol, index_type,
wrbuf_buf(ar[i].term), wrbuf_len(ar[i].term),
NULL, 1, zapt->term->which, nmem,
kc, kc->scope, ol, index_type,
- 0 /* hits_limit */,
+ 0 /* hits_limit_value */,
0 /* term_ref_id_str */);
if (!rset)
rset = rset_t;
0 /* term_ref_id_str */);
if (!rset)
rset = rset_t;
@@
-231,7
+238,7
@@
static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
rset = rset_create_and(nmem, kc, kc->scope, 2, rsets);
}
/* count it */
rset = rset_create_and(nmem, kc, kc->scope, 2, rsets);
}
/* count it */
- count_set(zh, rset, &count);
+ count_set(zh, rset, &count, approx_limit);
if (pos != -1)
{
if (pos != -1)
{
@@
-271,17
+278,19
@@
static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
}
return 0;
}
}
return 0;
}
-
-static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
+
+static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem,
struct rset_key_control *kc,
Z_AttributesPlusTerm *zapt,
int *position, int *num_entries,
ZebraScanEntry **list,
int *is_partial, RSET limit_set,
struct rset_key_control *kc,
Z_AttributesPlusTerm *zapt,
int *position, int *num_entries,
ZebraScanEntry **list,
int *is_partial, RSET limit_set,
- int index_type, int ord_no, int *ords)
+ const char *index_type,
+ int ord_no, int *ords)
{
struct scan2_info_entry *ar = nmem_malloc(nmem, sizeof(*ar) * ord_no);
struct rpn_char_map_info rcmi;
{
struct scan2_info_entry *ar = nmem_malloc(nmem, sizeof(*ar) * ord_no);
struct rpn_char_map_info rcmi;
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
int i, dif;
int after_pos;
int pos = 0;
int i, dif;
int after_pos;
int pos = 0;
@@
-297,7
+306,7
@@
static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
*num_entries = 0;
return ZEBRA_OK;
}
*num_entries = 0;
return ZEBRA_OK;
}
- rpn_char_map_prepare(zh->reg, index_type, &rcmi);
+ rpn_char_map_prepare(zh->reg, zm, &rcmi);
for (i = 0; i < ord_no; i++)
ar[i].term = wrbuf_alloc();
for (i = 0; i < ord_no; i++)
ar[i].term = wrbuf_alloc();
@@
-311,7
+320,7
@@
static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
termz[prefix_len] = 0;
strcpy(ar[i].prefix, termz);
termz[prefix_len] = 0;
strcpy(ar[i].prefix, termz);
- if (trans_scan_term(zh, zapt, termz+prefix_len, index_type) ==
+ if (trans_scan_term(zh, zapt, termz+prefix_len, zm) ==
ZEBRA_FAIL)
{
for (i = 0; i < ord_no; i++)
ZEBRA_FAIL)
{
for (i = 0; i < ord_no; i++)
@@
-381,7
+390,7
@@
static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
termz[prefix_len] = 0;
strcpy(ar[i].prefix, termz);
termz[prefix_len] = 0;
strcpy(ar[i].prefix, termz);
- if (trans_scan_term(zh, zapt, termz+prefix_len, index_type) ==
+ if (trans_scan_term(zh, zapt, termz+prefix_len, zm) ==
ZEBRA_FAIL)
return ZEBRA_FAIL;
wrbuf_rewind(ar[i].term);
ZEBRA_FAIL)
return ZEBRA_FAIL;
wrbuf_rewind(ar[i].term);
@@
-467,7
+476,7
@@
ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
int base_no;
int ords[RPN_MAX_ORDS], ord_no = 0;
int base_no;
int ords[RPN_MAX_ORDS], ord_no = 0;
- unsigned index_type;
+ const char *index_type;
char *search_type = NULL;
char rank_type[128];
int complete_flag;
char *search_type = NULL;
char rank_type[128];
int complete_flag;
@@
-515,7
+524,7
@@
ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
}
}
}
}
}
}
-
+
yaz_log(YLOG_DEBUG, "position = %d, num = %d",
*position, *num_entries);
yaz_log(YLOG_DEBUG, "position = %d, num = %d",
*position, *num_entries);
@@
-531,7
+540,11
@@
ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
zebra_setError(zh, YAZ_BIB1_TOO_MANY_DATABASES_SPECIFIED, 0);
return ZEBRA_FAIL;
}
zebra_setError(zh, YAZ_BIB1_TOO_MANY_DATABASES_SPECIFIED, 0);
return ZEBRA_FAIL;
}
-
+ if (sort_flag)
+ {
+ return rpn_facet(zh, stream, zapt, attributeset, position, num_entries,
+ list, is_partial, limit_set);
+ }
for (base_no = 0; base_no < num_bases; base_no++)
{
int ord;
for (base_no = 0; base_no < num_bases; base_no++)
{
int ord;
@@
-561,7
+574,7
@@
ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
nmem = nmem_create();
kc = zebra_key_control_create(zh);
nmem = nmem_create();
kc = zebra_key_control_create(zh);
- res = rpn_scan_ver2(zh, stream, nmem, kc, zapt, position, num_entries,
+ res = rpn_scan_norm(zh, stream, nmem, kc, zapt, position, num_entries,
list,
is_partial, limit_set, index_type, ord_no, ords);
nmem_destroy(nmem);
list,
is_partial, limit_set, index_type, ord_no, ords);
nmem_destroy(nmem);