From 15ded665c8ca37e3c7a99ce48c2e78acdb727bd6 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 13 Apr 2002 18:16:42 +0000 Subject: [PATCH] More XPATH work; common sequence numbers for extract keys --- include/recctrl.h | 7 +++++-- index/extract.c | 12 +++++------- index/zrpn.c | 39 +++++++++++++++++++++++---------------- recctrl/recgrs.c | 30 ++++++++++++++++++------------ tab/default.idx | 3 ++- 5 files changed, 53 insertions(+), 38 deletions(-) diff --git a/include/recctrl.h b/include/recctrl.h index 1b3cce8..485b746 100644 --- a/include/recctrl.h +++ b/include/recctrl.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recctrl.h,v $ - * Revision 1.34 2000-03-20 19:08:36 adam + * Revision 1.35 2002-04-13 18:16:42 adam + * More XPATH work; common sequence numbers for extract keys + * + * Revision 1.34 2000/03/20 19:08:36 adam * Added remote record import using Z39.50 extended services and Segment * Requests. * @@ -142,7 +145,7 @@ typedef struct { unsigned reg_type; char *string; int length; - int *seqnos; + int seqno; ZebraMaps zebra_maps; struct recExtractCtrl *extractCtrl; } RecWord; diff --git a/index/extract.c b/index/extract.c index 040aff0..09e9009 100644 --- a/index/extract.c +++ b/index/extract.c @@ -3,7 +3,7 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: extract.c,v 1.115 2002-04-04 20:50:36 adam Exp $ + * $Id: extract.c,v 1.116 2002-04-13 18:16:43 adam Exp $ */ #include #include @@ -44,7 +44,7 @@ static void logRecord (int showFlag) static void extract_init (struct recExtractCtrl *p, RecWord *w) { w->zebra_maps = p->zebra_maps; - w->seqnos = p->seqno; + w->seqno = 1; w->attrSet = VAL_BIB1; w->attrUse = 1016; w->reg_type = 'w'; @@ -1359,11 +1359,11 @@ void extract_add_index_string (RecWord *p, const char *string, unsigned short attrUse; int lead = 0; int diff = 0; - int *pseqno = &p->seqnos[p->reg_type]; + int *pseqno = &p->seqno; ZebraHandle zh = p->extractCtrl->handle; ZebraExplainInfo zei = zh->reg->zei; struct recKeys *keys = &zh->reg->keys; - + if (keys->buf_used+1024 > keys->buf_max) { char *b; @@ -1434,8 +1434,6 @@ void extract_add_index_string (RecWord *p, const char *string, dst += sizeof(*pseqno); } keys->buf_used = dst - keys->buf; - if (*pseqno) - (*pseqno)++; } static void extract_add_sort_string (RecWord *p, const char *string, @@ -1510,8 +1508,8 @@ static void extract_add_incomplete_field (RecWord *p) if (!i) return; extract_add_string (p, buf, i); + p->seqno++; } - (p->seqnos[p->reg_type])++; /* to separate this from next one */ } static void extract_add_complete_field (RecWord *p) diff --git a/index/zrpn.c b/index/zrpn.c index bb8dc7a..78f6180 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -3,7 +3,7 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: zrpn.c,v 1.114 2002-04-12 14:55:22 adam Exp $ + * $Id: zrpn.c,v 1.115 2002-04-13 18:16:43 adam Exp $ */ #include #include @@ -85,17 +85,17 @@ static int attr_find_ex (AttrType *src, oid_value *attributeSetP, case Z_AttributeValue_complex: if (src->minor >= element->value.complex->num_list) break; + if (element->attributeSet && attributeSetP) + { + oident *attrset; + + attrset = oid_getentbyoid (element->attributeSet); + *attributeSetP = attrset->value; + } if (element->value.complex->list[src->minor]->which == Z_StringOrNumeric_numeric) { ++(src->minor); - if (element->attributeSet && attributeSetP) - { - oident *attrset; - - attrset = oid_getentbyoid (element->attributeSet); - *attributeSetP = attrset->value; - } return *element->value.complex->list[src->minor-1]->u.numeric; } @@ -856,9 +856,9 @@ static int string_term (ZebraHandle zh, Z_AttributesPlusTerm *zapt, truncation_value = attr_find (&truncation, NULL); logf (LOG_DEBUG, "truncation value %d", truncation_value); - if (use_value == -1) + if (use_value == -1) /* no attribute - assumy "any" */ use_value = 1016; - if (use_value == -2) + if (use_value == -2) /* string attribute - assumy "any" */ use_value = 1016; for (base_no = 0; base_no < num_bases; base_no++) @@ -1931,8 +1931,8 @@ static RSET rpn_search_xpath (ZebraHandle zh, Z_AttributesPlusTerm *zapt, oid_value curAttributeSet = attributeSet; char term_dict[2048]; int base_no; + int reg_type = '0'; struct grep_info grep_info; - struct rpn_char_map_info rcmi; yaz_log (LOG_LOG, "rpn_search_xpath 1"); attr_init (&use, zapt, 1); @@ -1949,14 +1949,14 @@ static RSET rpn_search_xpath (ZebraHandle zh, Z_AttributesPlusTerm *zapt, return rset; } - rpn_char_map_prepare (zh->reg, '0', &rcmi); - - if (grep_info_prepare (zh, zapt, &grep_info, '0', stream)) + dict_grep_cmap (zh->reg->dict, 0, 0); + if (grep_info_prepare (zh, zapt, &grep_info, reg_type, stream)) return 0; yaz_log (LOG_LOG, "rpn_search_xpath 2"); for (base_no = 0; base_no < num_bases; base_no++) { + const char *termp = use_string; rset_between_parms parms; RSET rset_start_tag, rset_end_tag; int ord, ord_len, i, r, max_pos; @@ -1986,8 +1986,11 @@ static RSET rpn_search_xpath (ZebraHandle zh, Z_AttributesPlusTerm *zapt, } term_dict[prefix_len++] = ')'; term_dict[prefix_len++] = 1; - term_dict[prefix_len++] = '0'; + term_dict[prefix_len++] = reg_type; + + termp = use_string; strcpy (term_dict+prefix_len, use_string); + grep_info.isam_p_indx = 0; yaz_log (LOG_LOG, "rpn_search_xpath 3 %s", term_dict+prefix_len); r = dict_lookup_grep (zh->reg->dict, term_dict, 0, @@ -2016,8 +2019,12 @@ static RSET rpn_search_xpath (ZebraHandle zh, Z_AttributesPlusTerm *zapt, } term_dict[prefix_len++] = ')'; term_dict[prefix_len++] = 1; - term_dict[prefix_len++] = '0'; + term_dict[prefix_len++] = reg_type; + + termp = use_string; + strcpy (term_dict+prefix_len, use_string); + grep_info.isam_p_indx = 0; r = dict_lookup_grep (zh->reg->dict, term_dict, 0, &grep_info, &max_pos, 0, grep_handle); diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index deb7046..5974888 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -3,7 +3,10 @@ * All rights reserved. * * $Log: recgrs.c,v $ - * Revision 1.45 2002-04-12 14:40:42 adam + * Revision 1.46 2002-04-13 18:16:43 adam + * More XPATH work; common sequence numbers for extract keys + * + * Revision 1.45 2002/04/12 14:40:42 adam * Work on XPATH * * Revision 1.44 2002/04/11 20:09:47 adam @@ -477,10 +480,9 @@ static void index_termlist (data1_node *par, data1_node *n, } } -static int dumpkeys(data1_node *n, struct recExtractCtrl *p, int level) +static int dumpkeys(data1_node *n, struct recExtractCtrl *p, int level, + RecWord *wrd) { - RecWord wrd; - (*p->init)(p, &wrd); /* set defaults */ for (; n; n = n->next) { if (p->flagShowRecords) /* display element description to user */ @@ -522,14 +524,14 @@ static int dumpkeys(data1_node *n, struct recExtractCtrl *p, int level) if (n->which == DATA1N_tag) { - index_termlist (n, n, p, level, &wrd); + index_termlist (n, n, p, level, wrd); /* index start tag */ if (!n->root->u.root.absyn) - index_xpath (n, p, level, &wrd, 1); + index_xpath (n, p, level, wrd, 1); } if (n->child) - if (dumpkeys(n->child, p, level + 1) < 0) + if (dumpkeys(n->child, p, level + 1, wrd) < 0) return -1; @@ -551,9 +553,9 @@ static int dumpkeys(data1_node *n, struct recExtractCtrl *p, int level) } if (par) - index_termlist (par, n, p, level, &wrd); + index_termlist (par, n, p, level, wrd); if (!n->root->u.root.absyn) - index_xpath (n, p, level, &wrd, 1016); + index_xpath (n, p, level, wrd, 1016); } @@ -561,7 +563,7 @@ static int dumpkeys(data1_node *n, struct recExtractCtrl *p, int level) { /* index end tag */ if (!n->root->u.root.absyn) - index_xpath (n, p, level, &wrd, 2); + index_xpath (n, p, level, wrd, 2); } @@ -577,6 +579,7 @@ int grs_extract_tree(struct recExtractCtrl *p, data1_node *n) { oident oe; int oidtmp[OID_SIZE]; + RecWord wrd; oe.proto = PROTO_Z3950; oe.oclass = CLASS_SCHEMA; @@ -587,7 +590,8 @@ int grs_extract_tree(struct recExtractCtrl *p, data1_node *n) if ((oid_ent_to_oid (&oe, oidtmp))) (*p->schemaAdd)(p, oidtmp); } - return dumpkeys(n, p, 0); + (*p->init)(p, &wrd); + return dumpkeys(n, p, 0, &wrd); } static int grs_extract_sub(struct grs_handlers *h, struct recExtractCtrl *p, @@ -597,6 +601,7 @@ static int grs_extract_sub(struct grs_handlers *h, struct recExtractCtrl *p, struct grs_read_info gri; oident oe; int oidtmp[OID_SIZE]; + RecWord wrd; gri.readf = p->readf; gri.seekf = p->seekf; @@ -626,7 +631,8 @@ static int grs_extract_sub(struct grs_handlers *h, struct recExtractCtrl *p, #if 0 data1_pr_tree (p->dh, n, stdout); #endif - if (dumpkeys(n, p, 0) < 0) + (*p->init)(p, &wrd); + if (dumpkeys(n, p, 0, &wrd) < 0) { data1_free_tree(p->dh, n); return RECCTRL_EXTRACT_ERROR; diff --git a/tab/default.idx b/tab/default.idx index 2632158..cec40e5 100644 --- a/tab/default.idx +++ b/tab/default.idx @@ -1,5 +1,5 @@ # Zebra indexes as referred to from the *.abs-files. -# $Id: default.idx,v 1.8 2000-03-02 14:35:19 adam Exp $ +# $Id: default.idx,v 1.9 2002-04-13 18:16:43 adam Exp $ # # Traditional word index index w @@ -25,6 +25,7 @@ charmap numeric.chr # Null map index (no mapping at all) index 0 completeness 0 +position 1 charmap @ # Sort register (no mapping at all) -- 1.7.10.4