slow start on isam-d
[idzebra-moved-to-github.git] / isamc / merge-d.c
1 /*
2  * Copyright (c) 1996-1998, Index Data.
3  * See the file LICENSE for details.
4  * Heikki Levanto
5  *
6  * merge-d.c: merge routines for isamd
7  *
8  */
9
10 #include <stdlib.h>
11 #include <assert.h>
12 #include <string.h>
13 #include <stdio.h>
14 #include <log.h>
15 #include "isamd-p.h"
16
17
18 static char *hexdump(unsigned char *p, int len, char *buff) {
19   static char localbuff[128];
20   char bytebuff[8];
21   if (!buff) buff=localbuff;
22   *buff='\0';
23   while (len--) {
24     sprintf(bytebuff,"%02x",*p);
25     p++;
26     strcat(buff,bytebuff);
27     if (len) strcat(buff,",");
28   }
29   return buff;
30 }
31
32
33 /* isamd - heikki's append-only isam 
34  *
35  * The record pointers arre kept in a linked list of buffers, as usual.
36  * When modifying the list, we just store diffs at the end of it (either
37  * in the only block, or in a separate block). Occasionally we have too
38  * many blocks, and then we merge the diffs into the list.
39  */
40
41
42
43 ISAMD_P isamd_append (ISAMD is, ISAMD_P ipos, ISAMD_I data)
44 {
45   char i_item[128];    /* one input item */
46   char *i_ptr=i_item;
47   int i_more =1;
48   int i_mode;     /* 0 for delete, 1 for insert */ 
49
50   int retval=0;
51   
52   while (i_more)
53   {
54      i_ptr = i_item;
55      i_more = (*data->read_item)(data->clientData, &i_ptr, &i_mode); 
56      if (!retval)
57        memcpy(&retval,i_item, sizeof(retval));
58   }
59   return retval;
60 } /*  isamh_append */
61
62
63 /*
64  * $Log: merge-d.c,v $
65  * Revision 1.2  1999-07-14 15:05:30  heikki
66  * slow start on isam-d
67  *
68  * Revision 1.1  1999/07/14 13:14:47  heikki
69  * Created empty
70  *
71  *
72  */
73
74