-/* $Id: data1.h,v 1.7 2003-05-05 20:13:28 adam Exp $
+/* $Id: data1.h,v 1.8 2003-06-23 15:36:11 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
YAZ_EXPORT void data1_concat_text(data1_handle dh, NMEM m, data1_node *n);
+YAZ_EXPORT void data1_absyn_destroy(data1_handle dh);
+
YAZ_END_CDECL
#endif
-/* $Id: isamb.h,v 1.5 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isamb.h,v 1.6 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#ifndef ISAMB_H
#define ISAMB_H
typedef struct ISAMB_PP_s *ISAMB_PP;
typedef ISAMC_P ISAMB_P;
-ISAMB isamb_open (BFiles bfs, const char *name, int writeflag, ISAMC_M method,
+ISAMB isamb_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method,
int cache);
void isamb_close (ISAMB isamb);
-ISAMB_P isamb_merge (ISAMB b, ISAMB_P pos, ISAMC_I data);
+ISAMB_P isamb_merge (ISAMB b, ISAMB_P pos, ISAMC_I *data);
ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos);
void isamb_pp_close (ISAMB_PP pp);
+int isamb_unlink (ISAMB b, ISAMC_P pos);
+
int isamb_pp_num (ISAMB_PP pp);
ISAMB_PP isamb_pp_open_x (ISAMB isamb, ISAMB_P pos, int *level);
-/* $Id: isamc.h,v 1.10 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isamc.h,v 1.11 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
int max_blocks_mem;
int debug;
-} *ISAMC_M;
+} ISAMC_M;
typedef struct ISAMC_I_s {
int (*read_item)(void *clientData, char **dst, int *insertMode);
void *clientData;
-} *ISAMC_I;
+} ISAMC_I;
-void isc_getmethod (ISAMC_M m);
+void isc_getmethod (ISAMC_M *m);
-ISAMC isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M method);
+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_P isc_merge (ISAMC is, ISAMC_P pos, ISAMC_I *data);
ISAMC_PP isc_pp_open (ISAMC is, ISAMC_P pos);
void isc_pp_close (ISAMC_PP pp);
/* $Id$
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
int max_blocks_mem;
int debug;
-} *ISAMD_M;
+} ISAMD_M;
typedef struct ISAMD_I_s { /* encapsulation of input data */
int (*read_item)(void *clientData, char **dst, int *insertMode);
void *clientData;
} *ISAMD_I;
-ISAMD_M isamd_getmethod (ISAMD_M me);
+ISAMD_M *isamd_getmethod (ISAMD_M *me);
-ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M method);
+ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M *method);
int isamd_close (ISAMD is);
/*ISAMD_P isamd_append (ISAMD is, ISAMD_P pos, ISAMD_I data);*/
int isamd_append (ISAMD is, char *dictentry, int dictlen, ISAMD_I data);
-/* $Id: isams.h,v 1.3 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isams.h,v 1.4 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
int debug;
int block_size;
-} *ISAMS_M;
+} ISAMS_M;
typedef struct ISAMS_I_s {
int (*read_item)(void *clientData, char **dst, int *insertMode);
void *clientData;
} *ISAMS_I;
-void isams_getmethod (ISAMS_M me);
+void isams_getmethod (ISAMS_M *me);
ISAMS isams_open (BFiles bfs, const char *name, int writeflag,
- ISAMS_M method);
+ 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);
.deps
Makefile
Makefile.in
+*.mf
+tstisamb
-## $Id: Makefile.am,v 1.2 2002-08-17 08:00:28 adam Exp $
+## $Id: Makefile.am,v 1.3 2003-06-23 15:36:11 adam Exp $
noinst_LIBRARIES = libisamb.a
+check_PROGRAMS = tstisamb
+
+TESTS = $(check_PROGRAMS)
+
+tstisamb_SOURCES = tstisamb.c
+tstisamb_LDADD = libisamb.a ../bfile/libbfile.a ../util/libutil.a $(YAZLIB)
+
libisamb_a_SOURCES = isamb.c
INCLUDES = -I$(srcdir)/../include @YAZINC@
-/* $Id: isamb.c,v 1.26 2003-04-15 16:38:32 adam Exp $
+/* $Id: isamb.c,v 1.27 2003-06-23 15:36:11 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
struct ISAMB_s {
BFiles bfs;
- ISAMC_M method;
+ ISAMC_M *method;
struct ISAMB_file *file;
int no_cat;
(*src) += sizeof(*pos);
}
-ISAMB isamb_open (BFiles bfs, const char *name, int writeflag, ISAMC_M method,
+ISAMB isamb_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method,
int cache)
{
ISAMB isamb = xmalloc (sizeof(*isamb));
int i, b_size = 32;
isamb->bfs = bfs;
- isamb->method = (ISAMC_M) xmalloc (sizeof(*method));
+ isamb->method = (ISAMC_M *) xmalloc (sizeof(*method));
memcpy (isamb->method, method, sizeof(*method));
isamb->no_cat = 4;
isamb->log_io = 0;
int insert_sub (ISAMB b, struct ISAMB_block **p,
void *new_item, int *mode,
- ISAMC_I stream,
+ ISAMC_I *stream,
struct ISAMB_block **sp,
void *sub_item, int *sub_size,
void *max_item);
int insert_int (ISAMB b, struct ISAMB_block *p, void *lookahead_item,
int *mode,
- ISAMC_I stream, struct ISAMB_block **sp,
+ ISAMC_I *stream, struct ISAMB_block **sp,
void *split_item, int *split_size, void *last_max_item)
{
char *startp = p->bytes;
int insert_leaf (ISAMB b, struct ISAMB_block **sp1, void *lookahead_item,
- int *lookahead_mode, ISAMC_I stream, struct ISAMB_block **sp2,
+ int *lookahead_mode, ISAMC_I *stream,
+ struct ISAMB_block **sp2,
void *sub_item, int *sub_size,
void *max_item)
{
int insert_sub (ISAMB b, struct ISAMB_block **p, void *new_item,
int *mode,
- ISAMC_I stream,
+ ISAMC_I *stream,
struct ISAMB_block **sp,
void *sub_item, int *sub_size,
void *max_item)
sub_size, max_item);
}
-int isamb_merge (ISAMB b, ISAMC_P pos, ISAMC_I stream)
+int isamb_unlink (ISAMB b, ISAMC_P pos)
+{
+ struct ISAMB_block *p1;
+
+ if (!pos)
+ return 0;
+ p1 = open_block(b, pos);
+ p1->deleted = 1;
+ if (!p1->leaf)
+ {
+ int sub_p;
+ int item_len;
+ char *src = p1->bytes + p1->offset;
+
+ decode_ptr(&src, &sub_p);
+ isamb_unlink(b, sub_p);
+
+ while (src != p1->bytes + p1->size)
+ {
+ decode_ptr(&src, &item_len);
+ src += item_len;
+ decode_ptr(&src, &sub_p);
+ isamb_unlink(b, sub_p);
+ }
+ }
+ close_block(b, p1);
+ return 0;
+}
+
+int isamb_merge (ISAMB b, ISAMC_P pos, ISAMC_I *stream)
{
char item_buf[DST_ITEM_MAX];
char *item_ptr;
--- /dev/null
+/* $Id: tstisamb.c,v 1.1 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include <string.h>
+#include <yaz/xmalloc.h>
+#include <yaz/log.h>
+#include <isamb.h>
+#include <assert.h>
+
+int compare_item(const void *a, const void *b)
+{
+ int ia, ib;
+
+ memcpy(&ia, a, sizeof(int));
+ memcpy(&ib, b, sizeof(int));
+ return ia - ib;
+}
+
+void *code_start(int mode)
+{
+ return 0;
+}
+
+void code_item(int mode, void *p, char **dst, char **src)
+{
+ memcpy (*dst, *src, sizeof(int));
+ (*dst) += sizeof(int);
+ (*src) += sizeof(int);
+}
+
+void code_reset(void *p)
+{
+}
+void code_stop(int mode, void *p)
+{
+}
+
+struct read_info {
+ int no;
+ int max;
+};
+
+int code_read(void *vp, char **dst, int *insertMode)
+{
+ struct read_info *ri = (struct read_info *)vp;
+ int x;
+
+ if (ri->no > ri->max)
+ exit(3);
+ if (ri->no == ri->max)
+ return 0;
+ x = ri->no;
+ memcpy (*dst, &x, sizeof(int));
+ (*dst)+=sizeof(int);
+
+ (ri->no)++;
+ *insertMode = 1;
+ return 1;
+}
+
+void tst_insert(ISAMB isb, int n)
+{
+ ISAMC_I isamc_i;
+ ISAMC_P isamc_p;
+ struct read_info ri;
+ ISAMB_PP pp;
+ char key_buf[10];
+
+ /* insert a number of entries */
+ ri.no = 0;
+ ri.max = n;
+
+ isamc_i.clientData = &ri;
+ isamc_i.read_item = code_read;
+
+ isamc_p = isamb_merge (isb, 0 /* new list */ , &isamc_i);
+
+ /* read the entries */
+ pp = isamb_pp_open (isb, isamc_p);
+
+ ri.no = 0;
+ while(isamb_pp_read (pp, key_buf))
+ {
+ int x;
+ memcpy (&x, key_buf, sizeof(int));
+ if (x != ri.no)
+ {
+ yaz_log(LOG_DEBUG, "isamb_pp_read. Got %d (expected %d)",
+ x, ri.no);
+ exit(3);
+ }
+ ri.no++;
+ }
+ if (ri.no != ri.max)
+ {
+ yaz_log(LOG_DEBUG, "ri.max != ri.max (%d != %d)", ri.no, ri.max);
+ exit(3);
+ }
+ isamb_pp_close(pp);
+
+ isamb_unlink(isb, isamc_p);
+}
+
+int main(int argc, char **argv)
+{
+ BFiles bfs;
+ ISAMB isb;
+ ISAMC_M method;
+
+ if (argc == 2)
+ yaz_log_init_level(LOG_ALL);
+
+ /* setup method (attributes) */
+ method.compare_item = compare_item;
+ method.code_start = code_start;
+ method.code_item = code_item;
+ method.code_reset = code_reset;
+ method.code_stop = code_stop;
+
+ /* create block system */
+ bfs = bfs_create(0, 0);
+ if (!bfs)
+ {
+ yaz_log(LOG_DEBUG, "bfs_create failed");
+ exit(1);
+ }
+
+ /* create isam handle */
+ isb = isamb_open (bfs, "isamb", 1, &method, 0);
+ if (!isb)
+ {
+ yaz_log(LOG_DEBUG, "isamb_open failed");
+ exit(2);
+ }
+ tst_insert(isb, 1);
+ tst_insert(isb, 2);
+ tst_insert(isb, 20);
+ tst_insert(isb, 100);
+ tst_insert(isb, 500);
+ tst_insert(isb, 10000);
+
+ /* close isam handle */
+ isamb_close(isb);
+
+ /* exit block system */
+ bfs_destroy(bfs);
+ exit(0);
+ return 0;
+}
-/* $Id: isamc-p.h,v 1.8 2002-08-02 19:26:56 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isamc-p.h,v 1.9 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
int no_files;
int max_cat;
char *merge_buf;
- ISAMC_M method;
+ ISAMC_M *method;
ISAMC_file files;
};
-/* $Id: isamc.c,v 1.22 2002-08-02 19:26:56 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isamc.c,v 1.23 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
#define SMALL_TEST 0
-void isc_getmethod (ISAMC_M m)
+void isc_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 isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method)
{
ISAMC is;
ISAMC_filecat filecat;
is = (ISAMC) xmalloc (sizeof(*is));
- is->method = (ISAMC_M) xmalloc (sizeof(*is->method));
+ is->method = (ISAMC_M *) xmalloc (sizeof(*is->method));
memcpy (is->method, method, sizeof(*method));
filecat = is->method->filecat;
assert (filecat);
-/* $Id: isamd-p.h,v 1.12 2002-11-26 22:18:34 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isamd-p.h,v 1.13 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
struct ISAMD_s {
int no_files;
int max_cat;
- ISAMD_M method;
+ ISAMD_M *method;
ISAMD_file files;
int last_pos; /* last read/write position for seek stats */
int last_cat; /* same for category */
/*
* $Log: isamd-p.h,v $
- * Revision 1.12 2002-11-26 22:18:34 adam
+ * Revision 1.13 2003-06-23 15:36:11 adam
+ * Implemented isamb_unlink.
+ *
+ * Revision 1.12 2002/11/26 22:18:34 adam
* Remove // comments
*
* Revision 1.11 2002/08/02 19:26:56 adam
-/* $Id: isamd.c,v 1.25 2003-03-05 16:41:10 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isamd.c,v 1.26 2003-06-23 15:36:11 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
-
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#define SMALL_TEST 0
-ISAMD_M isamd_getmethod (ISAMD_M me)
+ISAMD_M *isamd_getmethod (ISAMD_M *me)
{
static struct ISAMD_filecat_s def_cat[] = {
#if SMALL_TEST
#endif
};
- ISAMD_M m = (ISAMD_M) xmalloc (sizeof(*m)); /* never released! */
+ ISAMD_M *m = (ISAMD_M *) xmalloc (sizeof(*m)); /* never released! */
m->filecat = def_cat; /* ok, only alloc'd once */
m->code_start = NULL;
-ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M method)
+ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M *method)
{
ISAMD is;
ISAMD_filecat filecat;
is = (ISAMD) xmalloc (sizeof(*is));
- is->method = (ISAMD_M) xmalloc (sizeof(*is->method));
+ is->method = (ISAMD_M *) xmalloc (sizeof(*is->method));
memcpy (is->method, method, sizeof(*method));
filecat = is->method->filecat;
assert (filecat);
#endif
-/*
- * $Log: isamd.c,v $
- * Revision 1.25 2003-03-05 16:41:10 adam
- * Fix GCC warnings
- *
- * Revision 1.24 2002/11/26 22:18:34 adam
- * Remove // comments
- *
- * Revision 1.23 2002/08/02 19:26:56 adam
- * Towards GPL
- *
- * Revision 1.22 2002/07/12 18:12:21 heikki
- * Isam-D now stores small entries directly in the dictionary.
- * Needs more tuning and cleaning...
- *
- * Revision 1.21 2002/07/11 16:16:00 heikki
- * Fixed a bug in isamd, failed to store a single key when its bits
- * did not fit into a singleton.
- *
- * Revision 1.20 2002/06/19 10:29:18 adam
- * align block sizes for isam sys. Better plot for test
- *
- * Revision 1.19 1999/11/30 13:48:04 adam
- * Improved installation. Updated for inclusion of YAZ header files.
- *
- * Revision 1.18 1999/10/06 15:18:13 heikki
- *
- * Improving block sizes again
- *
- * Revision 1.17 1999/10/06 11:46:36 heikki
- * mproved statistics on isam-d
- *
- * Revision 1.16 1999/10/05 09:57:40 heikki
- * Tuning the isam-d (and fixed a small "detail")
- *
- * Revision 1.15 1999/09/27 14:36:36 heikki
- * singletons
- *
- * Revision 1.14 1999/09/23 18:01:18 heikki
- * singleton optimising
- *
- * Revision 1.13 1999/09/20 15:48:06 heikki
- * Small changes
- *
- * Revision 1.12 1999/09/13 13:28:28 heikki
- * isam-d optimizing: merging input data in the same go
- *
- * Revision 1.11 1999/08/25 18:09:24 heikki
- * Starting to optimize
- *
- * Revision 1.10 1999/08/24 13:17:42 heikki
- * Block sizes, comments
- *
- * Revision 1.9 1999/08/20 12:25:58 heikki
- * Statistics in isamd
- *
- * Revision 1.8 1999/08/18 13:28:16 heikki
- * Set log levels to decent values
- *
- * Revision 1.6 1999/08/17 19:44:25 heikki
- * Fixed memory leaks
- *
- * Revision 1.4 1999/08/04 14:21:18 heikki
- * isam-d seems to be working.
- *
- * Revision 1.3 1999/07/21 14:24:50 heikki
- * isamd write and read functions ok, except when diff block full.
- * (merge not yet done)
- *
- * Revision 1.1 1999/07/14 12:34:43 heikki
- * Copied from isamh, starting to change things...
- *
- *
- */
-/* $Id: merge.c,v 1.22 2003-03-05 16:41:10 adam Exp $
+/* $Id: merge.c,v 1.23 2003-06-23 15:36:11 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
return mb[ptr].offset + fill - off;
}
-ISAMC_P isc_merge (ISAMC is, ISAMC_P ipos, ISAMC_I data)
+ISAMC_P isc_merge (ISAMC is, ISAMC_P ipos, ISAMC_I *data)
{
char i_item[128], *i_item_ptr;
/*
* $Log: merge.c,v $
- * Revision 1.22 2003-03-05 16:41:10 adam
+ * Revision 1.23 2003-06-23 15:36:11 adam
+ * Implemented isamb_unlink.
+ *
+ * Revision 1.22 2003/03/05 16:41:10 adam
* Fix GCC warnings
*
* Revision 1.21 2002/08/02 19:26:56 adam
-/* $Id: isams.c,v 1.3 2002-08-02 19:26:56 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: isams.c,v 1.4 2003-06-23 15:36:12 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
typedef unsigned ISAMS_BLOCK_SIZE;
struct ISAMS_s {
- ISAMS_M method;
+ ISAMS_M *method;
ISAMS_head head;
ISAMS_head head_old;
char *merge_buf;
int numRead;
};
-void isams_getmethod (ISAMS_M m)
+void isams_getmethod (ISAMS_M *m)
{
m->code_start = NULL;
m->code_item = NULL;
}
ISAMS isams_open (BFiles bfs, const char *name, int writeflag,
- ISAMS_M method)
+ ISAMS_M *method)
{
ISAMS is = (ISAMS) xmalloc (sizeof(*is));
- is->method = (ISAMS_M) xmalloc (sizeof(*is->method));
+ is->method = (ISAMS_M *) xmalloc (sizeof(*is->method));
memcpy (is->method, method, sizeof(*method));
is->block_size = is->method->block_size;
is->debug = is->method->debug;
}
return p;
}
+
+#if 0
static void inline_destroy_subfield(inline_subfield *p)
{
if (p)
xfree(p);
}
}
+#endif
+
static void inline_destroy_subfield_recursive(inline_subfield *p)
{
if (p)
-/* $Id: t4.c,v 1.2 2003-06-20 14:21:24 heikki Exp $
+/* $Id: t4.c,v 1.3 2003-06-23 15:36:12 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
zh = zebra_open (zs);
zebra_select_database(zh, "Default");
- for (i = 0; i<4; i++)
+ for (i = 0; i<2; i++)
{
ZebraRetrievalRecord retrievalRecord[1001];
char setname[20];
sprintf(setname, "s%d", i+1);
zebra_search_RPN (zh, odr_input, query, setname, &hits);
- printf ("hits=%d\n", hits);
-
yaz_pqf_destroy(parser);
odr_destroy (odr_input);