-/* $Id: isamb.h,v 1.4 2005-03-08 14:02:08 adam Exp $
+/* $Id: isamb.h,v 1.5 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
typedef struct ISAMB_s *ISAMB;
typedef struct ISAMB_PP_s *ISAMB_PP;
-typedef ISAMC_P ISAMB_P;
YAZ_EXPORT
ISAMB isamb_open(BFiles bfs, const char *name, int writeflag, ISAMC_M *method,
void isamb_close(ISAMB isamb);
YAZ_EXPORT
-ISAMB_P isamb_merge(ISAMB b, ISAMB_P pos, ISAMC_I *data);
+void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *data);
YAZ_EXPORT
-ISAMB_PP isamb_pp_open(ISAMB isamb, ISAMB_P pos, int scope);
+ISAMB_PP isamb_pp_open(ISAMB isamb, ISAM_P pos, int scope);
YAZ_EXPORT
int isamb_pp_read(ISAMB_PP pp, void *buf);
void isamb_pp_close(ISAMB_PP pp);
YAZ_EXPORT
-int isamb_unlink(ISAMB b, ISAMC_P pos);
+int isamb_unlink(ISAMB b, ISAM_P pos);
YAZ_EXPORT
-ISAMB_PP isamb_pp_open_x(ISAMB isamb, ISAMB_P pos, int *level, int scope);
+ISAMB_PP isamb_pp_open_x(ISAMB isamb, ISAM_P pos, int *level, int scope);
YAZ_EXPORT
void isamb_pp_close_x(ISAMB_PP pp, zint *size, zint *blocks);
int isamb_block_info(ISAMB isamb, int cat);
YAZ_EXPORT
-void isamb_dump(ISAMB b, ISAMB_P pos, void (*pr)(const char *str));
+void isamb_dump(ISAMB b, ISAM_P pos, void (*pr)(const char *str));
YAZ_END_CDECL
-/* $Id: isamc.h,v 1.2 2005-01-15 19:38:24 adam Exp $
+/* $Id: isamc.h,v 1.3 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_BEGIN_CDECL
+typedef zint ISAM_P;
+
typedef struct ISAMC_s *ISAMC;
-typedef zint ISAMC_P;
typedef struct ISAMC_PP_s *ISAMC_PP;
typedef struct ISAMC_filecat_s {
void *clientData;
} ISAMC_I;
-void isc_getmethod (ISAMC_M *m);
+void isamc_getmethod (ISAMC_M *m);
-ISAMC isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method);
-int isc_close (ISAMC is);
-ISAMC_P isc_merge (ISAMC is, ISAMC_P pos, ISAMC_I *data);
+ISAMC isamc_open (BFiles bfs, const char *name, int writeflag,
+ ISAMC_M *method);
+int isamc_close (ISAMC is);
+void isamc_merge (ISAMC is, ISAM_P *pos, ISAMC_I *data);
-ISAMC_PP isc_pp_open (ISAMC is, ISAMC_P pos);
-void isc_pp_close (ISAMC_PP pp);
-int isc_read_item (ISAMC_PP pp, char **dst);
-int isc_pp_read (ISAMC_PP pp, void *buf);
-zint isc_pp_num (ISAMC_PP pp);
+ISAMC_PP isamc_pp_open (ISAMC is, ISAM_P pos);
+void isamc_pp_close (ISAMC_PP pp);
+int isamc_read_item (ISAMC_PP pp, char **dst);
+int isamc_pp_read (ISAMC_PP pp, void *buf);
+zint isamc_pp_num (ISAMC_PP pp);
-zint isc_block_used (ISAMC is, int type);
-int isc_block_size (ISAMC is, int type);
+zint isamc_block_used (ISAMC is, int type);
+int isamc_block_size (ISAMC is, int type);
-#define isc_type(x) ((x) & 7)
-#define isc_block(x) ((x) >> 3)
+#define isamc_type(x) ((x) & 7)
+#define isamc_block(x) ((x) >> 3)
YAZ_END_CDECL
-/* $Id: isams.h,v 1.2 2005-01-15 19:38:24 adam Exp $
+/* $Id: isams.h,v 1.3 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_BEGIN_CDECL
typedef struct ISAMS_s *ISAMS;
-typedef ISAMC_P ISAMS_P;
typedef struct ISAMS_PP_s *ISAMS_PP;
typedef struct ISAMS_M_s {
ISAMS isams_open (BFiles bfs, const char *name, int writeflag,
ISAMS_M *method);
int isams_close (ISAMS is);
-ISAMS_P isams_merge (ISAMS is, ISAMS_I data);
-ISAMS_PP isams_pp_open (ISAMS is, ISAMS_P pos);
+ISAM_P isams_merge (ISAMS is, ISAMS_I data);
+ISAMS_PP isams_pp_open (ISAMS is, ISAM_P pos);
void isams_pp_close (ISAMS_PP pp);
int isams_read_item (ISAMS_PP pp, char **dst);
int isams_pp_read (ISAMS_PP pp, void *buf);
-/* $Id: rset.h,v 1.47 2005-01-17 01:21:43 adam Exp $
+/* $Id: rset.h,v 1.48 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
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, TERMID term);
+ int scope, ISAMB is, ISAM_P pos, TERMID term);
RSET rsisamc_create(NMEM nmem, const struct key_control *kcontrol,
- int scope, ISAMC is, ISAMC_P pos, TERMID term);
+ int scope, ISAMC is, ISAM_P pos, TERMID term);
RSET rsisams_create(NMEM nmem, const struct key_control *kcontrol,
- int scope, ISAMS is, ISAMS_P pos, TERMID term);
+ int scope, ISAMS is, ISAM_P pos, TERMID term);
YAZ_END_CDECL
-/* $Id: index.h,v 1.131 2005-03-30 09:25:23 adam Exp $
+/* $Id: index.h,v 1.132 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int *position, int *num_entries, ZebraScanEntry **list,
int *is_partial, RSET limit_set, int return_zero);
-RSET rset_trunc (ZebraHandle zh, ISAMS_P *isam_p, int no,
+RSET rset_trunc (ZebraHandle zh, ISAM_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, int scope);
-/* $Id: invstat.c,v 1.45 2005-03-09 12:14:42 adam Exp $
+/* $Id: invstat.c,v 1.46 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
zint occur = 0;
int i = 0;
struct inv_stat_info *stat_info = (struct inv_stat_info*) client;
- ISAMS_P isam_p;
+ ISAM_P isam_p;
int firstsys=-1;
int firstseq=-1;
int lastsys=-1;
stat_info->no_dict_entries++;
stat_info->no_dict_bytes += strlen(name);
- assert (*info == sizeof(ISAMS_P));
- memcpy (&isam_p, info+1, sizeof(ISAMS_P));
+ assert (*info == sizeof(ISAM_P));
+ memcpy (&isam_p, info+1, sizeof(ISAM_P));
if (stat_info->zh->reg->isams)
{
zint occurx = 0;
struct it_key key;
- pp = isc_pp_open (stat_info->zh->reg->isamc, isam_p);
- occur = isc_pp_num (pp);
- while (isc_pp_read(pp, &key))
+ pp = isamc_pp_open (stat_info->zh->reg->isamc, isam_p);
+ occur = isamc_pp_num (pp);
+ while (isamc_pp_read(pp, &key))
{
occurx++;
}
assert (occurx == occur);
- stat_info->no_isam_entries[isc_type(isam_p)] += occur;
- isc_pp_close (pp);
+ stat_info->no_isam_entries[isamc_type(isam_p)] += occur;
+ isamc_pp_close (pp);
}
if (stat_info->zh->reg->isamb)
{
if (zh->reg->isamc)
{
fprintf (stdout, " Blocks Occur Size KB Bytes/Entry\n");
- for (i = 0; isc_block_used (zh->reg->isamc, i) >= 0; i++)
+ for (i = 0; isamc_block_used (zh->reg->isamc, i) >= 0; i++)
{
fprintf (stdout, " %8" ZINT_FORMAT0 " %8" ZINT_FORMAT0,
- isc_block_used (zh->reg->isamc, i),
+ isamc_block_used (zh->reg->isamc, i),
stat_info.no_isam_entries[i]);
if (stat_info.no_isam_entries[i])
fprintf (stdout, " %8d %f",
(int) ((1023.0 + (double)
- isc_block_used(zh->reg->isamc, i) *
- isc_block_size(zh->reg->isamc,i))/1024),
- ((double) isc_block_used(zh->reg->isamc, i) *
- isc_block_size(zh->reg->isamc,i))/
+ isamc_block_used(zh->reg->isamc, i) *
+ isamc_block_size(zh->reg->isamc,i))/1024),
+ ((double) isamc_block_used(zh->reg->isamc, i) *
+ isamc_block_size(zh->reg->isamc,i))/
stat_info.no_isam_entries[i]);
fprintf (stdout, "\n");
}
-/* $Id: kcompare.c,v 1.55 2005-01-15 19:38:25 adam Exp $
+/* $Id: kcompare.c,v 1.56 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
ISAMC_M *key_isamc_m (Res res, ISAMC_M *me)
{
- isc_getmethod (me);
+ isamc_getmethod (me);
me->compare_item = key_compare;
me->log_item = key_logdump_txt;
-/* $Id: kinput.c,v 1.64 2005-01-15 19:38:26 adam Exp $
+/* $Id: kinput.c,v 1.65 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
while (hci.more)
{
char this_name[INP_NAME_MAX];
- ISAMC_P isamc_p, isamc_p2;
+ ISAM_P isamc_p, isamc_p2;
char *dict_info;
strcpy (this_name, hci.cur_name);
hi->no_diffs++;
if ((dict_info = dict_lookup (hi->reg->dict, hci.cur_name)))
{
- memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P));
- isamc_p2 = isc_merge (hi->reg->isamc, isamc_p, isamc_i);
+ memcpy (&isamc_p, dict_info+1, sizeof(ISAM_P));
+ isamc_p2 = isamc_p;
+ isamc_merge (hi->reg->isamc, &isamc_p2, isamc_i);
if (!isamc_p2)
{
hi->no_deletions++;
hi->no_updates++;
if (isamc_p2 != isamc_p)
dict_insert (hi->reg->dict, this_name,
- sizeof(ISAMC_P), &isamc_p2);
+ sizeof(ISAM_P), &isamc_p2);
}
}
else
{
- isamc_p = isc_merge (hi->reg->isamc, 0, isamc_i);
+ isamc_p = 0;
+ isamc_merge (hi->reg->isamc, &isamc_p, isamc_i);
hi->no_insertions++;
- dict_insert (hi->reg->dict, this_name, sizeof(ISAMC_P), &isamc_p);
+ dict_insert (hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p);
}
}
xfree (isamc_i);
while (hci.more)
{
char this_name[INP_NAME_MAX];
- ISAMC_P isamc_p, isamc_p2;
+ ISAM_P isamc_p, isamc_p2;
char *dict_info;
strcpy (this_name, hci.cur_name);
#endif
if ((dict_info = dict_lookup (hi->reg->dict, hci.cur_name)))
{
- memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P));
- isamc_p2 = isamb_merge (hi->reg->isamb, isamc_p, isamc_i);
+ memcpy (&isamc_p, dict_info+1, sizeof(ISAM_P));
+ isamc_p2 = isamc_p;
+ isamb_merge (hi->reg->isamb, &isamc_p2, isamc_i);
if (!isamc_p2)
{
hi->no_deletions++;
hi->no_updates++;
if (isamc_p2 != isamc_p)
dict_insert (hi->reg->dict, this_name,
- sizeof(ISAMC_P), &isamc_p2);
+ sizeof(ISAM_P), &isamc_p2);
}
}
else
{
- isamc_p = isamb_merge (hi->reg->isamb, 0, isamc_i);
+ isamc_p = 0;
+ isamb_merge (hi->reg->isamb, &isamc_p, isamc_i);
hi->no_insertions++;
- dict_insert (hi->reg->dict, this_name, sizeof(ISAMC_P), &isamc_p);
+ dict_insert (hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p);
}
}
xfree (isamc_i);
while (hci.more)
{
char this_name[INP_NAME_MAX];
- ISAMS_P isams_p;
+ ISAM_P isams_p;
char *dict_info;
strcpy (this_name, hci.cur_name);
{
isams_p = isams_merge (hi->reg->isams, isams_i);
hi->no_insertions++;
- dict_insert (hi->reg->dict, this_name, sizeof(ISAMS_P), &isams_p);
+ dict_insert (hi->reg->dict, this_name, sizeof(ISAM_P), &isams_p);
}
else
{
-/* $Id: trunc.c,v 1.51 2005-01-15 20:47:15 adam Exp $
+/* $Id: trunc.c,v 1.52 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
xfree(ti);
}
-static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length,
- 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, int scope,
- TERMID termid)
+static RSET rset_trunc_r(ZebraHandle zi, const char *term, int length,
+ const char *flags, ISAM_P *isam_p, int from, int to,
+ int merge_chunk, int preserve_position,
+ int term_type, NMEM rset_nmem,
+ const struct key_control *kctrl, int scope,
+ TERMID termid)
{
RSET result;
RSFD result_rsfd;
key_compare_it);
for (i = to-from; --i >= 0; )
{
- ispt[i] = isc_pp_open (zi->reg->isamc, isam_p[from+i]);
- if (isc_pp_read (ispt[i], ti->tmpbuf))
+ ispt[i] = isamc_pp_open (zi->reg->isamc, isam_p[from+i]);
+ if (isamc_pp_read (ispt[i], ti->tmpbuf))
heap_insert (ti, ti->tmpbuf, i);
else
- isc_pp_close (ispt[i]);
+ isamc_pp_close (ispt[i]);
}
while (ti->heapnum)
{
if (preserve_position)
{
heap_delete (ti);
- if (isc_pp_read (ispt[n], ti->tmpbuf))
+ if (isamc_pp_read (ispt[n], ti->tmpbuf))
heap_insert (ti, ti->tmpbuf, n);
else
- isc_pp_close (ispt[n]);
+ isamc_pp_close (ispt[n]);
}
else
{
while (1)
{
- if (!isc_pp_read (ispt[n], ti->tmpbuf))
+ if (!isamc_pp_read (ispt[n], ti->tmpbuf))
{
heap_delete (ti);
- isc_pp_close (ispt[n]);
+ isamc_pp_close (ispt[n]);
break;
}
if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > 1)
static int isams_trunc_cmp (const void *p1, const void *p2)
{
- ISAMS_P i1 = *(ISAMS_P*) p1;
- ISAMS_P i2 = *(ISAMS_P*) p2;
+ ISAM_P i1 = *(ISAM_P*) p1;
+ ISAM_P i2 = *(ISAM_P*) p2;
if (i1 > i2)
return 1;
static int isamc_trunc_cmp (const void *p1, const void *p2)
{
- ISAMC_P i1 = *(ISAMC_P*) p1;
- ISAMC_P i2 = *(ISAMC_P*) p2;
+ ISAM_P i1 = *(ISAM_P*) p1;
+ ISAM_P i2 = *(ISAM_P*) p2;
zint d;
- d = (isc_type (i1) - isc_type (i2));
+ d = (isamc_type (i1) - isamc_type (i2));
if (d == 0)
- d = isc_block (i1) - isc_block (i2);
+ d = isamc_block (i1) - isamc_block (i2);
if (d > 0)
return 1;
else if (d < 0)
return 0;
}
-RSET rset_trunc (ZebraHandle zi, ISAMS_P *isam_p, int no,
+RSET rset_trunc (ZebraHandle zi, ISAM_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, int scope)
-/* $Id: zebraapi.c,v 1.157 2005-04-13 08:52:27 adam Exp $
+/* $Id: zebraapi.c,v 1.158 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
{
struct ISAMC_M_s isamc_m;
- if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
+ if (!(reg->isamc = isamc_open (reg->bfs, FNAME_ISAMC,
rw, key_isamc_m(res, &isamc_m))))
{
- yaz_log (YLOG_WARN, "isc_open failed");
+ yaz_log (YLOG_WARN, "isamc_open failed");
return 0;
}
}
if (reg->isams)
isams_close (reg->isams);
if (reg->isamc)
- isc_close (reg->isamc);
+ isamc_close (reg->isamc);
if (reg->isamb)
isamb_close (reg->isamb);
rec_close (®->records);
int delete_w_handle(const char *info, void *handle)
{
ZebraHandle zh = (ZebraHandle) handle;
- ISAMC_P pos;
+ ISAM_P pos;
ASSERTZH;
if (*info == sizeof(pos))
-/* $Id: zrpn.c,v 1.172 2005-04-13 08:52:01 adam Exp $
+/* $Id: zrpn.c,v 1.173 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#ifdef TERM_COUNT
int *term_no;
#endif
- ISAMC_P *isam_p_buf;
+ ISAM_P *isam_p_buf;
int isam_p_size;
int isam_p_indx;
ZebraHandle zh;
}
if (p->isam_p_indx == p->isam_p_size)
{
- ISAMC_P *new_isam_p_buf;
+ ISAM_P *new_isam_p_buf;
#ifdef TERM_COUNT
int *new_term_no;
#endif
p->isam_p_size = 2*p->isam_p_size + 100;
- new_isam_p_buf = (ISAMC_P *) xmalloc(sizeof(*new_isam_p_buf) *
- p->isam_p_size);
+ new_isam_p_buf = (ISAM_P *) xmalloc(sizeof(*new_isam_p_buf) *
+ p->isam_p_size);
if (p->isam_p_buf)
{
memcpy(new_isam_p_buf, p->isam_p_buf,
struct scan_info_entry {
char *term;
- ISAMC_P isam_p;
+ ISAM_P isam_p;
};
struct scan_info {
scan_info->list[idx].term = (char *)
odr_malloc(scan_info->odr, strlen(name + len_prefix)+1);
strcpy(scan_info->list[idx].term, name + len_prefix);
- assert (*info == sizeof(ISAMC_P));
- memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAMC_P));
+ assert (*info == sizeof(ISAM_P));
+ memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAM_P));
return 0;
}
-/* $Id: isamb.c,v 1.75 2005-03-21 17:20:54 adam Exp $
+/* $Id: isamb.c,v 1.76 2005-04-13 13:03:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#define ISAMB_PTR_CODEC 1
struct ISAMB_cache_entry {
- ISAMB_P pos;
+ ISAM_P pos;
unsigned char *buf;
int dirty;
int hits;
};
struct ISAMB_block {
- ISAMB_P pos;
+ ISAM_P pos;
int cat;
int size;
int leaf;
struct ISAMB_PP_s {
ISAMB isamb;
- ISAMB_P pos;
+ ISAM_P pos;
int level;
int maxlevel; /* total depth */
zint total_size;
#endif
ISAMB isamb_open(BFiles bfs, const char *name, int writeflag, ISAMC_M *method,
- int cache)
+ int cache)
{
ISAMB isamb = xmalloc(sizeof(*isamb));
int i, b_size = ISAMB_MIN_SIZE;
}
}
-static int cache_block (ISAMB b, ISAMC_P pos, char *userbuf, int wr)
+static int cache_block (ISAMB b, ISAM_P pos, char *userbuf, int wr)
{
int cat = (int) (pos&CAT_MASK);
int off = (int) (((pos/CAT_MAX) &
* Reserve 5 bytes for large block sizes. 1 for small ones .. Number
of items. We can thus have at most 2^40 nodes.
*/
-static struct ISAMB_block *open_block(ISAMB b, ISAMC_P pos)
+static struct ISAMB_block *open_block(ISAMB b, ISAM_P pos)
{
int cat = (int) (pos&CAT_MASK);
const char *src;
char *startp = p->bytes;
const char *src = startp;
char *endp = p->bytes + p->size;
- ISAMB_P pos;
+ ISAM_P pos;
void *c1 = (*b->method->codec.start)();
decode_ptr(&src, &pos);
char *startp = p->bytes;
const char *src = startp;
char *endp = p->bytes + p->size;
- ISAMB_P pos;
+ ISAM_P pos;
struct ISAMB_block *sub_p1 = 0, *sub_p2 = 0;
char sub_item[DST_ITEM_MAX];
int sub_size;
sub_size, max_item);
}
-int isamb_unlink (ISAMB b, ISAMC_P pos)
+int isamb_unlink (ISAMB b, ISAM_P pos)
{
struct ISAMB_block *p1;
return 0;
}
-ISAMB_P isamb_merge (ISAMB b, ISAMC_P pos, ISAMC_I *stream)
+void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *stream)
{
char item_buf[DST_ITEM_MAX];
char *item_ptr;
more =
(*stream->read_item)(stream->clientData, &item_ptr, &i_mode);
}
- return 1;
+ *pos = 1;
+ return;
}
item_ptr = item_buf;
more = (*stream->read_item)(stream->clientData, &item_ptr, &i_mode);
char sub_item[DST_ITEM_MAX];
int sub_size;
- if (pos)
- p = open_block(b, pos);
+ if (*pos)
+ p = open_block(b, *pos);
more = insert_sub (b, &p, item_buf, &i_mode, stream, &sp,
sub_item, &sub_size, 0);
if (sp)
p2->size = dst - p2->bytes;
p2->no_items = p->no_items + sp->no_items;
- pos = p2->pos; /* return new super page */
+ *pos = p2->pos; /* return new super page */
close_block(b, sp);
close_block(b, p2);
#if INT_ENCODE
}
else
{
- pos = p->pos; /* return current one (again) */
+ *pos = p->pos; /* return current one (again) */
}
if (p->no_items == 0)
must_delete = 1;
}
if (must_delete)
{
- isamb_unlink(b, pos);
- return 0;
+ isamb_unlink(b, *pos);
+ *pos = 0;
}
- return pos;
}
-ISAMB_PP isamb_pp_open_x(ISAMB isamb, ISAMB_P pos, int *level, int scope)
+ISAMB_PP isamb_pp_open_x(ISAMB isamb, ISAM_P pos, int *level, int scope)
{
ISAMB_PP pp = xmalloc(sizeof(*pp));
int i;
return pp;
}
-ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos, int scope)
+ISAMB_PP isamb_pp_open (ISAMB isamb, ISAM_P pos, int scope)
{
return isamb_pp_open_x(isamb, pos, 0, scope);
}
}
/* simple recursive dumper .. */
-static void isamb_dump_r (ISAMB b, ISAMB_P pos, void (*pr)(const char *str),
+static void isamb_dump_r (ISAMB b, ISAM_P pos, void (*pr)(const char *str),
int level)
{
char buf[1024];
else
{
const char *src = p->bytes + p->offset;
- ISAMB_P sub;
+ ISAM_P sub;
decode_ptr(&src, &sub);
p->offset = src - (char*) p->bytes;
}
}
-void isamb_dump(ISAMB b, ISAMB_P pos, void (*pr)(const char *str))
+void isamb_dump(ISAMB b, ISAM_P pos, void (*pr)(const char *str))
{
isamb_dump_r(b, pos, pr, 0);
}
}
} /* forward_on_leaf */
-static int isamb_pp_climb_level(ISAMB_PP pp, ISAMB_P *pos)
+static int isamb_pp_climb_level(ISAMB_PP pp, ISAM_P *pos)
{ /* climbs higher in the tree, until finds a level with data left */
/* returns the node to (consider to) descend to in *pos) */
struct ISAMB_block *p = pp->block[pp->level];
} /* forward_unode */
-static void isamb_pp_descend_to_leaf(ISAMB_PP pp, ISAMB_P pos,
+static void isamb_pp_descend_to_leaf(ISAMB_PP pp, ISAM_P pos,
const void *untilbuf)
{ /* climbs down the tree, from pos, to the leftmost leaf */
struct ISAMB_block *p = pp->block[pp->level];
static int isamb_pp_find_next_leaf(ISAMB_PP pp)
{ /* finds the next leaf by climbing up and down */
- ISAMB_P pos;
+ ISAM_P pos;
if (!isamb_pp_climb_level(pp, &pos))
return 0;
isamb_pp_descend_to_leaf(pp, pos, 0);
static int isamb_pp_climb_desc(ISAMB_PP pp, const void *untilbuf)
{ /* climbs up and descends to a leaf where values >= *untilbuf are found */
- ISAMB_P pos;
+ ISAM_P pos;
#if ISAMB_DEBUG
struct ISAMB_block *p = pp->block[pp->level];
yaz_log(YLOG_DEBUG, "isamb_pp_climb_desc starting "
again:
while (p->offset == p->size)
{
- ISAMB_P pos;
+ ISAM_P pos;
#if INT_ENCODE
const char *src_0;
void *c1;
-/* $Id: tstisamb.c,v 1.19 2005-03-21 17:20:54 adam Exp $
+/* $Id: tstisamb.c,v 1.20 2005-04-13 13:03:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
void tst_insert(ISAMB isb, int n)
{
ISAMC_I isamc_i;
- ISAMC_P isamc_p;
+ ISAM_P isamc_p;
struct read_info ri;
ISAMB_PP pp;
char key_buf[10];
isamc_i.clientData = &ri;
isamc_i.read_item = code_read;
- isamc_p = isamb_merge (isb, 0 /* new list */ , &isamc_i);
+ isamc_p = 0; /* new list */
+ isamb_merge (isb, &isamc_p , &isamc_i);
/* read the entries */
pp = isamb_pp_open (isb, isamc_p, 1);
isamc_i.clientData = &ri;
isamc_i.read_item = code_read;
- isamc_p = isamb_merge (isb, isamc_p , &isamc_i);
+ isamb_merge (isb, &isamc_p , &isamc_i);
/* delete a number of entries (odd ones) */
ri.no = 1;
isamc_i.clientData = &ri;
isamc_i.read_item = code_read;
- isamc_p = isamb_merge (isb, isamc_p , &isamc_i);
+ isamb_merge (isb, &isamc_p, &isamc_i);
if (isamc_p)
{
void tst_forward(ISAMB isb, int n)
{
ISAMC_I isamc_i;
- ISAMC_P isamc_p;
+ ISAM_P isamc_p;
struct read_info ri;
int i;
ISAMB_PP pp;
isamc_i.clientData = &ri;
isamc_i.read_item = code_read;
- isamc_p = isamb_merge (isb, 0 /* new list */ , &isamc_i);
+ isamc_p = 0;
+ isamb_merge (isb, &isamc_p, &isamc_i);
/* read the entries */
pp = isamb_pp_open (isb, isamc_p, 1);
void tst_x(ISAMB isb)
{
ISAMC_I isamc_i;
- ISAMB_P isamb_p = 0;
+ ISAM_P isamb_p = 0;
struct read_info ri;
isamc_i.clientData = &ri;
ri.step = 1;
ri.max = 1500;
- isamb_p = isamb_merge (isb, isamb_p , &isamc_i);
+ isamb_merge (isb, &isamb_p , &isamc_i);
ri.no = 1;
ri.step = 1;
ri.max = 500;
- isamb_p = isamb_merge (isb, isamb_p , &isamc_i);
+ isamb_merge (isb, &isamb_p , &isamc_i);
}
void tst_append(ISAMB isb, int n)
{
ISAMC_I isamc_i;
- ISAMB_P isamb_p = 0;
+ ISAM_P isamb_p = 0;
struct read_info ri;
int i;
int chunk = 10;
isamc_i.clientData = &ri;
isamc_i.read_item = code_read;
- isamb_p = isamb_merge (isb, isamb_p , &isamc_i);
+ isamb_merge (isb, &isamb_p , &isamc_i);
}
}
-/* $Id: isamc.c,v 1.29 2005-01-15 19:38:31 adam Exp $
+/* $Id: isamc.c,v 1.30 2005-04-13 13:03:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
/*
* TODO:
- * Reduction to lower categories in isc_merge
+ * Reduction to lower categories in isamc_merge
*/
#include <stdlib.h>
#include <assert.h>
#define SMALL_TEST 0
-void isc_getmethod (ISAMC_M *m)
+void isamc_getmethod (ISAMC_M *m)
{
static struct ISAMC_filecat_s def_cat[] = {
m->max_blocks_mem = 10;
}
-ISAMC isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method)
+ISAMC isamc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method)
{
ISAMC is;
ISAMC_filecat filecat;
return is;
}
-zint isc_block_used (ISAMC is, int type)
+zint isamc_block_used (ISAMC is, int type)
{
if (type < 0 || type >= is->no_files)
return -1;
return is->files[type].head.lastblock-1;
}
-int isc_block_size (ISAMC is, int type)
+int isamc_block_size (ISAMC is, int type)
{
ISAMC_filecat filecat = is->method->filecat;
if (type < 0 || type >= is->no_files)
return filecat[type].bsize;
}
-int isc_close (ISAMC is)
+int isamc_close (ISAMC is)
{
int i;
return 0;
}
-int isc_read_block (ISAMC is, int cat, zint pos, char *dst)
+int isamc_read_block (ISAMC is, int cat, zint pos, char *dst)
{
++(is->files[cat].no_reads);
return bf_read (is->files[cat].bf, pos, 0, 0, dst);
}
-int isc_write_block (ISAMC is, int cat, zint pos, char *src)
+int isamc_write_block (ISAMC is, int cat, zint pos, char *src)
{
++(is->files[cat].no_writes);
if (is->method->debug > 2)
return bf_write (is->files[cat].bf, pos, 0, 0, src);
}
-int isc_write_dblock (ISAMC is, int cat, zint pos, char *src,
+int isamc_write_dblock (ISAMC is, int cat, zint pos, char *src,
zint nextpos, int offset)
{
ISAMC_BLOCK_SIZE size = offset + ISAMC_BLOCK_OFFSET_N;
src -= ISAMC_BLOCK_OFFSET_N;
memcpy (src, &nextpos, sizeof(nextpos));
memcpy (src + sizeof(nextpos), &size, sizeof(size));
- return isc_write_block (is, cat, pos, src);
+ return isamc_write_block (is, cat, pos, src);
}
#if ISAMC_FREELIST_CHUNK
}
#endif
-zint isc_alloc_block (ISAMC is, int cat)
+zint isamc_alloc_block (ISAMC is, int cat)
{
zint block = 0;
return block;
}
-void isc_release_block (ISAMC is, int cat, zint pos)
+void isamc_release_block (ISAMC is, int cat, zint pos)
{
if (is->method->debug > 3)
yaz_log (YLOG_LOG, "isc: release_block in cat %d:" ZINT_FORMAT, cat, pos);
}
}
-void isc_pp_close (ISAMC_PP pp)
+void isamc_pp_close (ISAMC_PP pp)
{
ISAMC is = pp->is;
xfree (pp);
}
-ISAMC_PP isc_pp_open (ISAMC is, ISAMC_P ipos)
+ISAMC_PP isamc_pp_open (ISAMC is, ISAM_P ipos)
{
ISAMC_PP pp = (ISAMC_PP) xmalloc (sizeof(*pp));
char *src;
- pp->cat = (int) isc_type(ipos);
- pp->pos = isc_block(ipos);
+ pp->cat = (int) isamc_type(ipos);
+ pp->pos = isamc_block(ipos);
src = pp->buf = (char *) xmalloc (is->method->filecat[pp->cat].bsize);
if (pp->pos)
{
src = pp->buf;
- isc_read_block (is, pp->cat, pp->pos, src);
+ isamc_read_block (is, pp->cat, pp->pos, src);
memcpy (&pp->next, src, sizeof(pp->next));
src += sizeof(pp->next);
memcpy (&pp->size, src, sizeof(pp->size));
}
/* returns non-zero if item could be read; 0 otherwise */
-int isc_pp_read (ISAMC_PP pp, void *buf)
+int isamc_pp_read (ISAMC_PP pp, void *buf)
{
char *cp = buf;
- return isc_read_item (pp, &cp);
+ return isamc_read_item (pp, &cp);
}
/* read one item from file - decode and store it in *dst.
0 if end-of-file
1 if item could be read ok and NO boundary
2 if item could be read ok and boundary */
-int isc_read_item (ISAMC_PP pp, char **dst)
+int isamc_read_item (ISAMC_PP pp, char **dst)
{
ISAMC is = pp->is;
const char *src = pp->buf + pp->offset;
pp->pos = pp->next;
src = pp->buf;
/* read block and save 'next' and 'size' entry */
- isc_read_block (is, pp->cat, pp->pos, pp->buf);
+ isamc_read_block (is, pp->cat, pp->pos, pp->buf);
memcpy (&pp->next, src, sizeof(pp->next));
src += sizeof(pp->next);
memcpy (&pp->size, src, sizeof(pp->size));
}
if (pp->deleteFlag)
- isc_release_block (is, pp->cat, pp->pos);
+ isamc_release_block (is, pp->cat, pp->pos);
(*is->method->codec.decode)(pp->decodeClientData, dst, &src);
pp->offset = src - pp->buf;
if (is->method->debug > 2)
return 1;
}
-zint isc_pp_num (ISAMC_PP pp)
+zint isamc_pp_num (ISAMC_PP pp)
{
return pp->numKeys;
}
-/* $Id: merge.c,v 1.29 2005-01-15 19:38:31 adam Exp $
+/* $Id: merge.c,v 1.30 2005-04-13 13:03:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#include <yaz/log.h>
#include "isamc-p.h"
-struct isc_merge_block {
- int offset; /* offset in r_buf */
- zint block; /* block number of file (0 if none) */
- int dirty; /* block is different from that on file */
+struct isamc_merge_block {
+ int offset; /* offset in r_buf */
+ zint block; /* block number of file (0 if none) */
+ int dirty; /* block is different from that on file */
};
#if 0
-static void opt_blocks (ISAMC is, struct isc_merge_block *mb, int ptr,
+static void opt_blocks (ISAMC is, struct isamc_merge_block *mb, int ptr,
int last)
{
int i, no_dirty = 0;
}
#endif
-static void flush_blocks (ISAMC is, struct isc_merge_block *mb, int ptr,
+static void flush_blocks (ISAMC is, struct isamc_merge_block *mb, int ptr,
char *r_buf, zint *firstpos, int cat, int last,
zint *numkeys)
{
/* consider this block number */
if (!mb[i].block)
{
- mb[i].block = isc_alloc_block (is, cat);
+ mb[i].block = isamc_alloc_block (is, cat);
mb[i].dirty = 1;
}
mb[i+1].block = 0;
else if (!mb[i+1].block)
{
- mb[i+1].block = isc_alloc_block (is, cat);
+ mb[i+1].block = isamc_alloc_block (is, cat);
mb[i+1].dirty = 1;
mb[i].dirty = 1;
}
}
memcpy (src, &mb[i+1].block, sizeof(zint));
memcpy (src+sizeof(zint), &ssize, sizeof(ssize));
- isc_write_block (is, cat, mb[i].block, src);
+ isamc_write_block (is, cat, mb[i].block, src);
}
}
-static int get_border (ISAMC is, struct isc_merge_block *mb, zint ptr,
+static int get_border (ISAMC is, struct isamc_merge_block *mb, zint ptr,
int cat, zint firstpos)
{
/* Border set to initial fill or block size depending on
return mb[ptr].offset + fill - off;
}
-ISAMC_P isc_merge (ISAMC is, ISAMC_P ipos, ISAMC_I *data)
+void isamc_merge (ISAMC is, ISAM_P *ipos, ISAMC_I *data)
{
char i_item[128], *i_item_ptr;
int last_dirty = 0;
int debug = is->method->debug;
- struct isc_merge_block mb[200];
+ struct isamc_merge_block mb[200];
zint firstpos = 0;
int cat = 0;
r_clientData = (*is->method->codec.start)();
r_buf = is->merge_buf + 128;
- pp = isc_pp_open (is, ipos);
+ pp = isamc_pp_open (is, *ipos);
/* read first item from file. make sure f_more indicates no boundary */
f_item_ptr = f_item;
- f_more = isc_read_item (pp, &f_item_ptr);
+ f_more = isamc_read_item (pp, &f_item_ptr);
if (f_more > 0)
f_more = 1;
cat = pp->cat;
if (debug > 1)
- yaz_log (YLOG_LOG, "isc: isc_merge begin %d " ZINT_FORMAT, cat, pp->pos);
+ yaz_log (YLOG_LOG, "isc: isamc_merge begin %d " ZINT_FORMAT, cat, pp->pos);
/* read first item from i */
i_item_ptr = i_item;
if (debug > 3)
yaz_log (YLOG_LOG, "isc: release A");
if (mb[ptr].block)
- isc_release_block (is, pp->cat, mb[ptr].block);
+ isamc_release_block (is, pp->cat, mb[ptr].block);
mb[ptr].block = pp->pos;
if (!mb[ptr].dirty)
mb[ptr].dirty = 1;
}
/* move f */
f_item_ptr = f_item;
- f_more = isc_read_item (pp, &f_item_ptr);
+ f_more = isamc_read_item (pp, &f_item_ptr);
}
else if (cmp > 0) /* insert f */
{
memcpy (r_item, f_item, f_item_ptr - f_item);
/* move f */
f_item_ptr = f_item;
- f_more = isc_read_item (pp, &f_item_ptr);
+ f_more = isamc_read_item (pp, &f_item_ptr);
}
else /* insert i */
{
/* delete all original block(s) read so far */
for (i = 0; i < ptr; i++)
if (mb[i].block)
- isc_release_block (is, pp->cat, mb[i].block);
+ isamc_release_block (is, pp->cat, mb[i].block);
/* also delete all block to be read in the future */
pp->deleteFlag = 1;
{
if (debug > 3)
yaz_log (YLOG_LOG, "isc: release C");
- isc_release_block (is, pp->cat, mb[ptr].block);
+ isamc_release_block (is, pp->cat, mb[ptr].block);
mb[ptr].block = 0;
if (ptr > 0)
mb[ptr-1].dirty = 1;
{
/* we have to patch initial block with num keys if that
has changed */
- if (numKeys != isc_pp_num (pp))
+ if (numKeys != isamc_pp_num (pp))
{
if (debug > 2)
yaz_log (YLOG_LOG, "isc: patch num keys firstpos=" ZINT_FORMAT " num=" ZINT_FORMAT,
else if (ptr > 0)
{ /* we haven't flushed initial block yet and there surely are some
blocks to flush. Make first block dirty if numKeys differ */
- if (numKeys != isc_pp_num (pp))
+ if (numKeys != isamc_pp_num (pp))
mb[0].dirty = 1;
}
/* flush rest of block(s) in r_buf */
if (!firstpos)
cat = 0;
if (debug > 1)
- yaz_log (YLOG_LOG, "isc: isc_merge return %d " ZINT_FORMAT, cat, firstpos);
- isc_pp_close (pp);
- return cat + firstpos * 8;
+ yaz_log (YLOG_LOG, "isc: isamc_merge return %d " ZINT_FORMAT, cat, firstpos);
+ isamc_pp_close (pp);
+ *ipos = cat + firstpos * 8;
}
-/* $Id: isams.c,v 1.11 2005-01-15 19:38:31 adam Exp $
+/* $Id: isams.c,v 1.12 2005-04-13 13:03:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
return 0;
}
-ISAMS_P isams_merge (ISAMS is, ISAMS_I data)
+ISAM_P isams_merge (ISAMS is, ISAMS_I data)
{
char i_item[128];
int i_more, i_mode;
return first_block * is->block_size + first_offset;
}
-ISAMS_PP isams_pp_open (ISAMS is, ISAMS_P pos)
+ISAMS_PP isams_pp_open (ISAMS is, ISAM_P pos)
{
ISAMS_PP pp = (ISAMS_PP) xmalloc (sizeof(*pp));
-/* $Id: rsisamb.c,v 1.30 2005-03-30 09:25:24 adam Exp $
+/* $Id: rsisamb.c,v 1.31 2005-04-13 13:03:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
struct rset_isamb_info {
ISAMB is;
- ISAMB_P pos;
+ ISAM_P pos;
};
static int log_level = 0;
static int log_level_initialized = 0;
-RSET rsisamb_create( NMEM nmem, const struct key_control *kcontrol, int scope,
- ISAMB is, ISAMB_P pos, TERMID term)
+RSET rsisamb_create(NMEM nmem, const struct key_control *kcontrol, int scope,
+ ISAMB is, ISAM_P pos, TERMID term)
{
RSET rnew = rset_create_base(&control, nmem, kcontrol, scope, term);
struct rset_isamb_info *info;
-/* $Id: rsisamc.c,v 1.36 2005-03-30 09:25:24 adam Exp $
+/* $Id: rsisamc.c,v 1.37 2005-04-13 13:03:49 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
struct rset_isamc_info {
ISAMC is;
- ISAMC_P pos;
+ ISAM_P pos;
};
static int log_level = 0;
static int log_level_initialized = 0;
-RSET rsisamc_create( NMEM nmem, const struct key_control *kcontrol, int scope,
- ISAMC is, ISAMC_P pos, TERMID term)
+RSET rsisamc_create(NMEM nmem, const struct key_control *kcontrol, int scope,
+ ISAMC is, ISAM_P pos, TERMID term)
{
RSET rnew = rset_create_base(&control, nmem, kcontrol, scope,term);
struct rset_isamc_info *info;
rfd->priv = ptinfo;
ptinfo->buf = nmem_malloc (ct->nmem,ct->keycontrol->key_size);
}
- ptinfo->pt = isc_pp_open(info->is, info->pos);
+ ptinfo->pt = isamc_pp_open(info->is, info->pos);
return rfd;
}
{
struct rset_pp_info *p = (struct rset_pp_info *)(rfd->priv);
- isc_pp_close(p->pt);
+ isamc_pp_close(p->pt);
rfd_delete_base(rfd);
}
{
struct rset_pp_info *p = (struct rset_pp_info *)(rfd->priv);
int r;
- r = isc_pp_read(p->pt, buf);
+ r = isamc_pp_read(p->pt, buf);
if (term)
*term = rfd->rset->term;
yaz_log(log_level, "isamc.r_read");
-/* $Id: rsisams.c,v 1.19 2005-03-30 09:25:24 adam Exp $
+/* $Id: rsisams.c,v 1.20 2005-04-13 13:03:50 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
struct rset_isams_info {
ISAMS is;
- ISAMS_P pos;
+ ISAM_P pos;
};
-RSET rsisams_create( NMEM nmem, const struct key_control *kcontrol, int scope,
- ISAMS is, ISAMS_P pos, TERMID term)
+RSET rsisams_create(NMEM nmem, const struct key_control *kcontrol, int scope,
+ ISAMS is, ISAM_P pos, TERMID term)
{
RSET rnew=rset_create_base(&control, nmem, kcontrol, scope, term);
struct rset_isams_info *info;