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
d484132
..
79b12aa
100644
(file)
--- a/
index/rpnscan.c
+++ b/
index/rpnscan.c
@@
-1,4
+1,4
@@
-/* $Id: rpnscan.c,v 1.13 2007-09-18 18:57:29 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);
@@
-102,7
+100,7
@@
static void count_set(ZebraHandle zh, RSET rset, zint *count)
break;
}
}
break;
}
}
- rset_close (rfd);
+ rset_close(rfd);
*count = rset->hits_count;
}
*count = rset->hits_count;
}
@@
-140,7
+138,7
@@
static void get_first_snippet_from_rset(ZebraHandle zh,
}
}
}
}
}
}
- rset_close (rfd);
+ rset_close(rfd);
}
struct scan2_info_entry {
}
struct scan2_info_entry {
@@
-160,7
+158,7
@@
static int scan_handle2(char *name, const char *info, int pos, void *client)
return 0;
len_prefix = strlen(scan_info->prefix);
return 0;
len_prefix = strlen(scan_info->prefix);
- if (memcmp (name, scan_info->prefix, len_prefix))
+ if (memcmp(name, scan_info->prefix, len_prefix))
return 1;
/* skip special terms such as first-in-field specials */
return 1;
/* skip special terms such as first-in-field specials */
@@
-170,8
+168,8
@@
static int scan_handle2(char *name, const char *info, int pos, void *client)
wrbuf_rewind(scan_info->term);
wrbuf_puts(scan_info->term, name+len_prefix);
wrbuf_rewind(scan_info->term);
wrbuf_puts(scan_info->term, name+len_prefix);
- assert (*info == sizeof(ISAM_P));
- memcpy (&scan_info->isam_p, info+1, sizeof(ISAM_P));
+ assert(*info == sizeof(ISAM_P));
+ memcpy(&scan_info->isam_p, info+1, sizeof(ISAM_P));
return 0;
}
return 0;
}
@@
-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();
@@
-307,11
+316,11
@@
static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
char termz[IT_MAX_WORD+20];
int prefix_len = 0;
char termz[IT_MAX_WORD+20];
int prefix_len = 0;
- prefix_len = key_SU_encode (ords[i], termz);
+ prefix_len = key_SU_encode(ords[i], termz);
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++)
@@
-377,11
+386,11
@@
static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem,
char termz[IT_MAX_WORD+20];
int prefix_len = 0;
char termz[IT_MAX_WORD+20];
int prefix_len = 0;
- prefix_len = key_SU_encode (ords[i], termz);
+ prefix_len = key_SU_encode(ords[i], termz);
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;
@@
-504,7
+513,7
@@
ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
else
termset_name = termset_value_string;
else
termset_name = termset_value_string;
- limit_set = resultSetRef (zh, termset_name);
+ limit_set = resultSetRef(zh, termset_name);
if (!limit_set)
{
if (!limit_set)
{
@@
-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,12
+540,16
@@
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;
- if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
+ if (zebraExplain_curDatabase(zh->reg->zei, basenames[base_no]))
{
zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE,
basenames[base_no]);
{
zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE,
basenames[base_no]);
@@
-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);