passign them to ranking, but getting closer...
Also, fixed some bugs in rsprox (hooray for our tests!)
-/* $Id: rset.h,v 1.37 2004-10-15 10:07:32 heikki Exp $
+/* $Id: rset.h,v 1.38 2004-10-20 14:32:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
typedef struct rsfd *RSFD; /* Rset "file descriptor" */
typedef struct rset *RSET; /* Result set */
-/*
-typedef struct terminfo *TERMID;
-*/
-typedef int TERMID;
- /* term thing for the rsets. They don't need to */
- /* know what it is. FIXME - define that somewhere */
-/* using int while testing, to get more type checking to work */
+/**
+ * rset_term is all we need to know of a term to do ranking etc.
+ * As far as the rsets are concerned, it is just a dummy pointer to
+ * be passed around.
+ */
+
+struct rset_term {
+ char *name;
+ int nn;
+ char *flags;
+ int count;
+ int type;
+};
+
+typedef struct rset_term *TERMID;
+TERMID rset_term_create (const char *name, int length, const char *flags,
+ int type, NMEM nmem);
+
+
+
+/** rsfd is a "file descriptor" for reading from a rset */
struct rsfd { /* the stuff common to all rsfd's. */
RSET rset; /* ptr to the rset this FD is opened to */
void *priv; /* private parameters for this type */
};
+/**
+ * rset_control has function pointers to all the important functions
+ * of a rset. Each type of rset will have its own control block, pointing
+ * to the functions for that type. They all have their own create function
+ * which is not part of the control block, as it takes different args for
+ * each type.
+ */
struct rset_control
{
char *desc; /* text description of set type (for debugging) */
int (*f_write)(RSFD rfd, const void *buf);
};
+/** rset_default_forward implements a generic forward with a read-loop */
int rset_default_forward(RSFD rfd, void *buf, TERMID *term,
const void *untilbuf);
+/**
+ * key_control contains all there is to know about the keys stored in
+ * an isam, and therefore operated by the rsets. Other than this info,
+ * all we assume is that all keys are the same size, and they can be
+ * memcpy'd around
+ */
struct key_control {
int key_size;
int scope; /* default for what level we operate (book/chapter/verse) on*/
/* FIXME - decode and encode, and lots of other stuff */
};
+/**
+ * A rset is an ordered sequence of keys, either directly from an underlaying
+ * isam, or from one of the higher-level operator rsets (and, or, ...).
+ * Actually, it is "virtual base class", no pure rsets exist in the system,
+ * they all are of some derived type.
+ */
typedef struct rset
{
const struct rset_control *control;
-/* $Id: trunc.c,v 1.46 2004-10-15 10:07:32 heikki Exp $
+/* $Id: trunc.c,v 1.47 2004-10-20 14:32:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
int preserve_position, int term_type, NMEM rset_nmem,
const struct key_control *kctrl, int scope)
{
+ TERMID termid;
logf (LOG_DEBUG, "rset_trunc no=%d", no);
if (no < 1)
return rsnull_create (rset_nmem,kctrl);
+ termid=rset_term_create(term, length, flags, term_type,rset_nmem);
if (zi->reg->isams)
{
if (no == 1)
return rsisams_create(rset_nmem, kctrl, scope,
- zi->reg->isams, *isam_p,
- 0 /*FIXME - use proper TERMID*/);
+ zi->reg->isams, *isam_p, termid);
qsort (isam_p, no, sizeof(*isam_p), isams_trunc_cmp);
}
else if (zi->reg->isamc)
{
if (no == 1)
return rsisamc_create(rset_nmem, kctrl, scope,
- zi->reg->isamc, *isam_p,
- 0 /*FIXME - use proper TERMID*/);
+ zi->reg->isamc, *isam_p, termid);
qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp);
}
else if (zi->reg->isamb)
{
if (no == 1)
return rsisamb_create(rset_nmem,kctrl, scope,
- zi->reg->isamb, *isam_p, 0 /* FIXME - TERMID */ );
+ zi->reg->isamb, *isam_p, termid);
else if (no <10000 ) /* FIXME - hardcoded number */
{
RSET r;
int i;
for (i=0;i<no;i++)
rsets[i]=rsisamb_create(rset_nmem, kctrl, scope,
- zi->reg->isamb, isam_p[i],
- 0 /* FIXME - use a proper TERMID */ );
+ zi->reg->isamb, isam_p[i], termid);
r=rsmultior_create( rset_nmem, kctrl, scope, no, rsets);
xfree(rsets);
return r;
-/* $Id: zsets.c,v 1.63 2004-10-15 10:07:34 heikki Exp $
+/* $Id: zsets.c,v 1.64 2004-10-20 14:32:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
return NULL;
if (s->rset)
rset_delete (s->rset);
+ if (s->rset_nmem)
+ nmem_destroy (s->rset_nmem);
if (s->nmem)
nmem_destroy (s->nmem);
}
{
NMEM nmem = nmem_create ();
yaz_log (LOG_LOG, "research %s", name);
+ if (!s->rset_nmem)
+ s->rset_nmem=nmem_create();
s->rset =
rpn_search (zh, nmem, s->rset_nmem, s->rpn, s->num_bases,
s->basenames, s->name, s);
/* term lists! */
/* (*rc->add) (handle, this_sys, term_index); */
- if ( (est==-2) && (zebraSet->hits==esthits))
- { /* time to estimate the hits */
- rset_pos(rfd,&cur,&tot);
- if (tot>0) {
- ratio=cur/tot;
- est=(zint)(0.5+zebraSet->hits/ratio);
- logf(LOG_LOG, "Estimating hits (%s) "
- "%0.1f->"ZINT_FORMAT
- "; %0.1f->"ZINT_FORMAT,
- rset->control->desc,
- cur, zebraSet->hits,
- tot,est);
- i=0; /* round to 3 significant digits */
- while (est>1000) {
- est/=10;
- i++;
+ if ( (est==-2) && (zebraSet->hits==esthits))
+ { /* time to estimate the hits */
+ rset_pos(rfd,&cur,&tot);
+ if (tot>0) {
+ ratio=cur/tot;
+ est=(zint)(0.5+zebraSet->hits/ratio);
+ logf(LOG_LOG, "Estimating hits (%s) "
+ "%0.1f->"ZINT_FORMAT
+ "; %0.1f->"ZINT_FORMAT,
+ rset->control->desc,
+ cur, zebraSet->hits,
+ tot,est);
+ i=0; /* round to 3 significant digits */
+ while (est>1000) {
+ est/=10;
+ i++;
+ }
+ while (i--) est*=10;
+ zebraSet->hits=est;
}
- while (i--) est*=10;
- zebraSet->hits=est;
}
}
- }
while (rset_read (rfd, &key,0) && (est<0) );
/* FIXME - term ?? */
score = (*rc->calc) (handle, psysno);
-/* $Id: rset.c,v 1.34 2004-10-15 10:07:34 heikki Exp $
+/* $Id: rset.c,v 1.35 2004-10-20 14:32:29 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
return more;
}
+TERMID rset_term_create (const char *name, int length, const char *flags,
+ int type, NMEM nmem)
+
+{
+ TERMID t;
+ logf (LOG_DEBUG, "term_create '%s' %d f=%s type=%d nmem=%p",
+ name, length, flags, type, nmem);
+ t= (TERMID) nmem_malloc (nmem, sizeof(*t));
+ if (!name)
+ t->name = NULL;
+ else if (length == -1)
+ t->name = nmem_strdup(nmem,name);
+ else
+ {
+ t->name = (char*) nmem_malloc(nmem,length+1);
+ memcpy (t->name, name, length);
+ t->name[length] = '\0';
+ }
+ if (!flags)
+ t->flags = NULL;
+ else
+ t->flags = nmem_strdup(nmem,flags);
+ t->nn = -1;
+ t->count = 0;
+ t->type = type;
+ return t;
+}
+
+
-/* $Id: rsprox.c,v 1.18 2004-10-15 10:07:34 heikki Exp $
+/* $Id: rsprox.c,v 1.19 2004-10-20 14:32:29 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
(*kctrl->getseq)(p->buf[i]))
{ /* FIXME - We need more flexible multilevel stuff */
p->more[i-1] = rset_read ( p->rfd[i-1], p->buf[i-1],
- &p->terms[i]);
+ &p->terms[i-1]);
break;
}
}
{
memcpy (buf, p->buf[0], kctrl->key_size);
if (term)
- *term=p->terms[i];
- p->more[0] = rset_read (p->rfd[0], p->buf[0], &p->terms[i]);
+ *term=p->terms[0];
+ p->more[0] = rset_read (p->rfd[0], p->buf[0], &p->terms[0]);
p->hits++;
return 1;
}
return 1;
}
}
- p->more[1] = rset_read (p->rfd[1], p->buf[1],&p->terms[i]);
+ p->more[1] = rset_read (p->rfd[1], p->buf[1],&p->terms[1]);
}
}
}
-/* $Id: t5.c,v 1.6 2004-08-25 09:23:39 adam Exp $
+/* $Id: t5.c,v 1.7 2004-10-20 14:32:29 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
;
yaz_log_init_file("t5.log");
+ yaz_log_init_level(LOG_ALL);
nmem_init ();