Implemented isamb_unlink.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 23 Jun 2003 15:36:11 +0000 (15:36 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 23 Jun 2003 15:36:11 +0000 (15:36 +0000)
17 files changed:
include/data1.h
include/isamb.h
include/isamc.h
include/isamd.h
include/isams.h
isamb/.cvsignore
isamb/Makefile.am
isamb/isamb.c
isamb/tstisamb.c [new file with mode: 0644]
isamc/isamc-p.h
isamc/isamc.c
isamc/isamd-p.h
isamc/isamd.c
isamc/merge.c
isams/isams.c
recctrl/inline.c
test/api/t4.c

index 7dabbd9..bcc9c7e 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
    Index Data Aps
 
@@ -514,6 +514,8 @@ YAZ_EXPORT const char *data1_systag_lookup(data1_absyn *absyn, const char *tag,
 
 YAZ_EXPORT void data1_concat_text(data1_handle dh, NMEM m, data1_node *n);
 
 
 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
 YAZ_END_CDECL
 
 #endif
index 359fd16..b265ae5 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -20,8 +20,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 */
 
 02111-1307, USA.
 */
 
-
-
 #ifndef ISAMB_H
 #define ISAMB_H
 
 #ifndef ISAMB_H
 #define ISAMB_H
 
@@ -32,11 +30,11 @@ typedef struct ISAMB_s *ISAMB;
 typedef struct ISAMB_PP_s *ISAMB_PP;
 typedef ISAMC_P ISAMB_P;
 
 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);
 
                   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);
 
 
 ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos);
 
@@ -44,6 +42,8 @@ int isamb_pp_read (ISAMB_PP pp, void *buf);
 
 void isamb_pp_close (ISAMB_PP pp);
 
 
 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);
 int isamb_pp_num (ISAMB_PP pp);
 
 ISAMB_PP isamb_pp_open_x (ISAMB isamb, ISAMB_P pos, int *level);
index f7c248c..a3ecb56 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -56,18 +56,18 @@ typedef struct ISAMC_M_s {
 
     int max_blocks_mem;
     int debug;
 
     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;
 
 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);
 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);
 
 ISAMC_PP isc_pp_open (ISAMC is, ISAMC_P pos);
 void isc_pp_close (ISAMC_PP pp);
index f699448..380916f 100644 (file)
@@ -1,5 +1,5 @@
 /* $Id$
 /* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -52,16 +52,16 @@ typedef struct ISAMD_M_s {
 
     int max_blocks_mem;
     int debug;
 
     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;
 
 
 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);
 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);
index 242b165..925175b 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -45,17 +45,17 @@ typedef struct ISAMS_M_s {
 
     int debug;
     int block_size;
 
     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;
 
 
 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 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);
 int isams_close (ISAMS is);
 ISAMS_P isams_merge (ISAMS is, ISAMS_I data);
 ISAMS_PP isams_pp_open (ISAMS is, ISAMS_P pos);
index e995588..883466a 100644 (file)
@@ -1,3 +1,5 @@
 .deps
 Makefile
 Makefile.in
 .deps
 Makefile
 Makefile.in
+*.mf
+tstisamb
index f2f07c5..2cd07b4 100644 (file)
@@ -1,7 +1,14 @@
-## $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
 
 
 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@
 libisamb_a_SOURCES = isamb.c
 
 INCLUDES = -I$(srcdir)/../include @YAZINC@
index 8903e69..e2042d1 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
    Index Data Aps
 
@@ -61,7 +61,7 @@ struct ISAMB_file {
 
 struct ISAMB_s {
     BFiles bfs;
 
 struct ISAMB_s {
     BFiles bfs;
-    ISAMC_M method;
+    ISAMC_M *method;
 
     struct ISAMB_file *file;
     int no_cat;
 
     struct ISAMB_file *file;
     int no_cat;
@@ -105,14 +105,14 @@ void decode_ptr (char **src, int *pos)
     (*src) += sizeof(*pos);
 }
 
     (*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;
                   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;
     memcpy (isamb->method, method, sizeof(*method));
     isamb->no_cat = 4;
     isamb->log_io = 0;
@@ -415,14 +415,14 @@ void close_block (ISAMB b, struct ISAMB_block *p)
 
 int insert_sub (ISAMB b, struct ISAMB_block **p,
                 void *new_item, int *mode,
 
 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,
                 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;
                 void *split_item, int *split_size, void *last_max_item)
 {
     char *startp = p->bytes;
@@ -531,7 +531,8 @@ int insert_int (ISAMB b, struct ISAMB_block *p, void *lookahead_item,
 
 
 int insert_leaf (ISAMB b, struct ISAMB_block **sp1, void *lookahead_item,
 
 
 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)
 {
                  void *sub_item, int *sub_size,
                  void *max_item)
 {
@@ -756,7 +757,7 @@ int insert_leaf (ISAMB b, struct ISAMB_block **sp1, void *lookahead_item,
 
 int insert_sub (ISAMB b, struct ISAMB_block **p, void *new_item,
                 int *mode,
 
 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)
                 struct ISAMB_block **sp,
                 void *sub_item, int *sub_size,
                 void *max_item)
@@ -769,7 +770,36 @@ int insert_sub (ISAMB b, struct ISAMB_block **p, void *new_item,
                            sub_size, 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;
 {
     char item_buf[DST_ITEM_MAX];
     char *item_ptr;
diff --git a/isamb/tstisamb.c b/isamb/tstisamb.c
new file mode 100644 (file)
index 0000000..a2c9140
--- /dev/null
@@ -0,0 +1,168 @@
+/* $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;
+}
index 995bd91..d2af549 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -67,7 +67,7 @@ struct ISAMC_s {
     int no_files;
     int max_cat;
     char *merge_buf;
     int no_files;
     int max_cat;
     char *merge_buf;
-    ISAMC_M method;
+    ISAMC_M *method;
     ISAMC_file files;
 }; 
 
     ISAMC_file files;
 }; 
 
index bc81c16..6f91fa9 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -42,7 +42,7 @@ static void init_fc (ISAMC is, int cat);
 
 #define SMALL_TEST 0
 
 
 #define SMALL_TEST 0
 
-void isc_getmethod (ISAMC_M m)
+void isc_getmethod (ISAMC_M *m)
 {
 
     static struct ISAMC_filecat_s def_cat[] = {
 {
 
     static struct ISAMC_filecat_s def_cat[] = {
@@ -72,7 +72,7 @@ void isc_getmethod (ISAMC_M m)
     m->max_blocks_mem = 10;
 }
 
     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;
 {
     ISAMC is;
     ISAMC_filecat filecat;
@@ -81,7 +81,7 @@ ISAMC isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M method)
 
     is = (ISAMC) xmalloc (sizeof(*is));
 
 
     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);
     memcpy (is->method, method, sizeof(*method));
     filecat = is->method->filecat;
     assert (filecat);
index 6eb4320..fa0b748 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -69,7 +69,7 @@ typedef struct ISAMD_file_s {
 struct ISAMD_s {
     int no_files;
     int max_cat;
 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 */
     ISAMD_file files;
     int last_pos;   /* last read/write position for seek stats */
     int last_cat;   /* same for category */
@@ -141,7 +141,10 @@ int singleton_encode(struct it_key *k);
 
 /*
  * $Log: isamd-p.h,v $
 
 /*
  * $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
  * Remove // comments
  *
  * Revision 1.11  2002/08/02 19:26:56  adam
index 21d90a9..37d40a3 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -20,9 +20,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 */
 
 02111-1307, USA.
 */
 
-
-
-
 #include <stdlib.h>
 #include <assert.h>
 #include <string.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <string.h>
@@ -40,7 +37,7 @@ static void init_fc (ISAMD is, int cat);
 
 #define SMALL_TEST 0
 
 
 #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
 {
     static struct ISAMD_filecat_s def_cat[] = {
 #if SMALL_TEST
@@ -81,7 +78,7 @@ ISAMD_M isamd_getmethod (ISAMD_M me)
 #endif 
 
     };
 #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;
     m->filecat = def_cat;                        /* ok, only alloc'd once */
 
     m->code_start = NULL;
@@ -100,7 +97,7 @@ 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)
 {
     ISAMD is;
     ISAMD_filecat filecat;
 {
     ISAMD is;
     ISAMD_filecat filecat;
@@ -108,7 +105,7 @@ ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M method)
 
     is = (ISAMD) xmalloc (sizeof(*is));
 
 
     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);
     memcpy (is->method, method, sizeof(*method));
     filecat = is->method->filecat;
     assert (filecat);
@@ -877,77 +874,3 @@ void isamd_pp_dump (ISAMD is, ISAMD_P ipos)
 
 #endif
 
 
 #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...
- *
- *
- */
index 15fa89a..7bfdf05 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
    Index Data Aps
 
@@ -154,7 +154,7 @@ static int get_border (ISAMC is, struct isc_merge_block *mb, int ptr,
     return mb[ptr].offset + fill - off;
 }
 
     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;
 {
 
     char i_item[128], *i_item_ptr;
@@ -482,7 +482,10 @@ ISAMC_P isc_merge (ISAMC is, ISAMC_P ipos, ISAMC_I data)
 
 /*
  * $Log: merge.c,v $
 
 /*
  * $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
  * Fix GCC warnings
  *
  * Revision 1.21  2002/08/02 19:26:56  adam
index f3583cc..a8c765c 100644 (file)
@@ -1,5 +1,5 @@
-/* $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.
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -37,7 +37,7 @@ typedef struct {
 typedef unsigned ISAMS_BLOCK_SIZE;
 
 struct ISAMS_s {
 typedef unsigned ISAMS_BLOCK_SIZE;
 
 struct ISAMS_s {
-    ISAMS_M method;
+    ISAMS_M *method;
     ISAMS_head head;
     ISAMS_head head_old;
     char *merge_buf;
     ISAMS_head head;
     ISAMS_head head_old;
     char *merge_buf;
@@ -57,7 +57,7 @@ struct ISAMS_PP_s {
     int numRead;
 };
 
     int numRead;
 };
 
-void isams_getmethod (ISAMS_M m)
+void isams_getmethod (ISAMS_M *m)
 {
     m->code_start = NULL;
     m->code_item = NULL;
 {
     m->code_start = NULL;
     m->code_item = NULL;
@@ -70,11 +70,11 @@ void isams_getmethod (ISAMS_M m)
 }
 
 ISAMS isams_open (BFiles bfs, const char *name, int writeflag,
 }
 
 ISAMS isams_open (BFiles bfs, const char *name, int writeflag,
-                 ISAMS_M method)
+                 ISAMS_M *method)
 {
     ISAMS is = (ISAMS) xmalloc (sizeof(*is));
 
 {
     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;
     memcpy (is->method, method, sizeof(*method));
     is->block_size = is->method->block_size;
     is->debug = is->method->debug;
index 08d5ee6..4b09b69 100644 (file)
@@ -47,6 +47,8 @@ static inline_subfield *inline_mk_subfield(inline_subfield *parent)
     }
     return p;
 }
     }
     return p;
 }
+
+#if 0
 static void inline_destroy_subfield(inline_subfield *p)
 {
     if (p)
 static void inline_destroy_subfield(inline_subfield *p)
 {
     if (p)
@@ -57,6 +59,8 @@ static void inline_destroy_subfield(inline_subfield *p)
        xfree(p);
     }
 }
        xfree(p);
     }
 }
+#endif
+
 static void inline_destroy_subfield_recursive(inline_subfield *p)
 {
     if (p)
 static void inline_destroy_subfield_recursive(inline_subfield *p)
 {
     if (p)
index d9e03dd..59331b8 100644 (file)
@@ -1,4 +1,4 @@
-/* $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
 
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
    Index Data Aps
 
@@ -53,7 +53,7 @@ int main(int argc, char **argv)
     zh = zebra_open (zs);
     zebra_select_database(zh, "Default");
 
     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];
     {
         ZebraRetrievalRecord retrievalRecord[1001];
         char setname[20];
@@ -68,8 +68,6 @@ int main(int argc, char **argv)
         sprintf(setname, "s%d", i+1);
         zebra_search_RPN (zh, odr_input, query, setname, &hits);
 
         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);
         yaz_pqf_destroy(parser);
 
         odr_destroy (odr_input);