-/* $Id: isamb.h,v 1.14 2004-08-23 13:06:45 adam Exp $
+/* $Id: isamb.h,v 1.15 2004-09-09 10:08:04 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
ISAMB_P isamb_merge (ISAMB b, ISAMB_P pos, ISAMC_I *data);
-ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos);
+ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos, int scope);
int isamb_pp_read (ISAMB_PP pp, void *buf);
int isamb_unlink (ISAMB b, ISAMC_P pos);
-ISAMB_PP isamb_pp_open_x (ISAMB isamb, ISAMB_P pos, int *level);
+ISAMB_PP isamb_pp_open_x (ISAMB isamb, ISAMB_P pos, int *level, int scope);
void isamb_pp_close_x (ISAMB_PP pp, int *size, int *blocks);
int isamb_block_info (ISAMB isamb, int cat);
-/* $Id: rset.h,v 1.33 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rset.h,v 1.34 2004-09-09 10:08:04 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
struct key_control {
int key_size;
+ int scope; /* default for what level we operate (book/chapter/verse) on*/
+ /* usual sysno/seqno is 2 */
int (*cmp) (const void *p1, const void *p2);
void (*key_logdump_txt) (int logmask, const void *p, const char *txt);
zint (*getseq)(const void *p);
char my_nmem; /* Should the nmem be destroyed with the rset? */
/* 1 if created with it, 0 if passed from above */
RSFD free_list; /* all rfd's allocated but not currently in use */
+ int scope; /* On what level do we count hits and compare them? */
} rset;
-/* rset is a "virtual base class", which will never exist on its own */
-/* all instances are rsets of some specific type, like rsisamb, or rsbool */
-/* They keep their own stuff behind the priv pointer. */
+/* rset is a "virtual base class", which will never exist on its own
+ * all instances are rsets of some specific type, like rsisamb, or rsbool
+ * They keep their own stuff behind the priv pointer. */
+
+/* On the old sysno-seqno type isams, the scope was hard-coded to be 2.
+ * This means that we count hits on the sysno level, and when matching an
+ * 'and', we consider it a match if both term occur within the same sysno.
+ * In more complex isams we can specify on what level we wish to do the
+ * matching and counting of hits. For example, we can have book / chapter /
+ * verse, and a seqno. Scope 2 means then "give me all verses that match",
+ * 3 would be chapters, 4 books.
+ * The resolution tells how much of the occurences we need to return. If we
+ * are doing some sort of proximity, we need to get the seqnos of all
+ * occurences, whereas if we are only counting hits, we do not need anything
+ * below the scope. Again 1 is seqnos, 2 sysnos (or verses), 3 books, etc.
+ */
+/* FIXME - Add a resolution, to decide on what level we want to return */
+/* hits. That can well be below scope, if we need to get seqnos for prox */
+/* or suchlike... */
RSFD rfd_create_base(RSET rs);
void rfd_delete_base(RSFD rfd);
RSET rset_create_base(const struct rset_control *sel,
NMEM nmem,
- const struct key_control *kcontrol);
+ const struct key_control *kcontrol,
+ int scope );
void rset_delete(RSET rs);
RSET rset_dup (RSET rs);
#define rset_type(rs) ((rs)->control->desc)
RSET rstemp_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
const char *temp_path);
RSET rsnull_create(NMEM nmem, const struct key_control *kcontrol);
RSET rsbool_create_and( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_r);
RSET rsbool_create_or ( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_r);
RSET rsbool_create_not( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_r);
RSET rsbetween_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_m, RSET rset_r,
RSET rset_attr);
RSET rsmultior_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
int no_rsets, RSET* rsets);
RSET rsprox_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
int rset_no, RSET *rset,
int ordered, int exclusion,
int relation, int distance);
RSET rsisamb_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
ISAMB is, ISAMB_P pos);
RSET rsisamc_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
ISAMC is, ISAMC_P pos);
RSET rsisams_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
ISAMS is, ISAMS_P pos);
-/* $Id: index.h,v 1.118 2004-09-09 09:07:12 adam Exp $
+/* $Id: index.h,v 1.119 2004-09-09 10:08:04 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
RSET rset_trunc (ZebraHandle zh, ISAMS_P *isam_p, int no,
const char *term, int length_term, const char *flags,
int preserve_position, int term_type, NMEM rset_nmem,
- const struct key_control *kctrl);
+ const struct key_control *kctrl, int scope);
void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type,
const char *db, int set,
-/* $Id: invstat.c,v 1.39 2004-08-06 13:14:46 adam Exp $
+/* $Id: invstat.c,v 1.40 2004-09-09 10:08:05 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
int size;
int blocks;
- pp = isamb_pp_open_x(stat_info->zh->reg->isamb, isam_p, &level);
+ pp = isamb_pp_open_x(stat_info->zh->reg->isamb, isam_p, &level, 0);
while (isamb_pp_read(pp, &key))
{
-/* $Id: trunc.c,v 1.43 2004-09-03 14:59:49 heikki Exp $
+/* $Id: trunc.c,v 1.44 2004-09-09 10:08:05 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
const char *flags, ISAMS_P *isam_p, int from, int to,
int merge_chunk, int preserve_position,
int term_type, NMEM rset_nmem,
- const struct key_control *kctrl)
+ const struct key_control *kctrl, int scope)
{
RSET result;
RSFD result_rsfd;
parms.temp_path = res_get (zi->res, "setTmpDir");
result = rset_create (rset_kind_temp, &parms);
*/
- result=rstemp_create( rset_nmem,kctrl,
+ result=rstemp_create( rset_nmem,kctrl, scope,
res_get (zi->res, "setTmpDir"));
result_rsfd = rset_open (result, RSETF_WRITE);
rset[rscur] = rset_trunc_r (zi, term, length, flags,
isam_p, i, i+i_add,
merge_chunk, preserve_position,
- term_type, rset_nmem, kctrl);
+ term_type, rset_nmem,
+ kctrl, scope);
else
rset[rscur] = rset_trunc_r (zi, term, length, flags,
isam_p, i, to,
merge_chunk, preserve_position,
- term_type, rset_nmem, kctrl);
+ term_type, rset_nmem,
+ kctrl, scope);
rscur++;
}
ti = heap_init (rscur, sizeof(struct it_key), key_compare_it);
for (i = to-from; --i >= 0; )
{
if (isam_p[from+i]) {
- ispt[i] = isamb_pp_open (zi->reg->isamb, isam_p[from+i]);
+ ispt[i] = isamb_pp_open (zi->reg->isamb, isam_p[from+i], scope);
if (isamb_pp_read (ispt[i], ti->tmpbuf))
heap_insert (ti, ti->tmpbuf, i);
else
RSET rset_trunc (ZebraHandle zi, ISAMS_P *isam_p, int no,
const char *term, int length, const char *flags,
int preserve_position, int term_type, NMEM rset_nmem,
- const struct key_control *kctrl)
+ const struct key_control *kctrl, int scope)
{
logf (LOG_DEBUG, "rset_trunc no=%d", no);
if (no < 1)
if (zi->reg->isams)
{
if (no == 1)
- return rsisams_create(rset_nmem, kctrl,
- zi->reg->isams, *isam_p);
+ return rsisams_create(rset_nmem, kctrl, scope,
+ zi->reg->isams, *isam_p);
qsort (isam_p, no, sizeof(*isam_p), isams_trunc_cmp);
}
else if (zi->reg->isamc)
{
if (no == 1)
- return rsisamc_create(rset_nmem, kctrl,
+ return rsisamc_create(rset_nmem, kctrl, scope,
zi->reg->isamc, *isam_p);
qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp);
}
else if (zi->reg->isamb)
{
if (no == 1)
- return rsisamb_create(rset_nmem,kctrl,
+ return rsisamb_create(rset_nmem,kctrl, scope,
zi->reg->isamb, *isam_p);
else if (no <10000 ) /* FIXME - hardcoded number */
{
RSET *rsets=xmalloc(no*sizeof(RSET)); /* use nmem! */
int i;
for (i=0;i<no;i++)
- rsets[i]=rsisamb_create(rset_nmem, kctrl,
+ rsets[i]=rsisamb_create(rset_nmem, kctrl, scope,
zi->reg->isamb, isam_p[i] );
- r=rsmultior_create( rset_nmem, kctrl, no, rsets);
+ r=rsmultior_create( rset_nmem, kctrl, scope, no, rsets);
xfree(rsets);
}
qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp);
return rsnull_create (rset_nmem, kctrl);
}
return rset_trunc_r (zi, term, length, flags, isam_p, 0, no, 100,
- preserve_position, term_type, rset_nmem,kctrl);
+ preserve_position, term_type, rset_nmem,kctrl,scope);
}
-/* $Id: zrpn.c,v 1.149 2004-09-01 15:01:32 heikki Exp $
+/* $Id: zrpn.c,v 1.150 2004-09-09 10:08:05 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
static const struct key_control it_ctrl={
sizeof(struct it_key),
+ 2, /* we have sysnos and seqnos in this key, nothing more */
key_compare_it,
key_logdump_txt, /* FIXME - clean up these functions */
key_get_seq,
};
+
const struct key_control *key_it_ctrl=&it_ctrl;
struct rpn_char_map_info {
return rset_trunc (zh, grep_info->isam_p_buf,
grep_info->isam_p_indx, term_dst,
strlen(term_dst), rank_type, 1 /* preserve pos */,
- zapt->term->which, rset_nmem,key_it_ctrl);
+ zapt->term->which, rset_nmem,
+ key_it_ctrl,key_it_ctrl->scope);
}
else if (rset_no == 1)
return (rset[0]);
else
- result = rsprox_create( rset_nmem, key_it_ctrl,
+ result = rsprox_create( rset_nmem, key_it_ctrl, key_it_ctrl->scope,
rset_no, rset,
1 /* ordered */, 0 /* exclusion */,
3 /* relation */, 1 /* distance */);
grep_info_delete (&grep_info);
if (rset_no == 0)
return rsnull_create (rset_nmem,key_it_ctrl);
- return rsmultior_create(rset_nmem, key_it_ctrl,
+ return rsmultior_create(rset_nmem, key_it_ctrl,key_it_ctrl->scope,
rset_no, rset);
}
result = rset[0];
/* FIXME - Use a proper rsmultiand */
for (i = 1; i<rset_no; i++)
- result= rsbool_create_and(rset_nmem,key_it_ctrl,
+ result= rsbool_create_and(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
result, rset[i] );
return result;
}
grep_info.isam_p_indx, term_dst,
strlen(term_dst), rank_type,
0 /* preserve position */,
- zapt->term->which, rset_nmem, key_it_ctrl);
+ zapt->term->which, rset_nmem,
+ key_it_ctrl,key_it_ctrl->scope);
assert (rset[rset_no]);
if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset)))
break;
for (i = 1; i<rset_no; i++)
{
/* FIXME - Use a proper multi-and */
- result= rsbool_create_and(rset_nmem,key_it_ctrl,
+ result= rsbool_create_and(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
result, rset[i] );
}
return result;
parms.temp_path = res_get (zh->res, "setTmpDir");
result = rset_create (rset_kind_temp, &parms);
*/
- result = rstemp_create( rset_nmem,key_it_ctrl,
+ result = rstemp_create( rset_nmem,key_it_ctrl,key_it_ctrl->scope,
res_get (zh->res, "setTmpDir") );
rsfd = rset_open (result, RSETF_WRITE);
grep_info.isam_p_indx);
rset = rset_trunc (zh, grep_info.isam_p_buf,
grep_info.isam_p_indx, term, strlen(term),
- flags, 1, term_type,rset_nmem,key_it_ctrl);
+ flags, 1, term_type,rset_nmem,
+ key_it_ctrl, key_it_ctrl->scope);
grep_info_delete (&grep_info);
return rset;
}
parms.printer = key_print_it;
rset = rset_create (rset_kind_between, &parms);
*/
- rset=rsbetween_create( rset_nmem,key_it_ctrl,
+ rset=rsbetween_create( rset_nmem,key_it_ctrl,key_it_ctrl->scope,
rset_start_tag, rset, rset_end_tag, rset_attr);
}
first_path = 0;
switch (zop->which)
{
case Z_Operator_and:
- r = rsbool_create_and(rset_nmem,key_it_ctrl, rset_l,rset_r );
+ r = rsbool_create_and(rset_nmem,key_it_ctrl, key_it_ctrl->scope,
+ rset_l,rset_r );
break;
case Z_Operator_or:
- r = rsbool_create_or(rset_nmem,key_it_ctrl, rset_l,rset_r );
+ r = rsbool_create_or(rset_nmem,key_it_ctrl, key_it_ctrl->scope,
+ rset_l,rset_r );
break;
case Z_Operator_and_not:
- r = rsbool_create_not(rset_nmem,key_it_ctrl, rset_l,rset_r );
+ r = rsbool_create_not(rset_nmem,key_it_ctrl, key_it_ctrl->scope,
+ rset_l,rset_r );
break;
case Z_Operator_prox:
if (zop->u.prox->which != Z_ProximityOperator_known)
twosets[0] = rset_l;
twosets[1] = rset_r;
- r=rsprox_create(rset_nmem,key_it_ctrl,
+ r=rsprox_create(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
2, twosets,
*zop->u.prox->ordered,
(!zop->u.prox->exclusion ?
&glist[i+before].term, mterm);
rset = rset_trunc (zh, &scan_info_array[j0].list[ptr[j0]].isam_p, 1,
glist[i+before].term, strlen(glist[i+before].term),
- NULL, 0, zapt->term->which, rset_nmem, key_it_ctrl);
-
+ NULL, 0, zapt->term->which, rset_nmem,
+ key_it_ctrl,key_it_ctrl->scope);
ptr[j0]++;
for (j = j0+1; j<ord_no; j++)
{
rset_trunc (zh, &scan_info_array[j].list[ptr[j]].isam_p, 1,
glist[i+before].term,
strlen(glist[i+before].term), NULL, 0,
- zapt->term->which,rset_nmem,key_it_ctrl);
+ zapt->term->which,rset_nmem,
+ key_it_ctrl, key_it_ctrl->scope);
rset = rsbool_create_or(rset_nmem,key_it_ctrl,
- rset, rset2);
+ key_it_ctrl->scope, rset, rset2);
/* FIXME - Use a proper multi-or */
ptr[j]++;
}
}
if (limit_set)
- rset = rsbool_create_and(rset_nmem,key_it_ctrl,
+ rset = rsbool_create_and(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
rset, rset_dup(limit_set));
count_set (rset, &glist[i+before].occurrences);
rset_delete (rset);
rset = rset_trunc
(zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
glist[before-1-i].term, strlen(glist[before-1-i].term),
- NULL, 0, zapt->term->which,rset_nmem,key_it_ctrl);
+ NULL, 0, zapt->term->which,rset_nmem,
+ key_it_ctrl,key_it_ctrl->scope);
ptr[j0]++;
&scan_info_array[j].list[before-1-ptr[j]].isam_p, 1,
glist[before-1-i].term,
strlen(glist[before-1-i].term), NULL, 0,
- zapt->term->which, rset_nmem,key_it_ctrl);
+ zapt->term->which, rset_nmem,
+ key_it_ctrl, key_it_ctrl->scope);
rset = rsbool_create_and(rset_nmem,key_it_ctrl,
- rset, rset2);
+ key_it_ctrl->scope, rset, rset2);
/* FIXME - multi-and ?? */
ptr[j]++;
}
}
if (limit_set)
- rset = rsbool_create_and(rset_nmem,key_it_ctrl,
+ rset = rsbool_create_and(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
rset, rset_dup(limit_set));
count_set (rset, &glist[before-1-i].occurrences);
rset_delete (rset);
-/* $Id: isamb.c,v 1.57 2004-09-03 14:59:49 heikki Exp $
+/* $Id: isamb.c,v 1.58 2004-09-09 10:08:05 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
zint skipped_nodes[ISAMB_MAX_LEVEL]; /* [0]=skipped leaves, 1=higher etc */
zint accessed_nodes[ISAMB_MAX_LEVEL]; /* nodes we did not skip */
struct ISAMB_block **block;
+ int scope; /* on what level we forward */
};
return pos;
}
-ISAMB_PP isamb_pp_open_x (ISAMB isamb, ISAMB_P pos, int *level)
+ISAMB_PP isamb_pp_open_x (ISAMB isamb, ISAMB_P pos, int *level, int scope)
{
ISAMB_PP pp = xmalloc (sizeof(*pp));
int i;
pp->no_blocks = 0;
pp->skipped_numbers=0;
pp->returned_numbers=0;
+ pp->scope=scope;
for (i=0;i<ISAMB_MAX_LEVEL;i++)
pp->skipped_nodes[i] = pp->accessed_nodes[i]=0;
while (1)
return pp;
}
-ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos)
+ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos, int scope)
{
- return isamb_pp_open_x (isamb, pos, 0);
+ return isamb_pp_open_x (isamb, pos, 0, scope);
}
void isamb_pp_close_x (ISAMB_PP pp, int *size, int *blocks)
isamb_dump_r(b, pos, pr, 0);
}
-#if 0
-/* Old isamb_pp_read that Adam wrote, kept as a reference in case we need to
- debug the more complex pp_read that also forwards. May be deleted near end
- of 2004, if it has not shown to be useful */
-
-
-int isamb_pp_read (ISAMB_PP pp, void *buf)
-{
- char *dst = buf;
- char *src;
- struct ISAMB_block *p = pp->block[pp->level];
- if (!p)
- return 0;
-
- while (p->offset == p->size)
- {
- int pos, item_len;
- while (p->offset == p->size)
- {
- if (pp->level == 0)
- return 0;
- close_block (pp->isamb, pp->block[pp->level]);
- pp->block[pp->level] = 0;
- (pp->level)--;
- p = pp->block[pp->level];
- assert (!p->leaf);
- }
- src = p->bytes + p->offset;
-
- decode_ptr (&src, &item_len);
- src += item_len;
- decode_ptr (&src, &pos);
-
- p->offset = src - (char*) p->bytes;
-
- ++(pp->level);
-
- while (1)
- {
- pp->block[pp->level] = p = open_block (pp->isamb, pos);
-
- pp->total_size += p->size;
- pp->no_blocks++;
-
- if (p->leaf)
- {
- break;
- }
- src = p->bytes + p->offset;
- decode_ptr (&src, &pos);
- p->offset = src - (char*) p->bytes;
- pp->level++;
- }
- }
- assert (p->offset < p->size);
- assert (p->leaf);
- src = p->bytes + p->offset;
- (*pp->isamb->method->codec.code_item)(ISAMC_DECODE, p->decodeClientData,
- &dst, &src);
- p->offset = src - (char*) p->bytes;
- /* key_logdump_txt(LOG_DEBUG,buf, "isamb_pp_read returning 1"); */
- return 1;
-}
-
-#else
int isamb_pp_read (ISAMB_PP pp, void *buf)
{
return isamb_pp_forward(pp, buf, 0);
}
-#endif
-#define NEW_FORWARD 1
-
-#if NEW_FORWARD == 1
static int isamb_pp_on_right_node(ISAMB_PP pp, int level, const void *untilbuf)
{ /* looks one node higher to see if we should be on this node at all */
(*pp->isamb->method->codec.log_item)(LOG_DEBUG,src,"on_leaf: value");
#endif
cmp=(*pp->isamb->method->compare_item)(untilbuf,src);
- if (cmp<2) {
+ if (cmp<pp->scope) { /* cmp<2 */
#if ISAMB_DEBUG
logf(LOG_DEBUG,"isamb_pp_on_right returning true "
"cmp=%d lev=%d ofs=%d",cmp,level,p->offset);
dst=buf;
(*pp->isamb->method->codec.decode)(p->decodeClientData,&dst, &src);
p->offset = src - (char*) p->bytes;
- /*
#if ISAMB_DEBUG
(*pp->isamb->method->codec.log_item)(LOG_DEBUG, buf, "read_on_leaf returning 1");
#endif
-*/
pp->returned_numbers++;
return 1;
} /* read_on_leaf */
return 0;
/* FIXME - this is an extra function call, inline the read? */
cmp=(*pp->isamb->method->compare_item)(untilbuf,buf);
- if (cmp <2){ /* found a good one */
+ if (cmp <pp->scope){ /* cmp<2 found a good one */
#if ISAMB_DEBUG
if (skips)
logf(LOG_DEBUG, "isam_pp_fwd_on_leaf skipped %d items",skips);
cmp=(*pp->isamb->method->compare_item)(untilbuf,src);
src+=item_len;
decode_ptr(&src,&nxtpos);
- if (cmp<2)
+ if (cmp<pp->scope) /* cmp<2 */
{
#if ISAMB_DEBUG
logf(LOG_DEBUG,"isamb_pp_forward_unode returning a hit "
struct ISAMB_block *p = pp->block[pp->level];
assert(p->leaf);
logf(LOG_DEBUG,"isamb_pp_forward starting "
- "at level %d node %d ofs=%d sz=%d u=%p",
- pp->level, p->pos, p->offset, p->size,untilbuf);
+ "at level %d node %d ofs=%d sz=%d u=%p sc=%d",
+ pp->level, p->pos, p->offset, p->size,untilbuf, scope);
#endif
if (untilbuf) {
if (isamb_pp_forward_on_leaf( pp, buf, untilbuf)) {
}
} /* isam_pp_forward (new version) */
-#elif NEW_FORWARD == 0
-
-int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilbuf)
-{
- /* pseudocode:
- * while 1
- * while at end of node
- * climb higher. If out, return 0
- * while not on a leaf (and not at its end)
- * decode next
- * if cmp
- * descend to node
- * decode next
- * if cmp
- * return 1
- */
- /*
- * The upper nodes consist of a sequence of nodenumbers and keys
- * When opening a block, the first node number is read in, and
- * offset points to the first key, which is the upper limit of keys
- * in the node just read.
- */
- char *dst = buf;
- const char *src;
- struct ISAMB_block *p = pp->block[pp->level];
- int cmp;
- int item_len;
- int pos;
- int nxtpos;
- int descending=0; /* used to prevent a border condition error */
- if (!p)
- return 0;
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isamb_pp_forward starting [%p] p=%d",pp,p->pos);
-
- (*pp->isamb->method->codec.log_item)(LOG_DEBUG, untilbuf, "until");
- (*pp->isamb->method->codec.log_item)(LOG_DEBUG, buf, "buf");
-#endif
-
- while (1)
- {
- while ( (p->offset == p->size) && !descending )
- { /* end of this block - climb higher */
- assert (p->offset <= p->size);
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isamb_pp_forward climbing from l=%d",
- pp->level);
-#endif
- if (pp->level == 0)
- {
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isamb_pp_forward returning 0 at root");
-#endif
- return 0; /* at end of the root, nothing left */
- }
- close_block(pp->isamb, pp->block[pp->level]);
- pp->block[pp->level]=0;
- (pp->level)--;
- p=pp->block[pp->level];
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isamb_pp_forward climbed to node %d off=%d",
- p->pos, p->offset);
-#endif
- assert(!p->leaf);
- assert(p->offset <= p->size);
- /* skip the child we have handled */
- if (p->offset != p->size)
- {
- src = p->bytes + p->offset;
- decode_ptr(&src, &item_len);
-#if ISAMB_DEBUG
- (*pp->isamb->method->codec.log_item)(LOG_DEBUG, src,
- " isamb_pp_forward "
- "climb skipping old key");
-#endif
- src += item_len;
- decode_ptr(&src,&pos);
- p->offset = src - (char*) p->bytes;
- break; /* even if this puts us at the end of the block, we
- need to descend to the last pos. UGLY coding,
- clean up some day */
- }
- }
- if (!p->leaf)
- {
- src = p->bytes + p->offset;
- if (p->offset == p->size)
- cmp=-2 ; /* descend to the last node, as we have
- no value to cmp */
- else
- {
- decode_ptr(&src, &item_len);
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isamb_pp_forward (B) on a high node. "
- "ofs=%d sz=%d nxtpos=%d ",
- p->offset,p->size,pos);
- (*pp->isamb->method->codec.log_item)(LOG_DEBUG, src, "");
-#endif
- if (untilbuf)
- cmp=(*pp->isamb->method->compare_item)(untilbuf,src);
- else
- cmp=-2;
- src += item_len;
- decode_ptr(&src,&nxtpos);
- }
- if (cmp<2)
- {
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isambb_pp_forward descending l=%d p=%d ",
- pp->level, pos);
-#endif
- descending=1; /* prevent climbing for a while */
- ++(pp->level);
- p = open_block(pp->isamb,pos);
- pp->block[pp->level] = p ;
- pp->total_size += p->size;
- (pp->accessed_nodes[pp->maxlevel - pp->level])++;
- pp->no_blocks++;
- if ( !p->leaf)
- { /* block starts with a pos */
- src = p->bytes + p->offset;
- decode_ptr(&src,&pos);
- p->offset=src-(char*) p->bytes;
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isamb_pp_forward: block %d starts with %d",
- p->pos, pos);
-#endif
- }
- } /* descend to the node */
- else
- { /* skip the node */
- p->offset = src - (char*) p->bytes;
- pos=nxtpos;
- (pp->skipped_nodes[pp->maxlevel - pp->level -1])++;
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,
- "isamb_pp_forward: skipping block on level %d, noting "
- "on %d (%d)",
- pp->level, pp->maxlevel - pp->level-1 ,
- pp->skipped_nodes[pp->maxlevel - pp->level-1 ]);
-#endif
- /* 0 is always leafs, 1 is one level above leafs etc, no
- * matter how high tree */
- }
- } /* not on a leaf */
- else
- { /* on a leaf */
- if (p->offset == p->size) {
- descending = 0;
- }
- else
- {
- assert (p->offset < p->size);
- src = p->bytes + p->offset;
- dst=buf;
- (*pp->isamb->method->codec.decode)(p->decodeClientData,
- &dst, &src);
- p->offset = src - (char*) p->bytes;
- if (untilbuf)
- cmp=(*pp->isamb->method->compare_item)(untilbuf,buf);
- else
- cmp=-2;
-#if ISAMB_DEBUG
- logf(LOG_DEBUG,"isamb_pp_forward on a leaf. cmp=%d",
- cmp);
- (*pp->isamb->method->codec.log_item)(LOG_DEBUG, buf, "");
-#endif
- if (cmp <2)
- {
-#if ISAMB_DEBUG
- if (untilbuf)
- {
- (*pp->isamb->method->codec.log_item)(
- LOG_DEBUG, buf, "isamb_pp_forward returning 1");
- }
- else
- {
- (*pp->isamb->method->codec.log_item)(
- LOG_DEBUG, buf, "isamb_pp_read returning 1 (fwd)");
- }
-#endif
- pp->returned_numbers++;
- return 1;
- }
- else
- pp->skipped_numbers++;
- }
- } /* leaf */
- } /* main loop */
-}
-
-#elif NEW_FORWARD == 2
-
-int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilb)
-{
- char *dst = buf;
- const char *src;
- struct ISAMB_block *p = pp->block[pp->level];
- if (!p)
- return 0;
-
-again:
- while (p->offset == p->size)
- {
- int pos, item_len;
- while (p->offset == p->size)
- {
- if (pp->level == 0)
- return 0;
- close_block (pp->isamb, pp->block[pp->level]);
- pp->block[pp->level] = 0;
- (pp->level)--;
- p = pp->block[pp->level];
- assert (!p->leaf);
- }
-
- assert(!p->leaf);
- src = p->bytes + p->offset;
-
- decode_ptr (&src, &item_len);
- src += item_len;
- decode_ptr (&src, &pos);
-
- p->offset = src - (char*) p->bytes;
-
- src = p->bytes + p->offset;
-
- while(1)
- {
- if (!untilb || p->offset == p->size)
- break;
- assert(p->offset < p->size);
- decode_ptr (&src, &item_len);
- if ((*pp->isamb->method->compare_item)(untilb, src) <= 1)
- break;
- src += item_len;
- decode_ptr (&src, &pos);
- p->offset = src - (char*) p->bytes;
- }
-
- pp->level++;
-
- while (1)
- {
- pp->block[pp->level] = p = open_block (pp->isamb, pos);
-
- pp->total_size += p->size;
- pp->no_blocks++;
-
- if (p->leaf)
- {
- break;
- }
-
- src = p->bytes + p->offset;
- while(1)
- {
- decode_ptr (&src, &pos);
- p->offset = src - (char*) p->bytes;
-
- if (!untilb || p->offset == p->size)
- break;
- assert(p->offset < p->size);
- decode_ptr (&src, &item_len);
- if ((*pp->isamb->method->compare_item)(untilb, src) <= 1)
- break;
- src += item_len;
- }
- pp->level++;
- }
- }
- assert (p->offset < p->size);
- assert (p->leaf);
- while(1)
- {
- char *dst0 = dst;
- src = p->bytes + p->offset;
- (*pp->isamb->method->codec.decode)(p->decodeClientData, &dst, &src);
- p->offset = src - (char*) p->bytes;
- if (!untilb || (*pp->isamb->method->compare_item)(untilb, dst0) <= 1)
- break;
- dst = dst0;
- if (p->offset == p->size) goto again;
- }
- /* key_logdump_txt(LOG_DEBUG,buf, "isamb_pp_read returning 1"); */
- return 1;
-}
-
-#endif
-
void isamb_pp_pos( ISAMB_PP pp, double *current, double *total )
{ /* return an estimate of the current position and of the total number of */
/* occureences in the isam tree, based on the current leaf */
-/* $Id: tstisamb.c,v 1.9 2004-08-23 13:06:46 adam Exp $
+/* $Id: tstisamb.c,v 1.10 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
isamc_p = isamb_merge (isb, 0 /* new list */ , &isamc_i);
/* read the entries */
- pp = isamb_pp_open (isb, isamc_p);
+ pp = isamb_pp_open (isb, isamc_p, 2);
for (i = 0; i<ri.max; i +=2 )
{
}
isamb_pp_close(pp);
- pp = isamb_pp_open (isb, isamc_p);
+ pp = isamb_pp_open (isb, isamc_p, 2);
for (i = 0; i<ri.max; i += 100)
{
int x = -1;
isamc_p = isamb_merge (isb, 0 /* new list */ , &isamc_i);
/* read the entries */
- pp = isamb_pp_open (isb, isamc_p);
+ pp = isamb_pp_open (isb, isamc_p, 2);
ri.no = 0;
while(isamb_pp_read (pp, key_buf))
-/* $Id: rsbetween.c,v 1.24 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rsbetween.c,v 1.25 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#endif
RSET rsbetween_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_m, RSET rset_r, RSET rset_attr)
{
- RSET rnew=rset_create_base(&control, nmem, kcontrol);
+ RSET rnew=rset_create_base(&control, nmem, kcontrol, scope);
struct rset_between_info *info=
(struct rset_between_info *) nmem_malloc(rnew->nmem,sizeof(*info));
info->rset_l = rset_l;
else
{
p->level = 0;
- cmp_l=2; /* past this record */
+ cmp_l=rfd->rset->scope; /* past this record */
}
#if RSBETWEEN_DEBUG
log2( p, "after first L", cmp_l, cmp_r);
while (cmp_l < 0) /* l before m */
{
- if (cmp_l == -2)
+ if (cmp_l <= - rfd->rset->scope) /* ==-2 */
p->level=0; /* earlier record */
- if (cmp_l == -1)
+ if (cmp_l > - rfd->rset->scope) /* == -1 */
{
p->level++; /* relevant start tag */
}
else if (cmp_attr > 0)
break;
- else if (cmp_attr==-1)
+ else if (cmp_attr > - rfd->rset->scope) /* == -1 */
p->more_attr = rset_read (p->rfd_attr, p->buf_attr);
/* if we had a forward that went all the way to
* the seqno, we could use that. But fwd only goes
* to the sysno */
- else if (cmp_attr==-2)
+ else if (cmp_attr <= - rfd->rset->scope) /* ==-2 */
{
p->more_attr = rset_forward( p->rfd_attr,
p->buf_attr, p->buf_l);
}
#define NEWCODE 1
#if NEWCODE
- if (cmp_l==-2)
+ if (cmp_l <= - rfd->rset->scope )/* ==-2 */
{
if (p->more_l)
{
if (p->more_l)
cmp_l= (*kctrl->cmp)(p->buf_l, p->buf_m);
else
- cmp_l=2;
+ cmp_l=rfd->rset->scope; /*2*/
#if RSBETWEEN_DEBUG
log2( p, "after forwarding L", cmp_l, cmp_r);
#endif
cmp_l= (*kctrl->cmp)(p->buf_l, p->buf_m);
}
else
- cmp_l=2;
+ cmp_l=rfd->rset->scope; /*2*/
#if RSBETWEEN_DEBUG
log2( p, "end of L loop", cmp_l, cmp_r);
#endif
if (p->more_r)
cmp_r= (*kctrl->cmp)(p->buf_r, p->buf_m);
else
- cmp_r=2;
+ cmp_r=rfd->rset->scope; /*2*/
#if RSBETWEEN_DEBUG
log2( p, "after first R", cmp_l, cmp_r);
#endif
while (cmp_r < 0) /* r before m */
{
/* -2, earlier record, don't count level */
- if (cmp_r == -1)
+ if (cmp_r > -rfd->rset->scope) /* == -1 */
p->level--; /* relevant end tag */
if (p->more_r)
{
#if NEWCODE
- if (cmp_r==-2)
+ if (cmp_r <= - rfd->rset->scope) /* == -2 */
{
p->more_r=rset_forward(p->rfd_r, p->buf_r, p->buf_m);
} else
#endif
}
else
- cmp_r=2;
+ cmp_r=rfd->rset->scope; /*2*/
#if RSBETWEEN_DEBUG
log2( p, "End of R loop", cmp_l, cmp_r);
#endif
log2( p, "Returning a hit (and forwarding m)", cmp_l, cmp_r);
#endif
p->more_m = rset_read (p->rfd_m, p->buf_m);
- if (cmp_l == 2)
+ if (cmp_l >= rfd->rset->scope) /* == 2 */
p->level = 0;
p->hits++;
return 1;
return 0; /* ergo, nothing can be found. stop scanning */
}
#if NEWCODE
- if (cmp_l == 2)
+ if (cmp_l >= rfd->rset->scope) /* == 2 */
{
p->level = 0;
p->more_m=rset_forward(p->rfd_m, p->buf_m, p->buf_l);
p->more_m = rset_read (p->rfd_m, p->buf_m);
}
#else
- if (cmp_l == 2)
+ if (cmp_l >= rfd->rset->scope ) /* == 2 */
p->level = 0;
p->more_m = rset_read (p->rfd_m, p->buf_m);
#endif
-/* $Id: rsbool.c,v 1.46 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rsbool.c,v 1.47 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
static RSET rsbool_create_base( const struct rset_control *ctrl,
NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_r)
{
- RSET rnew=rset_create_base(ctrl, nmem, kcontrol);
+ RSET rnew=rset_create_base(ctrl, nmem, kcontrol, scope);
struct rset_bool_info *info;
info = (struct rset_bool_info *) nmem_malloc(rnew->nmem,sizeof(*info));
info->rset_l = rset_l;
RSET rsbool_create_and( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_r)
{
return rsbool_create_base(rset_kind_and, nmem, kcontrol,
+ scope,
rset_l, rset_r);
}
RSET rsbool_create_or( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_r)
{
return rsbool_create_base(rset_kind_or, nmem, kcontrol,
+ scope,
rset_l, rset_r);
}
RSET rsbool_create_not( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
RSET rset_l, RSET rset_r)
{
return rsbool_create_base(rset_kind_not, nmem, kcontrol,
+ scope,
rset_l, rset_r);
}
struct rset_bool_rfd *p=(struct rset_bool_rfd *)rfd->priv;
const struct key_control *kctrl=rfd->rset->keycontrol;
- if ( p->more_l && ((kctrl->cmp)(untilbuf,p->buf_l)==2) )
+ if ( p->more_l && ((kctrl->cmp)(untilbuf,p->buf_l)>=rfd->rset->scope) )
p->more_l = rset_forward(p->rfd_l, p->buf_l, untilbuf);
- if ( p->more_r && ((kctrl->cmp)(untilbuf,p->buf_r)==2))
+ if ( p->more_r && ((kctrl->cmp)(untilbuf,p->buf_r)>=rfd->rset->scope))
p->more_r = rset_forward(p->rfd_r, p->buf_r, untilbuf);
p->tail=0;
return rset_read(rfd,buf);
if (p->more_l && p->more_r)
cmp = (*kctrl->cmp)(p->buf_l, p->buf_r);
else if (p->more_l)
- cmp = -2;
+ cmp = -rfd->rset->scope;
else
- cmp = 2;
+ cmp = rfd->rset->scope;
#if RSET_DEBUG
logf (LOG_DEBUG, "r_read_and [%p] looping: m=%d/%d c=%d t=%d",
rfd, p->more_l, p->more_r, cmp, p->tail);
(*kctrl->log_item)(LOG_DEBUG, p->buf_r, "right ");
#endif
if (!cmp)
- {
+ { /* cmp==0 */
memcpy (buf, p->buf_l, kctrl->key_size);
p->more_l = rset_read (p->rfd_l, p->buf_l);
p->tail = 1;
}
- else if (cmp == 1)
- {
+ else if ( (cmp>0) && (cmp<rfd->rset->scope))
+ { /* typically cmp == 1 */
memcpy (buf, p->buf_r, kctrl->key_size);
p->more_r = rset_read (p->rfd_r, p->buf_r);
p->tail = 1;
p->hits++;
return 1;
}
- else if (cmp == -1)
- {
+ else if ( (cmp<0) && (-cmp<rfd->rset->scope))
+ { /* cmp == -1 */
memcpy (buf, p->buf_l, kctrl->key_size);
p->more_l = rset_read (p->rfd_l, p->buf_l);
p->tail = 1;
p->hits++;
return 1;
}
- else if (cmp > 1) /* cmp == 2 */
- {
+ else if (cmp >= rfd->rset->scope )
+ { /* cmp == 2 */
if (p->tail)
{
memcpy (buf, p->buf_r, kctrl->key_size);
return 0; /* no point in reading further */
}
}
- else /* cmp == -2 */
- {
+ else
+ { /* cmp == -2 */
if (p->tail)
{
memcpy (buf, p->buf_l, kctrl->key_size);
if (p->more_l && p->more_r)
cmp = (*kctrl->cmp)(p->buf_l, p->buf_r);
else if (p->more_r)
- cmp = 2;
+ cmp = rfd->rset->scope;
else
- cmp = -2;
+ cmp = -rfd->rset->scope;
if (!cmp)
- {
+ { /* cmp==0 */
memcpy (buf, p->buf_l, kctrl->key_size);
p->more_l = rset_read (p->rfd_l, p->buf_l);
p->more_r = rset_read (p->rfd_r, p->buf_r);
if (p->more_l && p->more_r)
cmp = (*kctrl->cmp)(p->buf_l, p->buf_r);
else if (p->more_r)
- cmp = 2;
+ cmp = rfd->rset->scope;
else
- cmp = -2;
- if (cmp < -1)
- {
+ cmp = -rfd->rset->scope;
+
+ if (cmp <= -rfd->rset->scope)
+ { /* cmp == -2 */
memcpy (buf, p->buf_l, kctrl->key_size);
p->more_l = rset_read (p->rfd_l, p->buf_l);
p->hits++;
return 1;
}
- else if (cmp > 1)
+ else if (cmp >= rfd->rset->scope) /* cmp >1 */
p->more_r = rset_forward( p->rfd_r, p->buf_r, p->buf_l);
else
- {
+ { /* cmp== -1, 0, or 1 */
memcpy (buf, p->buf_l, kctrl->key_size);
do
{
if (!p->more_l)
break;
cmp = (*kctrl->cmp)(p->buf_l, buf);
- } while (cmp >= -1 && cmp <= 1);
+ } while (abs(cmp)<rfd->rset->scope);
+ /* (cmp >= -1 && cmp <= 1) */
do
{
p->more_r = rset_read (p->rfd_r, p->buf_r);
if (!p->more_r)
break;
cmp = (*kctrl->cmp)(p->buf_r, buf);
- } while (cmp >= -1 && cmp <= 1);
+ } while (abs(cmp)<rfd->rset->scope);
+ /* (cmp >= -1 && cmp <= 1) */
}
}
return 0;
-/* $Id: rset.c,v 1.32 2004-09-03 14:59:50 heikki Exp $
+/* $Id: rset.c,v 1.33 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
RSET rset_create_base(const struct rset_control *sel,
- NMEM nmem, const struct key_control *kcontrol)
+ NMEM nmem, const struct key_control *kcontrol,
+ int scope)
{
RSET rnew;
NMEM M;
rnew->priv = 0;
rnew->free_list=NULL;
rnew->keycontrol=kcontrol;
+ rnew->scope=scope;
return rnew;
}
const void *untilbuf)
{
int more=1;
- int cmp=2;
+ int cmp=rfd->rset->scope;
logf (LOG_DEBUG, "rset_default_forward starting '%s' (ct=%p rfd=%p)",
rfd->rset->control->desc, rfd->rset, rfd);
/* key_logdump(LOG_DEBUG, untilbuf); */
- while ( (cmp==2) && (more))
+ while ( (cmp>=rfd->rset->scope) && (more))
{
logf (LOG_DEBUG, "rset_default_forward looping m=%d c=%d",more,cmp);
more=rset_read(rfd, buf);
-/* $Id: rsisamb.c,v 1.21 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rsisamb.c,v 1.22 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
ISAMB_P pos;
};
-RSET rsisamb_create( NMEM nmem, const struct key_control *kcontrol,
+RSET rsisamb_create( NMEM nmem, const struct key_control *kcontrol, int scope,
ISAMB is, ISAMB_P pos)
{
- RSET rnew=rset_create_base(&control, nmem, kcontrol);
+ RSET rnew=rset_create_base(&control, nmem, kcontrol, scope);
struct rset_isamb_info *info;
info = (struct rset_isamb_info *) nmem_malloc(rnew->nmem,sizeof(*info));
info->is=is;
ptinfo->buf = nmem_malloc (ct->nmem,ct->keycontrol->key_size);
rfd->priv=ptinfo;
}
- ptinfo->pt = isamb_pp_open (info->is, info->pos);
+ ptinfo->pt = isamb_pp_open (info->is, info->pos, ct->scope );
return rfd;
}
-/* $Id: rsisamc.c,v 1.24 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rsisamc.c,v 1.25 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
ISAMC_P pos;
};
-RSET rsisamc_create( NMEM nmem, const struct key_control *kcontrol,
+RSET rsisamc_create( NMEM nmem, const struct key_control *kcontrol, int scope,
ISAMC is, ISAMC_P pos)
{
- RSET rnew=rset_create_base(&control, nmem, kcontrol);
+ RSET rnew=rset_create_base(&control, nmem, kcontrol, scope);
struct rset_isamc_info *info;
info = (struct rset_isamc_info *) nmem_malloc(rnew->nmem,sizeof(*info));
info->is=is;
static void r_rewind (RSFD rfd)
{
- logf (LOG_DEBUG, "rsisamc_rewind");
+ logf (LOG_FATAL, "rsisamc_rewind");
abort ();
}
-/* $Id: rsisams.c,v 1.12 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rsisams.c,v 1.13 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
};
-RSET rsisams_create( NMEM nmem, const struct key_control *kcontrol,
+RSET rsisams_create( NMEM nmem, const struct key_control *kcontrol, int scope,
ISAMS is, ISAMS_P pos)
{
- RSET rnew=rset_create_base(&control, nmem, kcontrol);
+ RSET rnew=rset_create_base(&control, nmem, kcontrol, scope);
struct rset_isams_info *info;
info = (struct rset_isams_info *) nmem_malloc(rnew->nmem,sizeof(*info));
rnew->priv=info;
-/* $Id: rsmultior.c,v 1.9 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rsmultior.c,v 1.10 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
}
-RSET rsmultior_create( NMEM nmem, const struct key_control *kcontrol,
+RSET rsmultior_create( NMEM nmem, const struct key_control *kcontrol, int scope,
int no_rsets, RSET* rsets)
{
- RSET rnew=rset_create_base(&control, nmem,kcontrol);
+ RSET rnew=rset_create_base(&control, nmem,kcontrol, scope);
struct rset_multior_info *info;
info = (struct rset_multior_info *) nmem_malloc(rnew->nmem,sizeof(*info));
info->no_rsets=no_rsets;
-/* $Id: rsnull.c,v 1.25 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rsnull.c,v 1.26 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
RSET rsnull_create(NMEM nmem, const struct key_control *kcontrol )
{
- RSET rnew=rset_create_base(&control, nmem, kcontrol);
+ RSET rnew=rset_create_base(&control, nmem, kcontrol,0);
rnew->priv=NULL;
return rnew;
}
-/* $Id: rsprox.c,v 1.15 2004-09-03 15:04:11 heikki Exp $
+/* $Id: rsprox.c,v 1.16 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
};
-RSET rsprox_create( NMEM nmem, const struct key_control *kcontrol,
+RSET rsprox_create( NMEM nmem, const struct key_control *kcontrol, int scope,
int rset_no, RSET *rset,
int ordered, int exclusion,
int relation, int distance)
{
- RSET rnew=rset_create_base(&control, nmem, kcontrol);
+ RSET rnew=rset_create_base(&control, nmem, kcontrol, scope);
struct rset_prox_info *info;
info = (struct rset_prox_info *) nmem_malloc(rnew->nmem,sizeof(*info));
info->rset = nmem_malloc(rnew->nmem,rset_no * sizeof(*info->rset));
if (untilbuf)
{
/* it is enough to forward first one. Other will follow. */
- if ( p->more[0] && ((kctrl->cmp)(untilbuf, p->buf[0]) >= 2) )
+ if ( p->more[0] && /* was: cmp >=2 */
+ ((kctrl->cmp)(untilbuf, p->buf[0]) >= rfd->rset->scope) )
p->more[0] = rset_forward(p->rfd[0], p->buf[0], untilbuf);
}
if (info->ordered && info->relation == 3 && info->exclusion == 0
break;
}
cmp = (*kctrl->cmp) (p->buf[i], p->buf[i-1]);
- if (cmp > 1)
+ if (cmp >= rfd->rset->scope ) /* cmp>1 */
{
p->more[i-1] = rset_forward (p->rfd[i-1],
p->buf[i-1],
p->buf[i]);
break;
}
- else if (cmp == 1)
+ else if ( cmp>0 ) /* cmp == 1*/
{
if ((*kctrl->getseq)(p->buf[i-1]) +1 !=
(*kctrl->getseq)(p->buf[i]))
while (p->more[0] && p->more[1])
{
int cmp = (*kctrl->cmp)(p->buf[0], p->buf[1]);
- if (cmp < -1)
+ if ( cmp <= - rfd->rset->scope) /* cmp<-1*/
p->more[0] = rset_forward (p->rfd[0],
p->buf[0], p->buf[1]);
- /* FIXME - this certainly looks wrong! */
- else if (cmp > 1)
+ else if ( cmp >= rfd->rset->scope ) /* cmp>1 */
p->more[1] = rset_forward (p->rfd[1],
p->buf[1], p->buf[0]);
else
-/* $Id: rstemp.c,v 1.48 2004-09-01 15:01:32 heikki Exp $
+/* $Id: rstemp.c,v 1.49 2004-09-09 10:08:06 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
};
RSET rstemp_create( NMEM nmem, const struct key_control *kcontrol,
+ int scope,
const char *temp_path)
{
- RSET rnew=rset_create_base(&control, nmem, kcontrol);
+ RSET rnew=rset_create_base(&control, nmem, kcontrol, scope);
struct rset_temp_info *info;
info = (struct rset_temp_info *) nmem_malloc(rnew->nmem, sizeof(*info));