+Remove isamd. It's not been in use for a long time and isamb is better
+in most cases.
+
+Change SYSNO to be zint. Change pointers in isamc and isamb to zint.
+Change block number in bfile/cfile to zint. zint is a long integer
+(64-bit). This change practially removes register limits for Zebra.
+
+Implement int-list encoding for ISAMs.
+
Added a new 'cut' directive to charmaps (.chr files) which specifies that
only characters after the cutting char should be indexed.
-/* $Id: bfile.c,v 1.35 2002-08-02 19:26:55 adam Exp $
+/* $Id: bfile.c,v 1.36 2004-08-04 08:35:22 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <zebrautl.h>
#include <bfile.h>
+
#include "cfile.h"
struct BFiles_struct {
return(tmp);
}
-int bf_read (BFile bf, int no, int offset, int nbytes, void *buf)
+int bf_read (BFile bf, zint no, int offset, int nbytes, void *buf)
{
int r;
return r;
}
-int bf_write (BFile bf, int no, int offset, int nbytes, const void *buf)
+int bf_write (BFile bf, zint no, int offset, int nbytes, const void *buf)
{
int r;
zebra_lock_rdwr_wlock (&bf->rdwr_lock);
-/* $Id: cfile.c,v 1.27 2002-08-02 19:26:55 adam Exp $
+/* $Id: cfile.c,v 1.28 2004-08-04 08:35:22 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
int i, j;
logf (LOG_DEBUG, "cf: Moving to flat shadow: %s", cf->rmf->name);
- logf (LOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=%d total=%d",
+ logf (LOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT " total="
+ ZINT_FORMAT,
cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);
assert (cf->head.state == 1);
}
-int cf_read (CFile cf, int no, int offset, int nbytes, void *buf)
+int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf)
{
int block;
zebra_mutex_unlock (&cf->mutex);
if (!mf_read (cf->block_mf, block, offset, nbytes, buf))
{
- logf (LOG_FATAL|LOG_ERRNO, "cf_read no=%d, block=%d", no, block);
+ logf (LOG_FATAL|LOG_ERRNO, "cf_read no=" ZINT_FORMAT ", block=%d", no, block);
exit (1);
}
return 1;
}
-int cf_write (CFile cf, int no, int offset, int nbytes, const void *buf)
+int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf)
{
int block;
zebra_mutex_unlock (&cf->mutex);
if (mf_write (cf->block_mf, block, offset, nbytes, buf))
{
- logf (LOG_FATAL|LOG_ERRNO, "cf_write no=%d, block=%d", no, block);
+ logf (LOG_FATAL|LOG_ERRNO, "cf_write no=" ZINT_FORMAT ", block=%d", no, block);
exit (1);
}
return 0;
int cf_close (CFile cf)
{
- logf (LOG_DEBUG, "cf: close hits=%d miss=%d bucket_in_memory=%d total=%d",
+ logf (LOG_DEBUG, "cf: close hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT
+ " total=" ZINT_FORMAT,
cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);
flush_bucket (cf, -1);
-/* $Id: cfile.h,v 1.14 2002-08-02 19:26:55 adam Exp $
+/* $Id: cfile.h,v 1.15 2004-08-04 08:35:22 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
{
struct CFile_head {
int state; /* 1 = hash, 2 = flat */
- int next_block; /* next free block / last block */
+ zint next_block; /* next free block / last block */
int block_size; /* mfile/bfile block size */
int hash_size; /* no of chains in hash table */
- int first_bucket; /* first hash bucket */
- int next_bucket; /* last hash bucket + 1 = first flat bucket */
- int flat_bucket; /* last flat bucket + 1 */
+ zint first_bucket; /* first hash bucket */
+ zint next_bucket; /* last hash bucket + 1 = first flat bucket */
+ zint flat_bucket; /* last flat bucket + 1 */
} head;
MFile block_mf;
MFile hash_mf;
struct CFile_hash_bucket **parray;
struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
int dirty;
- int bucket_in_memory;
- int max_bucket_in_memory;
+ zint bucket_in_memory;
+ zint max_bucket_in_memory;
char *iobuf;
MFile rmf;
int no_hits;
int cf_close (CFile cf);
CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
int wflag, int *firstp);
-int cf_read (CFile cf, int no, int offset, int nbytes, void *buf);
-int cf_write (CFile cf, int no, int offset, int nbytes, const void *buf);
+int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf);
+int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf);
void cf_unlink (CFile cf);
void cf_commit (CFile cf);
-/* $Id: commit.c,v 1.16 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: commit.c,v 1.17 2004-08-04 08:35:22 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
static void cf_commit_flat (CFile cf)
{
- int *fp;
+ zint *fp;
int hno;
- int i, vno = 0;
+ int i;
+ zint vno = 0;
#if CF_OPTIMIZE_COMMIT
struct map_cache *m_p;
#if CF_OPTIMIZE_COMMIT
m_p = map_cache_init (cf);
#endif
- fp = (int *) xmalloc (HASH_BSIZE);
+ fp = (zint *) xmalloc (HASH_BSIZE);
for (hno = cf->head.next_bucket; hno < cf->head.flat_bucket; hno++)
{
for (i = 0; i < (int) (HASH_BSIZE/sizeof(int)); i++)
if (!mf_read (cf->hash_mf, hno, 0, 0, fp) &&
hno != cf->head.flat_bucket-1)
{
- logf (LOG_FATAL, "read index block hno=%d (%d-%d) commit",
+ logf (LOG_FATAL, "read index block hno=%d (" ZINT_FORMAT "-" ZINT_FORMAT ") commit",
hno, cf->head.next_bucket, cf->head.flat_bucket-1);
}
for (i = 0; i < (int) (HASH_BSIZE/sizeof(int)); i++)
#else
if (!mf_read (cf->block_mf, fp[i], 0, 0, cf->iobuf))
{
- logf (LOG_FATAL, "read data block hno=%d (%d-%d) "
- "i=%d commit block at %d (->%d)",
+ logf (LOG_FATAL, "read data block hno=%d (" ZINT_FORMAT "-" ZINT_FORMAT ") "
+ "i=%d commit block at " ZINT_FORMAT " (->" ZINT_FORMAT")",
hno, cf->head.next_bucket, cf->head.flat_bucket-1,
i, fp[i], vno);
exit (1);
-/* $Id: mfile.c,v 1.52 2003-04-05 12:32:34 adam Exp $
+/* $Id: mfile.c,v 1.53 2004-08-04 08:35:22 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
/*
* Read one block from a metafile. Interface mirrors bfile.
*/
-int mf_read(MFile mf, int no, int offset, int nbytes, void *buf)
+int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf)
{
int rd, toread;
/*
* Write.
*/
-int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf)
+int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf)
{
int ps, nblocks, towrite;
mf_dir *dp;
mf->files[mf->cur_file].blocks = 0;
mf->files[mf->cur_file].bytes = 0;
mf->files[mf->cur_file].fd = -1;
- sprintf(tmp, "%s/%s-%d.mf", dp->name, mf->name,
+ sprintf(tmp, "%s/%s-" ZINT_FORMAT ".mf", dp->name, mf->name,
mf->files[mf->cur_file].number);
mf->files[mf->cur_file].path = xstrdup(tmp);
mf->no_files++;
dnl Zebra, Index Data Aps, 1995-2004
-dnl $Id: configure.in,v 1.91 2004-06-11 10:36:08 adam Exp $
+dnl $Id: configure.in,v 1.92 2004-08-04 08:35:22 adam Exp $
dnl
AC_INIT(include/zebraver.h)
-AM_INIT_AUTOMAKE(idzebra,1.3.16)
+AM_INIT_AUTOMAKE(idzebra,1.4.0)
dnl ------ Substitutions
AC_SUBST(TCL_INCLUDE)
AC_SUBST(TCL_LIB)
-/* $Id: d1_absyn.c,v 1.9 2003-06-12 18:20:24 adam Exp $
+/* $Id: d1_absyn.c,v 1.10 2004-08-04 08:35:22 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
while (p)
{
- if (!strcmp (name, p->name))
+ if (!yaz_matchstr (name, p->name))
return p->absyn;
p = p->next;
}
while (p)
{
- if (!strcmp (name, p->name))
+ if (!yaz_matchstr (name, p->name))
return p->attset;
p = p->next;
}
-/* $Id: d1_read.c,v 1.8 2004-07-26 13:51:42 adam Exp $
+/* $Id: d1_read.c,v 1.9 2004-08-04 08:35:22 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
return data1_add_insert_taggeddata (dh, at, tagname, m, 1, 0);
}
-data1_node *data1_mk_tag_data_int (data1_handle dh, data1_node *at,
- const char *tag, int num,
+data1_node *data1_mk_tag_data_zint (data1_handle dh, data1_node *at,
+ const char *tag, zint num,
NMEM nmem)
{
data1_node *node_data;
return 0;
node_data->u.data.what = DATA1I_num;
node_data->u.data.data = node_data->lbuf;
- sprintf (node_data->u.data.data, "%d", num);
+ sprintf (node_data->u.data.data, ZINT_FORMAT, num);
node_data->u.data.len = strlen (node_data->u.data.data);
return node_data;
}
+data1_node *data1_mk_tag_data_int (data1_handle dh, data1_node *at,
+ const char *tag, int num,
+ NMEM nmem)
+{
+ return data1_mk_tag_data_zint(dh, at, tag, num, nmem);
+}
+
data1_node *data1_mk_tag_data_oid (data1_handle dh, data1_node *at,
const char *tag, Odr_oid *oid,
NMEM nmem)
# Simple Zebra configuration file
-# $Id: zebra.cfg,v 1.2 2003-03-04 23:30:20 adam Exp $
+# $Id: zebra.cfg,v 1.3 2004-08-04 08:35:23 adam Exp $
#
# Where the schema files, attribute files, etc are located.
profilePath: ../../tab
attset: explain.att
recordtype: grs.sgml
-isam: b
+isam: c
+
+#recordId: (bib-1,identifier-standard)
clean:
rm -f records/dino.xml *.mf *.LCK zebrasrv.pid
-dist-hook:
+dist-hook: records/dino.xml
-mkdir $(distdir)/records
+ cp records/dino.xml $(distdir)/records
noinst_HEADERS = bfile.h bset.h charmap.h d1_attset.h d1_map.h \
-data1.h dfa.h dict.h direntz.h isamb.h isamc.h isamd.h isamg.h isam.h \
-isams.h mfile.h passwddb.h recctrl.h res.h rsbetween.h rsbool.h rset.h \
-rsisamb.h rsisamc.h rsisamd.h rsisam.h rsisams.h rsm_or.h rsnull.h \
-rsprox.h rstemp.h set.h sortidx.h str.h zebra-lock.h zebramap.h zebrautl.h \
+data1.h dfa.h dict.h direntz.h isam-codec.h isamb.h isamc.h isamg.h \
+isam.h isams.h mfile.h passwddb.h recctrl.h \
+res.h rsbetween.h rsbool.h rset.h rsisamb.h rsisamc.h rsisam.h \
+rsisams.h rsm_or.h rsnull.h rsprox.h rstemp.h set.h \
+sortidx.h str.h zebra-lock.h zebramap.h zebrautl.h \
zebra_xpath.h
include_HEADERS = zebraapi.h zebraver.h
-/* $Id: bfile.h,v 1.21 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: bfile.h,v 1.22 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#ifndef BFILE_H
#define BFILE_H
#include <mfile.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+YAZ_BEGIN_CDECL
#define bf_blocksize(bf) mf_blocksize(bf->mf)
block 'no'. stores contents in buffer 'buf'.
returns 1 if whole block could be read; 0 otherwise.
*/
-int bf_read (BFile bf, int no, int offset, int nbytes, void *buf);
+int bf_read (BFile bf, zint no, int offset, int nbytes, void *buf);
/* bf_write: writes bytes to bfile 'bf'.
writes 'nbytes' bytes (or whole block if 0) at offset 'offset' to
block 'no'. retrieves contents from buffer 'buf'.
returns 0 if successful; non-zero otherwise.
*/
-int bf_write (BFile bf, int no, int offset, int nbytes, const void *buf);
+int bf_write (BFile bf, zint no, int offset, int nbytes, const void *buf);
/* bf_cache: enables bfile cache if spec is not NULL */
void bf_cache (BFiles bfs, const char *spec);
/* bf_reset: delete register and shadow completely */
void bf_reset (BFiles bfs);
-#ifdef __cplusplus
-}
-#endif
+YAZ_END_CDECL
#endif
-/* $Id: data1.h,v 1.9 2004-07-26 12:20:06 adam Exp $
+/* $Id: data1.h,v 1.10 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include <yaz/oid.h>
#include <yaz/proto.h>
+#include <zebraver.h>
#include <d1_attset.h>
#include <d1_map.h>
#include <yaz/yaz-util.h>
YAZ_EXPORT void data1_set_root(data1_handle dh, data1_node *res,
NMEM nmem, const char *name);
+YAZ_EXPORT data1_node *data1_mk_tag_data_zint (data1_handle dh, data1_node *at,
+ const char *tag, zint num,
+ NMEM nmem);
YAZ_EXPORT data1_node *data1_mk_tag_data_int (data1_handle dh, data1_node *at,
const char *tag, int num,
NMEM nmem);
--- /dev/null
+/* $Id: isam-codec.h,v 1.1 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 2004
+ 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.
+*/
+
+#ifndef ISAM_CODEC_H
+#define ISAM_CODEC_H
+
+typedef struct {
+ void *(*start)(void);
+ void (*stop)(void *p);
+ void (*decode)(void *p, char **dst, const char **src);
+ void (*encode)(void *p, char **dst, const char **src);
+ void (*reset)(void *p);
+} ISAM_CODEC;
+
+#endif
-/* $Id: isamb.h,v 1.10 2004-08-03 14:54:41 heikki Exp $
+/* $Id: isamb.h,v 1.11 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include <bfile.h>
#include <isamc.h>
+YAZ_BEGIN_CDECL
+
typedef struct ISAMB_s *ISAMB;
typedef struct ISAMB_PP_s *ISAMB_PP;
typedef ISAMC_P ISAMB_P;
void isamb_dump (ISAMB b, ISAMB_P pos, void (*pr)(const char *str));
+YAZ_END_CDECL
+
#endif
-/* $Id: isamc.h,v 1.12 2004-06-01 12:56:38 adam Exp $
+/* $Id: isamc.h,v 1.13 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
02111-1307, USA.
*/
-
-
#ifndef ISAMC_H
#define ISAMC_H
+#include <isam-codec.h>
#include <bfile.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+YAZ_BEGIN_CDECL
typedef struct ISAMC_s *ISAMC;
-typedef int ISAMC_P;
+typedef zint ISAMC_P;
typedef struct ISAMC_PP_s *ISAMC_PP;
typedef struct ISAMC_filecat_s {
int (*compare_item)(const void *a, const void *b);
void (*log_item)(int logmask, const void *p, const char *txt);
-#define ISAMC_DECODE 0
-#define ISAMC_ENCODE 1
- void *(*code_start)(int mode);
- void (*code_stop)(int mode, void *p);
- void (*code_item)(int mode, void *p, char **dst, char **src);
- void (*code_reset)(void *p);
+ ISAM_CODEC codec;
int max_blocks_mem;
int debug;
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);
-int isc_pp_num (ISAMC_PP pp);
+zint isc_pp_num (ISAMC_PP pp);
-int isc_block_used (ISAMC is, int type);
+zint isc_block_used (ISAMC is, int type);
int isc_block_size (ISAMC is, int type);
#define isc_type(x) ((x) & 7)
#define isc_block(x) ((x) >> 3)
-#ifdef __cplusplus
-}
-#endif
+YAZ_END_CDECL
#endif
#define ISAMD_ENCODE 1
void *(*code_start)(int mode);
void (*code_stop)(int mode, void *p);
- void (*code_item)(int mode, void *p, char **dst, char **src);
+ void (*code_item)(int mode, void *p, char **dst, const char **src);
void (*code_reset)(void *p);
int max_blocks_mem;
-/* $Id: isams.h,v 1.5 2004-06-01 12:56:38 adam Exp $
+/* $Id: isams.h,v 1.6 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#ifndef ISAMS_H
#define ISAMS_H
+#include <isam-codec.h>
#include <bfile.h>
+#include <isamc.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ISAMS_s *ISAMS;
-typedef int ISAMS_P;
+typedef ISAMC_P ISAMS_P;
typedef struct ISAMS_PP_s *ISAMS_PP;
typedef struct ISAMS_M_s {
int (*compare_item)(const void *a, const void *b);
void (*log_item)(int logmask, const void *p, const char *txt);
-#define ISAMC_DECODE 0
-#define ISAMC_ENCODE 1
- void *(*code_start)(int mode);
- void (*code_stop)(int mode, void *p);
- void (*code_item)(int mode, void *p, char **dst, char **src);
+ ISAM_CODEC codec;
int debug;
int block_size;
-/* $Id: mfile.h,v 1.21 2003-03-25 23:47:24 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: mfile.h,v 1.22 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
#include <stdio.h>
#include <yaz/yconfig.h>
+#include <zebraver.h>
#ifdef WIN32
-#if 0
-/* 32-bit access .. */
-typedef long mfile_off_t;
-#define mfile_seek lseek
-
-#else
/* 64-bit access .. */
typedef __int64 mfile_off_t;
#define mfile_seek _lseeki64
-#endif
#else
#include <sys/types.h>
typedef struct part_file
{
- int number;
- int top;
- int blocks;
+ zint number;
+ zint top;
+ zint blocks;
mfile_off_t bytes;
mf_dir *dir;
char *path;
/*
* Read one block from a metafile. Interface mirrors bfile.
*/
-int mf_read(MFile mf, int no, int offset, int nbytes, void *buf);
+int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf);
/*
* Same.
*/
-int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf);
+int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf);
/*
* Destroy a metafile, unlinking component files. File must be open.
-/* $Id: rsm_or.h,v 1.6 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: rsm_or.h,v 1.7 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
#include <rset.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+YAZ_BEGIN_CDECL
extern const struct rset_control *rset_kind_m_or;
int (*cmp)(const void *p1, const void *p2);
ISAMC isc;
- ISAM_P *isam_positions;
+ ISAMC_P *isam_positions;
RSET_TERM rset_term;
int no_isam_positions;
int no_save_positions;
} rset_m_or_parms;
-#ifdef __cplusplus
-}
-#endif
+YAZ_END_CDECL
#endif
-/* $Id: sortidx.h,v 1.3 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: sortidx.h,v 1.4 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#ifndef SORTIDX_H
#define SORTIDX_H
+#include <zebraver.h>
#include <bfile.h>
#ifdef __cplusplus
SortIdx sortIdx_open (BFiles bfs, int write_flag);
void sortIdx_close (SortIdx si);
int sortIdx_type (SortIdx si, int type);
-void sortIdx_sysno (SortIdx si, int sysno);
+void sortIdx_sysno (SortIdx si, SYSNO sysno);
void sortIdx_add (SortIdx si, const char *buf, int len);
void sortIdx_read (SortIdx si, char *buf);
-/* $Id: zebraapi.h,v 1.13 2004-07-28 08:15:45 adam Exp $
+/* $Id: zebraapi.h,v 1.14 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
int len; /* length */
oid_value format; /* record syntax */
char *base;
- int sysno;
+ SYSNO sysno;
int score;
} ZebraRetrievalRecord;
int zebra_insert_record (ZebraHandle zh,
const char *recordType,
- int *sysno, const char *match, const char *fname,
+ SYSNO *sysno, const char *match, const char *fname,
const char *buf, int buf_size,
int force_update);
int zebra_update_record (ZebraHandle zh,
const char *recordType,
- int* sysno, const char *match, const char *fname,
+ SYSNO *sysno, const char *match, const char *fname,
const char *buf, int buf_size,
int force_update);
int zebra_delete_record (ZebraHandle zh,
const char *recordType,
- int *sysno, const char *match, const char *fname,
+ SYSNO *sysno, const char *match, const char *fname,
const char *buf, int buf_size,
int force_update);
int *type, char *out, size_t *len);
YAZ_EXPORT int zebra_sort (ZebraHandle zh, ODR stream,
- int num_input_setnames,
- const char **input_setnames,
- const char *output_setname,
- Z_SortKeySpecList *sort_sequence,
- int *sort_status);
+ int num_input_setnames,
+ const char **input_setnames,
+ const char *output_setname,
+ Z_SortKeySpecList *sort_sequence,
+ int *sort_status);
YAZ_EXPORT
int zebra_select_databases (ZebraHandle zh, int num_bases,
-/* $Id: zebrautl.h,v 1.7 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: zebrautl.h,v 1.8 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#ifndef ZEBRA_UTIL_H
#define ZEBRA_UTIL_H
#include <res.h>
#include <zebraver.h>
+YAZ_BEGIN_CDECL
+zint atoi_zn (const char *buf, zint len);
+YAZ_END_CDECL
+
#endif
-/* $Id: zebraver.h,v 1.38 2004-07-30 10:06:09 adam Exp $
+/* $Id: zebraver.h,v 1.39 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
*/
#ifndef ZEBRAVER
-#define ZEBRAVER "1.3.16"
+
+#define ZEBRAVER "1.4.0"
+
+#define ZEBRADATE "$Date: 2004-08-04 08:35:23 $"
+
+#ifdef __GNUC__
+typedef long long int zint;
+#define ZINT_FORMAT "%lld"
+#define ZINT_FORMAT0 "lld"
+#else
+#ifdef WIN32
+typedef __int64 zint;
+#define ZINT_FORMAT "%lld"
+#define ZINT_FORMAT0 "lld"
+#error must define ZINT_FORMAT on Windows
+#else
+typedef long zint;
+#define ZINT_FORMAT "%ld"
+#define ZINT_FORMAT0 "ld"
#endif
+#endif
+
+typedef zint SYSNO;
-#ifndef ZEBRADATE
-#define ZEBRADATE "$Date: 2004-07-30 10:06:09 $"
#endif
-## $Id: Makefile.am,v 1.23 2003-03-26 16:41:48 adam Exp $
+## $Id: Makefile.am,v 1.24 2004-08-04 08:35:23 adam Exp $
noinst_PROGRAMS = apitest kdump
zebrasrv_SOURCES = zserver.c
zebrash_SOURCES = zebrash.c
apitest_SOURCES = apitest.c
-kdump_SOURCES=kdump.c kcompare.c
+kdump_SOURCES = kdump.c
AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) $(TCL_INCLUDE) -DDEFAULT_PROFILE_PATH=\"$(pkgdatadir)/tab\"
-/* $Id: dirs.c,v 1.19 2002-08-17 07:59:03 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: dirs.c,v 1.20 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
dict_delete (p->dict, path);
}
-void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime)
+void dirs_add (struct dirs_info *p, const char *src, SYSNO sysno, time_t mtime)
{
char path[DIRS_MAX_PATH];
char info[16];
-/* $Id: extract.c,v 1.157 2004-07-28 09:47:41 adam Exp $
+/* $Id: extract.c,v 1.158 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
02111-1307, USA.
*/
-
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
struct recKeys *reckeys,
int attrSetS, int attrUseS)
{
+#if IT_KEY_NEW
+/* #error searchRecordKey does not work yet in this mode.. */
+ static const char *ws[32];
+ void *decode_handle = iscz1_start();
+ int off = 0;
+ int startSeq = -1;
+ int seqno = 0;
+ int i;
+
+ for (i = 0; i<32; i++)
+ ws[i] = NULL;
+
+ while (off < reckeys->buf_used)
+ {
+ const char *src = reckeys->buf + off;
+ struct it_key key;
+ char *dst = (char*) &key;
+ int attrSet, attrUse;
+
+ iscz1_decode(decode_handle, &dst, &src);
+ assert(key.len < 4 && key.len > 2);
+
+ attrSet = key.mem[0];
+ attrUse = key.mem[1];
+ seqno = key.mem[2];
+
+ if (attrUseS == attrUse && attrSetS == attrSet)
+ {
+ int woff;
+
+ if (startSeq == -1)
+ startSeq = seqno;
+ woff = seqno - startSeq;
+ if (woff >= 0 && woff < 31)
+ ws[woff] = src;
+ }
+
+ while (*src++)
+ ;
+ off = src - reckeys->buf;
+ }
+ iscz1_stop(decode_handle);
+ assert (off == reckeys->buf_used);
+ return ws;
+#else
static const char *ws[32];
int off = 0;
int startSeq = -1;
}
assert (off == reckeys->buf_used);
return ws;
+#endif
}
struct file_read_info {
int recordOffset;
struct recordGroup *rGroup;
};
+
+void create_rec_keys_codec(struct recKeys *keys)
+{
+ keys->buf_used = 0;
+#if IT_KEY_NEW
+ iscz1_reset(keys->codec_handle);
+#else
+ keys->prevAttrUse = -1;
+ keys->prevAttrSet = -1;
+ keys->prevSeqNo = 0;
+#endif
+}
static int file_extract_record(ZebraHandle zh,
SYSNO *sysno, const char *fname,
/* we are going to read from a file, so prepare the extraction */
int i;
- zh->reg->keys.buf_used = 0;
- zh->reg->keys.prevAttrUse = -1;
- zh->reg->keys.prevAttrSet = -1;
- zh->reg->keys.prevSeqNo = 0;
+ create_rec_keys_codec(&zh->reg->keys);
+
zh->reg->sortKeys.buf_used = 0;
recordOffset = fi->file_moffset;
{
rinfo = dict_lookup (zh->reg->matchDict, matchStr);
if (rinfo)
+ {
+ assert(*rinfo == sizeof(*sysno));
memcpy (sysno, rinfo+1, sizeof(*sysno));
+ }
}
else
{
int delete_flag,
int test_mode,
const char *recordType,
- int *sysno,
+ SYSNO *sysno,
const char *match_criteria,
const char *fname,
int force_update,
extractCtrl.endf = zebra_record_int_end;
extractCtrl.fh = &fc;
- zh->reg->keys.buf_used = 0;
- zh->reg->keys.prevAttrUse = -1;
- zh->reg->keys.prevAttrSet = -1;
- zh->reg->keys.prevSeqNo = 0;
+ create_rec_keys_codec(&zh->reg->keys);
+
zh->reg->sortKeys.buf_used = 0;
if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0]))
if (matchStr) {
rinfo = dict_lookup (zh->reg->matchDict, matchStr);
if (rinfo)
+ {
+ assert(*rinfo == sizeof(*sysno));
memcpy (sysno, rinfo+1, sizeof(*sysno));
+ }
}
}
abort ();
}
- zh->reg->keys.buf_used = 0;
- zh->reg->keys.prevAttrUse = -1;
- zh->reg->keys.prevAttrSet = -1;
- zh->reg->keys.prevSeqNo = 0;
+ create_rec_keys_codec(&zh->reg->keys);
+
zh->reg->sortKeys.buf_used = 0;
extractCtrl.init = extract_init;
void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno,
int cmd, struct recKeys *reckeys)
{
+#if IT_KEY_NEW
+ void *decode_handle = iscz1_start();
+#else
+ int seqno = 0;
#if SU_SCHEME
#else
unsigned char attrSet = (unsigned char) -1;
unsigned short attrUse = (unsigned short) -1;
#endif
- int seqno = 0;
+#endif
int off = 0;
int ch = 0;
ZebraExplainInfo zei = zh->reg->zei;
zh->reg->key_file_no = 0;
}
zebraExplain_recordCountIncrement (zei, cmd ? 1 : -1);
+#if IT_KEY_NEW
+ while (off < reckeys->buf_used)
+ {
+ const char *src = reckeys->buf + off;
+ struct it_key key;
+ char *dst = (char*) &key;
+ int attrSet, attrUse;
+
+ iscz1_decode(decode_handle, &dst, &src);
+ assert(key.len < 4 && key.len > 2);
+
+ attrSet = key.mem[0];
+ attrUse = key.mem[1]; /* sequence in mem[2] */
+
+ if (zh->reg->key_buf_used + 1024 >
+ (zh->reg->ptr_top -zh->reg->ptr_i)*sizeof(char*))
+ extract_flushWriteKeys (zh,0);
+ assert(zh->reg->ptr_i >= 0);
+ ++(zh->reg->ptr_i);
+ assert(zh->reg->ptr_i > 0);
+ (zh->reg->key_buf)[zh->reg->ptr_top - zh->reg->ptr_i] =
+ (char*)zh->reg->key_buf + zh->reg->key_buf_used;
+
+ ch = zebraExplain_lookupSU (zei, attrSet, attrUse);
+ if (ch < 0)
+ ch = zebraExplain_addSU (zei, attrSet, attrUse);
+
+ assert (ch > 0);
+ zh->reg->key_buf_used +=
+ key_SU_encode (ch,((char*)zh->reg->key_buf) +
+ zh->reg->key_buf_used);
+ while (*src)
+ ((char*)zh->reg->key_buf) [(zh->reg->key_buf_used)++] = *src++;
+ src++;
+ ((char*)(zh->reg->key_buf))[(zh->reg->key_buf_used)++] = '\0';
+ ((char*)(zh->reg->key_buf))[(zh->reg->key_buf_used)++] = cmd;
+
+ key.len = 2;
+ key.mem[0] = sysno;
+ key.mem[1] = key.mem[2]; /* sequence .. */
+
+ memcpy ((char*)zh->reg->key_buf + zh->reg->key_buf_used,
+ &key, sizeof(key));
+ (zh->reg->key_buf_used) += sizeof(key);
+ off = src - reckeys->buf;
+ }
+#else
while (off < reckeys->buf_used)
{
const char *src = reckeys->buf + off;
(zh->reg->key_buf_used) += sizeof(key);
off = src - reckeys->buf;
}
+#endif
assert (off == reckeys->buf_used);
+#if IT_KEY_NEW
+ iscz1_stop(decode_handle);
+#endif
}
void extract_flushWriteKeys (ZebraHandle zh, int final)
zh->reg->key_buf_used = 0;
}
-void extract_add_index_string (RecWord *p, const char *string,
- int length)
+void extract_add_index_string (RecWord *p, const char *str, int length)
{
char *dst;
+ ZebraHandle zh = p->extractCtrl->handle;
+ struct recKeys *keys = &zh->reg->keys;
+#if IT_KEY_NEW
+ struct it_key key;
+ const char *src = (char*) &key;
+#else
unsigned char attrSet;
unsigned short attrUse;
int lead = 0;
int diff = 0;
int *pseqno = &p->seqno;
- ZebraHandle zh = p->extractCtrl->handle;
ZebraExplainInfo zei = zh->reg->zei;
- struct recKeys *keys = &zh->reg->keys;
+#endif
if (keys->buf_used+1024 > keys->buf_max)
{
}
dst = keys->buf + keys->buf_used;
+#if IT_KEY_NEW
+ key.len = 3;
+ key.mem[0] = p->attrSet;
+ key.mem[1] = p->attrUse;
+ key.mem[2] = p->seqno;
+
+#if 0
+ /* just for debugging .. */
+ yaz_log(LOG_LOG, "set=%d use=%d seqno=%d", p->attrSet, p->attrUse,
+ p->seqno);
+#endif
+
+ iscz1_encode(keys->codec_handle, &dst, &src);
+
+ *dst++ = p->reg_type;
+ memcpy (dst, str, length);
+ dst += length;
+ *dst++ = '\0';
+#else
/* leader byte is encoded as follows:
bit 0 : 1 if attrset is unchanged; 0 if attrset is changed
bit 1 : 1 if attruse is unchanged; 0 if attruse is changed
lead |= 2;
else
keys->prevAttrUse = attrUse;
-#if 1
+
diff = 1 + *pseqno - keys->prevSeqNo;
if (diff >= 1 && diff <= 15)
lead |= (diff << 2);
else
diff = 0;
-#endif
+
keys->prevSeqNo = *pseqno;
*dst++ = lead;
}
#endif
*dst++ = p->reg_type;
- memcpy (dst, string, length);
+ memcpy (dst, str, length);
dst += length;
*dst++ = '\0';
memcpy (dst, pseqno, sizeof(*pseqno));
dst += sizeof(*pseqno);
}
+#endif
keys->buf_used = dst - keys->buf;
}
-static void extract_add_sort_string (RecWord *p, const char *string,
+static void extract_add_sort_string (RecWord *p, const char *str,
int length)
{
ZebraHandle zh = p->extractCtrl->handle;
off += key_SU_encode(p->attrSet, sk->buf + off);
off += key_SU_encode(p->attrUse, sk->buf + off);
off += key_SU_encode(length, sk->buf + off);
- memcpy (sk->buf + off, string, length);
+ memcpy (sk->buf + off, str, length);
sk->buf_used = off + length;
}
i->prevseq=0;
i->prevcmd=-1;
i->keylen=0;
+#if IT_KEY_NEW
+ i->encode_handle = iscz1_start();
+#endif
}
+#if IT_KEY_NEW
+#else
char *encode_key_int (int d, char *bp)
{
if (d <= 63)
}
return bp;
}
+#endif
+
#define OLDENCODE 1
#ifdef OLDENCODE
void encode_key_write (char *k, struct encode_info *i, FILE *outf)
{
struct it_key key;
- char *bp = i->buf;
+ char *bp = i->buf, *bp0;
+ const char *src = (char *) &key;
+ /* copy term to output buf */
while ((*bp++ = *k++))
;
- memcpy (&key, k+1, sizeof(struct it_key));
+ /* and copy & align key so we can mangle */
+ memcpy (&key, k+1, sizeof(struct it_key)); /* *k is insert/delete */
+#if IT_KEY_NEW
+ bp0 = bp++;
+ iscz1_encode(i->encode_handle, &bp, &src);
+ *bp0 = (*k * 128) + bp - bp0 - 1; /* length and insert/delete combined */
+#else
bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
if (i->sysno != key.sysno)
{
bp = encode_key_int (key.seqno - i->seqno, bp);
i->seqno = key.seqno;
i->cmd = *k;
+#endif
if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
{
logf (LOG_FATAL|LOG_ERRNO, "fwrite");
void encode_key_flush (struct encode_info *i, FILE *outf)
{ /* dummy routine */
+#if IT_KEY_NEW
+ iscz1_stop(i->encode_handle);
+#endif
}
#else
-/* $Id: index.h,v 1.109 2004-06-14 10:31:56 mike Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: index.h,v 1.110 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#ifndef INDEX_H
#define INDEX_H
#include <isams.h>
#include <isam.h>
#include <isamc.h>
-#include <isamd.h>
#include <isamb.h>
#define ISAM_DEFAULT "c"
#include <data1.h>
#define SU_SCHEME 1
#define IT_MAX_WORD 256
-#define IT_KEY_HAVE_SEQNO 1
-#define IT_KEY_HAVE_FIELD 0
-typedef int SYSNO;
+#define IT_KEY_NEW 1
+
+#if IT_KEY_NEW
+
+#endif
+#if IT_KEY_NEW
+#define IT_KEY_LEVEL_MAX 4
+struct it_key {
+ int len;
+ zint mem[IT_KEY_LEVEL_MAX];
+};
+#else
struct it_key {
int sysno;
int seqno;
};
+#endif
enum dirsKind { dirs_dir, dirs_file };
struct dirs_entry *dirs_last (struct dirs_info *p);
void dirs_mkdir (struct dirs_info *p, const char *src, time_t mtime);
void dirs_rmdir (struct dirs_info *p, const char *src);
-void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime);
+void dirs_add (struct dirs_info *p, const char *src, SYSNO sysno, time_t mtime);
void dirs_del (struct dirs_info *p, const char *src);
void dirs_free (struct dirs_info **pp);
int key_open (ZebraHandle zh, int mem);
int key_close (ZebraHandle zh);
int key_compare (const void *p1, const void *p2);
+void key_init(struct it_key *k);
char *key_print_it (const void *p, char *buf);
int key_get_seq (const void *p);
int key_compare_it (const void *p1, const void *p2);
void key_input (ZebraHandle zh, int nkeys, int cache, Res res);
ISAMS_M *key_isams_m (Res res, ISAMS_M *me);
ISAMC_M *key_isamc_m (Res res, ISAMC_M *me);
-ISAMD_M *key_isamd_m (Res res, ISAMD_M *me);
int merge_sort (char **buf, int from, int to);
int key_SU_code (int ch, char *out);
int prevseq;
int prevcmd;
int keylen; /* tells if we have an unwritten key in buf, and how long*/
+#if IT_KEY_NEW
+ void *encode_handle;
+#endif
char buf[ENCODE_BUFLEN];
};
int buf_used;
int buf_max;
char *buf;
+#if IT_KEY_NEW
+ void *codec_handle;
+#else
+ int prevSeqNo;
char prevAttrSet;
short prevAttrUse;
- int prevSeqNo;
+#endif
};
-#if 1
struct sortKeys {
int buf_used;
int buf_max;
char *buf;
};
-#else
-struct sortKey {
- char *string;
- int length;
- int attrSet;
- int attrUse;
- struct sortKey *next;
-};
-#endif
struct zebra_register {
char *name;
ISAMS isams;
ISAM isam;
ISAMC isamc;
- ISAMD isamd;
ISAMB isamb;
Dict dict;
Dict matchDict;
* int rssize; // number of records in result set (estimate?)
*/
void (*end)(struct zebra_register *reg, void *set_handle);
- int (*calc)(void *set_handle, int sysno);
+ int (*calc)(void *set_handle, zint sysno);
void (*add)(void *set_handle, int seqno, int term_index);
};
extern struct rank_control *rankzv_class;
extern struct rank_control *rankliv_class;
-int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream,
+int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, ODR stream,
oid_value input_format, Z_RecordComposition *comp,
oid_value *output_format, char **rec_bufp,
int *rec_lenp, char **basenamep);
int delete_flag,
int test_mode,
const char *recordType,
- int *sysno,
+ SYSNO *sysno,
const char *match_criteria,
const char *fname,
int force_update,
void zebra_livcode_transform(ZebraHandle zh, Z_RPNQuery *query);
-void *iscz1_code_start (int mode);
-void iscz1_code_reset (void *vp);
-void iscz1_code_stop (int mode, void *p);
-void iscz1_code_item (int mode, void *vp, char **dst, char **src);
-
-
+void *iscz1_start ();
+void iscz1_reset (void *vp);
+void iscz1_stop (void *p);
+void iscz1_decode (void *vp, char **dst, const char **src);
+void iscz1_encode (void *vp, char **dst, const char **src);
YAZ_END_CDECL
-/* $Id: invstat.c,v 1.35 2003-06-20 14:21:23 heikki Exp $
+/* $Id: invstat.c,v 1.36 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <string.h>
#include "index.h"
-#include "../isamc/isamd-p.h"
struct inv_stat_info {
ZebraHandle zh;
stat_info->no_dict_entries++;
stat_info->no_dict_bytes += strlen(name);
- if (!stat_info->zh->reg->isamd)
- {
- assert (*info == sizeof(ISAMS_P));
- memcpy (&isam_p, info+1, sizeof(ISAMS_P));
- }
+ assert (*info == sizeof(ISAMS_P));
+ memcpy (&isam_p, info+1, sizeof(ISAMS_P));
if (stat_info->zh->reg->isams)
{
occur = isams_pp_num (pp);
while (isams_pp_read(pp, &key))
{
+ occurx++;
+#if IT_KEY_NEW
+#else
stat_info->cksum = stat_info->cksum * 65509 +
key.sysno + 11 * key.seqno;
- occurx++;
if (-1==firstsys)
{
firstseq=key.seqno;
}
lastsys=key.sysno;
lastseq=key.seqno;
+#endif
}
assert (occurx == occur);
stat_info->no_isam_entries[0] += occur;
occur = isc_pp_num (pp);
while (isc_pp_read(pp, &key))
{
+ occurx++;
+#if IT_KEY_NEW
+#else
stat_info->cksum = stat_info->cksum * 65509 +
key.sysno + 11 * key.seqno;
- occurx++;
if (-1==firstsys)
{
firstseq=key.seqno;
}
lastsys=key.sysno;
lastseq=key.seqno;
+#endif
}
assert (occurx == occur);
stat_info->no_isam_entries[isc_type(isam_p)] += occur;
isc_pp_close (pp);
}
- if (stat_info->zh->reg->isamd)
- {
- ISAMD_PP pp;
- int occurx = 0;
- struct it_key key;
- /* printf("[%d: %d %d %d %d %d %d] ", */
- /* info[0], info[1], info[2], info[3], info[4], info[5], info[7]);*/
- pp = isamd_pp_open (stat_info->zh->reg->isamd, info+1, info[0]);
-
- occur = isamd_pp_num (pp);
- while (isamd_pp_read(pp, &key))
- {
- stat_info->cksum = stat_info->cksum * 65509 +
- key.sysno + 11 * key.seqno;
- occurx++;
- /* printf("%d.%d ", key.sysno, key.seqno); */ /*!*/
- if (-1==firstsys)
- {
- firstseq=key.seqno;
- firstsys=key.sysno;
- }
- lastsys=key.sysno;
- lastseq=key.seqno;
- if ( pp->is->method->debug >8 )
- logf (LOG_LOG,"sysno=%d seqno=%d (%x/%x) oc=%d/%d ofs=%d ",
- key.sysno, key.seqno,
- key.sysno, key.seqno,
- occur,occurx, pp->offset);
- }
- /* printf("\n"); */ /*!*/
-#ifdef SKIPTHIS
- if ( pp->is->method->debug >7 )
- logf(LOG_LOG,"item %d=%d:%d says %d keys, counted %d",
- isam_p, isamd_type(isam_p), isamd_block(isam_p),
- occur, occurx);
-#endif
- if (occurx != occur)
- logf(LOG_LOG,"Count error!!! read %d, counted %d", occur, occurx);
- assert (occurx == occur);
- i = pp->cat;
- if (info[1])
- i=SINGLETON_TYPE;
- stat_info->no_isam_entries[i] += occur;
- isamd_pp_close (pp);
- }
if (stat_info->zh->reg->isamb)
{
ISAMB_PP pp;
while (isamb_pp_read(pp, &key))
{
+ occur++;
+#if IT_KEY_NEW
+#else
stat_info->cksum = stat_info->cksum * 65509 +
key.sysno + 11 * key.seqno;
- occur++;
if (-1==firstsys)
{
firstseq=key.seqno;
}
lastsys=key.sysno;
lastseq=key.seqno;
+#endif
}
isamb_pp_close_x (pp, &size, &blocks);
stat_info->isamb_blocks[cat] += blocks;
int zebra_register_statistics (ZebraHandle zh, int dumpdict)
{
- int blocks;
- int size;
- int count;
int i, prev;
int before = 0;
int occur;
fprintf (stdout, " Blocks Occur Size KB Bytes/Entry\n");
for (i = 0; isc_block_used (zh->reg->isamc, i) >= 0; i++)
{
- fprintf (stdout, " %8d %8d", isc_block_used (zh->reg->isamc, i),
+ fprintf (stdout, " %8" ZINT_FORMAT0 " %8d", isc_block_used (zh->reg->isamc, i),
stat_info.no_isam_entries[i]);
if (stat_info.no_isam_entries[i])
fprintf (stdout, "\n");
}
}
- if (zh->reg->isamd)
- {
- fprintf (stdout, " Blocks Occur KB Bytes/Entry\n");
- if (zh->reg->isamd->method->debug >0)
- logf(LOG_LOG," Blocks Occur KB Bytes/Entry");
- for (i = 0; i<=SINGLETON_TYPE; i++)
- {
- blocks= isamd_block_used(zh->reg->isamd,i);
- size= isamd_block_size(zh->reg->isamd,i);
- count=stat_info.no_isam_entries[i];
- if (i==SINGLETON_TYPE)
- blocks=size=0;
- if (stat_info.no_isam_entries[i])
- {
- fprintf (stdout, "%c %7d %7d %7d %5.2f\n",
- (i==SINGLETON_TYPE)?('z'):('A'+i),
- blocks,
- count,
- (int) ((1023.0 + (double) blocks * size)/1024),
- ((double) blocks * size)/count);
- if (zh->reg->isamd->method->debug >0)
- logf(LOG_LOG, "%c %7d %7d %7d %5.2f",
- (i==SINGLETON_TYPE)?('z'):('A'+i),
- blocks,
- count,
- (int) ((1023.0 + (double) blocks * size)/1024),
- ((double) blocks * size)/count);
- } /* entries */
- } /* for */
- } /* isamd */
- if ( (zh->reg->isamd) && (zh->reg->isamd->method->debug>0))
- fprintf (stdout, "\n%d words using %d bytes\n",
- stat_info.no_dict_entries, stat_info.no_dict_bytes);
if (zh->reg->isamb)
{
-/* $Id: kcompare.c,v 1.46 2004-06-09 13:11:49 adam Exp $
+/* $Id: kcompare.c,v 1.47 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include "index.h"
+#if IT_KEY_NEW
+#define INT_CODEC_NEW 1
+#else
#define INT_CODEC_NEW 0
+#endif
+
#define CODEC_INLINE inline
void key_logdump_txt (int logmask, const void *p, const char *txt)
{
struct it_key key;
if (p)
{
+#if IT_KEY_NEW
+ char formstr[128];
+ int i;
+
memcpy (&key, p, sizeof(key));
- logf (logmask, "%7d:%-4d %s", key.sysno, key.seqno,txt);
+ assert(key.len > 0 && key.len <= IT_KEY_LEVEL_MAX);
+ *formstr = '\0';
+ for (i = 0; i<key.len; i++)
+ {
+ sprintf(formstr + strlen(formstr), ZINT_FORMAT, key.mem[i]);
+ if (i)
+ strcat(formstr, " ");
+ }
+ logf (logmask, "%s %s", formstr, txt);
+#else
+/* !IT_KEY_NEW */
+ memcpy (&key, p, sizeof(key));
+ logf (logmask, "%7d:%-4d %s", key.sysno, key.seqno, txt);
+#endif
}
else
logf(logmask, " (null) %s",txt);
void key_logdump (int logmask, const void *p)
{
- key_logdump_txt(logmask,p,"");
+ key_logdump_txt(logmask, p, "");
}
int key_compare_it (const void *p1, const void *p2)
{
+#if IT_KEY_NEW
+ int i, l = ((struct it_key *) p1)->len;
+ if (((struct it_key *) p2)->len > l)
+ l = ((struct it_key *) p2)->len;
+ assert (l <= 4 && l > 0);
+ for (i = 0; i < l; i++)
+ {
+ if (((struct it_key *) p1)->mem[i] != ((struct it_key *) p2)->mem[i])
+ {
+ if (((struct it_key *) p1)->mem[i] > ((struct it_key *) p2)->mem[i])
+ return l-i;
+ else
+ return i-l;
+ }
+ }
+#else
if (((struct it_key *) p1)->sysno != ((struct it_key *) p2)->sysno)
{
if (((struct it_key *) p1)->sysno > ((struct it_key *) p2)->sysno)
else
return -1;
}
+#endif
return 0;
}
char *key_print_it (const void *p, char *buf)
{
+#if IT_KEY_NEW
+ strcpy(buf, "");
+#else
const struct it_key *i = p;
sprintf (buf, "%d:%d", i->sysno, i->seqno);
+#endif
return buf;
}
struct it_key i1, i2;
memcpy (&i1, p1, sizeof(i1));
memcpy (&i2, p2, sizeof(i2));
+#if IT_KEY_NEW
+ int i, l = i1.len;
+ if (i2.len > l)
+ l = i2.len;
+ assert (l <= 4 && l > 0);
+ for (i = 0; i < l; i++)
+ {
+ if (i1.mem[i] != i2.mem[i])
+ {
+ if (i1.mem[i] > i2.mem[i])
+ return l-i;
+ else
+ return i-l;
+ }
+ }
+#else
if (i1.sysno != i2.sysno)
{
if (i1.sysno > i2.sysno)
else
return -1;
}
+#endif
return 0;
}
{
struct it_key k;
memcpy (&k, p, sizeof(k));
+#if IT_KEY_NEW
+ return k.mem[k.len-1];
+#else
return k.seqno;
+#endif
}
int key_qsort_compare (const void *p1, const void *p2)
struct it_key key;
};
-void *iscz1_code_start (int mode)
+void *iscz1_start (void)
{
struct iscz1_code_info *p = (struct iscz1_code_info *)
xmalloc (sizeof(*p));
- p->key.sysno = 0;
- p->key.seqno = 0;
+ iscz1_reset(p);
return p;
}
-void iscz1_code_reset (void *vp)
+#if IT_KEY_NEW
+void key_init(struct it_key *key)
+{
+ int i;
+ key->len = 0;
+ for (i = 0; i<IT_KEY_LEVEL_MAX; i++)
+ key->mem[i] = 0;
+}
+#endif
+
+void iscz1_reset (void *vp)
{
struct iscz1_code_info *p = (struct iscz1_code_info *) vp;
+#if IT_KEY_NEW
+ int i;
+ p->key.len = 0;
+ for (i = 0; i< IT_KEY_LEVEL_MAX; i++)
+ p->key.mem[i] = 0;
+#else
p->key.sysno = 0;
p->key.seqno = 0;
+#endif
}
-void iscz1_code_stop (int mode, void *p)
+void iscz1_stop (void *p)
{
xfree (p);
}
-#if INT_CODEC_NEW
-static CODEC_INLINE void iscz1_encode_int (unsigned d, char **dst)
+#if INT_CODEC_NEW
+/* small encoder that works with unsigneds of any length */
+static CODEC_INLINE void iscz1_encode_int (zint d, char **dst)
{
unsigned char *bp = (unsigned char*) *dst;
*dst = (char *) bp;
}
-static CODEC_INLINE int iscz1_decode_int (unsigned char **src)
+/* small decoder that works with unsigneds of any length */
+static CODEC_INLINE zint iscz1_decode_int (unsigned char **src)
{
- unsigned d = 0;
+ zint d = 0;
unsigned char c;
unsigned r = 0;
while (((c = *(*src)++) & 128))
{
- d += ((c&127) << r);
+ d += ((zint) (c&127) << r);
r += 7;
}
- d += (c << r);
+ d += ((zint) c << r);
return d;
}
#else
/* ! INT_CODEC_NEW */
+/* old encoder that works with unsigneds up to 30 bits */
static CODEC_INLINE void iscz1_encode_int (unsigned d, char **dst)
{
unsigned char *bp = (unsigned char*) *dst;
*dst = (char *) bp;
}
+/* old decoder that works with unsigneds up to 30 bits */
static CODEC_INLINE int iscz1_decode_int (unsigned char **src)
{
unsigned c = *(*src)++;
}
#endif
-void iscz1_code_item (int mode, void *vp, char **dst, char **src)
+void iscz1_encode (void *vp, char **dst, const char **src)
{
struct iscz1_code_info *p = (struct iscz1_code_info *) vp;
struct it_key tkey;
+#if IT_KEY_NEW
+ zint d;
+ int i;
+#else
int d;
+#endif
- if (mode == ISAMC_ENCODE)
+ /* 1
+ 3, 2, 9, 12
+ 3, 2, 10, 2
+ 4, 1
+
+ if diff is 0, then there is more ...
+ if diff is non-zero, then _may_ be more
+ */
+ memcpy (&tkey, *src, sizeof(struct it_key));
+#if IT_KEY_NEW
+ /* deal with leader + delta encoding .. */
+ d = 0;
+ assert(tkey.len > 0 && tkey.len <= 4);
+ for (i = 0; i < tkey.len; i++)
{
- memcpy (&tkey, *src, sizeof(struct it_key));
- d = tkey.sysno - p->key.sysno;
- if (d)
- {
- iscz1_encode_int (2*tkey.seqno + 1, dst);
- iscz1_encode_int (d, dst);
- p->key.sysno += d;
- p->key.seqno = tkey.seqno;
- }
- else
- {
- iscz1_encode_int (2*(tkey.seqno - p->key.seqno), dst);
- p->key.seqno = tkey.seqno;
- }
- (*src) += sizeof(struct it_key);
+ d = tkey.mem[i] - p->key.mem[i];
+ if (d || i == tkey.len-1)
+ { /* all have been equal until now, now make delta .. */
+ p->key.mem[i] = tkey.mem[i];
+ if (d > 0)
+ {
+ iscz1_encode_int (i + (tkey.len << 3) + 64, dst);
+ i++;
+ iscz1_encode_int (d, dst);
+ }
+ else
+ {
+ iscz1_encode_int (i + (tkey.len << 3), dst);
+ }
+ break;
+ }
+ }
+ /* rest uses absolute encoding ... */
+ for (; i < tkey.len; i++)
+ {
+ iscz1_encode_int (tkey.mem[i], dst);
+ p->key.mem[i] = tkey.mem[i];
+ }
+ (*src) += sizeof(struct it_key);
+#else
+ d = tkey.sysno - p->key.sysno;
+ if (d)
+ {
+ iscz1_encode_int (2*tkey.seqno + 1, dst);
+ iscz1_encode_int (d, dst);
+ p->key.sysno += d;
+ p->key.seqno = tkey.seqno;
}
else
{
- d = iscz1_decode_int ((unsigned char **) src);
- if (d & 1)
- {
- p->key.seqno = d>>1;
- p->key.sysno += iscz1_decode_int ((unsigned char **) src);
- }
- else
- p->key.seqno += d>>1;
- memcpy (*dst, &p->key, sizeof(struct it_key));
- (*dst) += sizeof(struct it_key);
+ iscz1_encode_int (2*(tkey.seqno - p->key.seqno), dst);
+ p->key.seqno = tkey.seqno;
+ }
+ (*src) += sizeof(struct it_key);
+#endif
+}
+
+void iscz1_decode (void *vp, char **dst, const char **src)
+{
+ struct iscz1_code_info *p = (struct iscz1_code_info *) vp;
+#if IT_KEY_NEW
+ int i;
+#else
+ int d;
+#endif
+
+#if IT_KEY_NEW
+ int leader = iscz1_decode_int ((unsigned char **) src);
+ i = leader & 7;
+ if (leader & 64)
+ p->key.mem[i] += iscz1_decode_int ((unsigned char **) src);
+ else
+ p->key.mem[i] = iscz1_decode_int ((unsigned char **) src);
+ p->key.len = (leader >> 3) & 7;
+ while (++i < p->key.len)
+ p->key.mem[i] = iscz1_decode_int ((unsigned char **) src);
+ memcpy (*dst, &p->key, sizeof(struct it_key));
+ (*dst) += sizeof(struct it_key);
+#else
+ d = iscz1_decode_int ((unsigned char **) src);
+ if (d & 1)
+ {
+ p->key.seqno = d>>1;
+ p->key.sysno += iscz1_decode_int ((unsigned char **) src);
}
+ else
+ p->key.seqno += d>>1;
+ memcpy (*dst, &p->key, sizeof(struct it_key));
+ (*dst) += sizeof(struct it_key);
+#endif
}
ISAMS_M *key_isams_m (Res res, ISAMS_M *me)
me->compare_item = key_compare;
me->log_item = key_logdump_txt;
- me->code_start = iscz1_code_start;
- me->code_item = iscz1_code_item;
- me->code_stop = iscz1_code_stop;
+ me->codec.start = iscz1_start;
+ me->codec.decode = iscz1_decode;
+ me->codec.encode = iscz1_encode;
+ me->codec.stop = iscz1_stop;
+ me->codec.reset = iscz1_reset;
me->debug = atoi(res_get_def (res, "isamsDebug", "0"));
me->compare_item = key_compare;
me->log_item = key_logdump_txt;
- me->code_start = iscz1_code_start;
- me->code_item = iscz1_code_item;
- me->code_stop = iscz1_code_stop;
- me->code_reset = iscz1_code_reset;
+ me->codec.start = iscz1_start;
+ me->codec.decode = iscz1_decode;
+ me->codec.encode = iscz1_encode;
+ me->codec.stop = iscz1_stop;
+ me->codec.reset = iscz1_reset;
me->debug = atoi(res_get_def (res, "isamcDebug", "0"));
return me;
}
-ISAMD_M *key_isamd_m (Res res, ISAMD_M *me)
-{
- me = isamd_getmethod (me);
-
- me->compare_item = key_compare;
- me->log_item = key_logdump_txt;
-
- me->code_start = iscz1_code_start;
- me->code_item = iscz1_code_item;
- me->code_stop = iscz1_code_stop;
- me->code_reset = iscz1_code_reset;
-
- me->debug = atoi(res_get_def (res, "isamdDebug", "0"));
-
- return me;
-}
-
int key_SU_encode (int ch, char *out)
{
int i;
-/* $Id: kdump.c,v 1.24 2004-01-22 11:27:21 adam Exp $
+/* $Id: kdump.c,v 1.25 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
02111-1307, USA.
*/
-
#include <stdio.h>
#include <string.h>
#include <assert.h>
char *prog;
-
+#if IT_KEY_NEW
+int main(int argc, char **argv)
+{
+ exit(0);
+}
+#else
int key_file_decode (FILE *f)
{
int c, d;
return 1;
}
+
int main (int argc, char **argv)
{
int ret;
logf (LOG_FATAL|LOG_ERRNO, "fclose %s", key_fname);
exit (1);
}
-
exit (0);
}
+#endif
-/* $Id: kinput.c,v 1.59 2004-06-15 10:56:31 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: kinput.c,v 1.60 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-
-
#include <fcntl.h>
#ifdef WIN32
size_t chunk; /* number of bytes allocated */
size_t buf_ptr; /* current position in buffer */
char *prev_name; /* last word read */
+#if IT_KEY_NEW
+ void *decode_handle;
+#else
int sysno; /* last sysno */
int seqno; /* last seqno */
+#endif
off_t length; /* length of file */
/* handler invoked in each read */
void (*readHandler)(struct key_file *keyp, void *rinfo);
void key_file_destroy (struct key_file *f)
{
+#if IT_KEY_NEW
+ iscz1_stop(f->decode_handle);
+#endif
xfree (f->buf);
xfree (f->prev_name);
xfree (f);
f = (struct key_file *) xmalloc (sizeof(*f));
f->res = res;
+#if IT_KEY_NEW
+ f->decode_handle = iscz1_start();
+#else
f->sysno = 0;
f->seqno = 0;
+#endif
f->no = no;
f->chunk = chunk;
f->offset = 0;
int key_file_read (struct key_file *f, char *key)
{
- int i, d, c;
+ int i, c;
+ char srcbuf[128];
+#if IT_KEY_NEW
+ const char *src = srcbuf;
+ char *dst;
+ int j;
+#else
struct it_key itkey;
+ int d;
+#endif
c = key_file_getc (f);
if (c == 0)
while ((key[i++] = key_file_getc (f)))
;
strcpy (f->prev_name, key);
- f->sysno = 0;
+#if IT_KEY_NEW
+ iscz1_reset(f->decode_handle);
+#endif
}
+#if IT_KEY_NEW
+ c = key_file_getc(f); /* length + insert/delete combined */
+ key[i++] = c & 128;
+ c = c & 127;
+ for (j = 0; j < c; j++)
+ srcbuf[j] = key_file_getc(f);
+ dst = key + i;
+ iscz1_decode(f->decode_handle, &dst, &src);
+ return i + sizeof(struct it_key);
+#else
d = key_file_decode (f);
key[i++] = d & 1;
d = d >> 1;
f->seqno = itkey.seqno;
memcpy (key + i, &itkey, sizeof(struct it_key));
return i + sizeof (struct it_key);
+#endif
}
struct heap_info {
return 0;
}
-int heap_inpd (struct heap_info *hi)
-{
- struct heap_cread_info hci;
- ISAMD_I isamd_i = (ISAMD_I) xmalloc (sizeof(*isamd_i));
-
- hci.key = (char *) xmalloc (KEY_SIZE);
- hci.key_1 = (char *) xmalloc (KEY_SIZE);
- hci.key_2 = (char *) xmalloc (KEY_SIZE);
- hci.ret = -1;
- hci.first_in_list = 1;
- hci.hi = hi;
- hci.more = heap_read_one (hi, hci.cur_name, hci.key);
-
- isamd_i->clientData = &hci;
- isamd_i->read_item = heap_cread_item;
-
- while (hci.more)
- {
- char this_name[INP_NAME_MAX];
- char *dict_info;
- char dictentry[ISAMD_MAX_DICT_LEN+1];
- char dictlen;
-
- strcpy (this_name, hci.cur_name);
-
- /* print_dict_item (hi->reg->zebra_maps, hci.cur_name); */
- /*!*/ /* FIXME: depend on isamd-debug */
-
- assert (hci.cur_name[1]);
- hi->no_diffs++;
- if ((dict_info = dict_lookup (hi->reg->dict, hci.cur_name)))
- {
- dictlen=dict_info[0];
- memcpy (dictentry, dict_info+1, dictlen );
-#ifdef SKIPTHIS
- logf(LOG_LOG,"dictentry before. len=%d: %d %d %d %d %d %d %d %d %d",
- dictlen,dictentry[0], dictentry[1], dictentry[2],
- dictentry[3], dictentry[4], dictentry[5],
- dictentry[6], dictentry[7], dictentry[8]); /*!*/
-#endif
- dictlen= isamd_append(hi->reg->isamd, dictentry, dictlen, isamd_i);
- /* logf dictentry after */
- if (dictlen)
- {
- hi->no_updates++;
- if ( (dictlen!=dict_info[0]) ||
- (0!=memcmp(dictentry, dict_info+1, dictlen)) )
- {
- dict_insert(hi->reg->dict, this_name,
- dictlen,dictentry);
- }
- }
- else
- {
- hi->no_deletions++;
- if (!dict_delete (hi->reg->dict, this_name))
- {
- logf (LOG_FATAL, "dict_delete failed");
- abort();
- }
- }
- }
- else
- {
- dictlen=0;
- memset (dictentry, '\0', ISAMD_MAX_DICT_LEN);
- dictlen= isamd_append(hi->reg->isamd, dictentry, dictlen, isamd_i);
- /* logf dictentry first */
- hi->no_insertions++;
- if (dictlen)
- dict_insert(hi->reg->dict, this_name,
- dictlen,dictentry);
- }
- }
- xfree (isamd_i);
- xfree (hci.key);
- xfree (hci.key_1);
- xfree (hci.key_2);
- return 0;
-}
-
int heap_inp (struct heap_info *hi)
{
char *info;
heap_inpc (hi);
if (zh->reg->isam)
heap_inp (hi);
- if (zh->reg->isamd)
- heap_inpd (hi);
if (zh->reg->isamb)
heap_inpb (hi);
key_heap_destroy (hi, nkeys);
}
-
-
Licensed under the Academic Free License version 1.1.
http://opensource.org/licenses/academic.php
-$Id: livcode.c,v 1.1 2003-03-26 16:41:48 adam Exp $
+$Id: livcode.c,v 1.2 2004-08-04 08:35:23 adam Exp $
*/
* score should be between 0 and 1000. If score cannot be obtained
* -1 should be returned.
*/
-static int calc (void *set_handle, int sysno)
+static int calc (void *set_handle, zint sysno)
{
int i, lo, divisor, score = 0;
struct rank_set_info *si = (struct rank_set_info *) set_handle;
- logf (LOG_DEBUG, "livrank calc sysno=%d", sysno);
+ logf (LOG_DEBUG, "livrank calc sysno=" ZINT_FORMAT, sysno);
if (!si->no_rank_entries)
return -1;
-/* $Id: rank1.c,v 1.14 2003-03-26 16:57:24 adam Exp $
+/* $Id: rank1.c,v 1.15 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
* score should be between 0 and 1000. If score cannot be obtained
* -1 should be returned.
*/
-static int calc (void *set_handle, int sysno)
+static int calc (void *set_handle, zint sysno)
{
int i, lo, divisor, score = 0;
struct rank_set_info *si = (struct rank_set_info *) set_handle;
divisor = si->no_rank_entries * (8+log2_int (si->last_pos/si->no_entries));
score = score / divisor;
#if DEBUG_RANK
- yaz_log (LOG_LOG, "sysno=%d score=%d", sysno, score);
+ yaz_log (LOG_LOG, "sysno=" ZINT_FORMAT " score=%d", sysno, score);
#endif
if (score > 1000)
score = 1000;
-/* $Id: recindex.c,v 1.34 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: recindex.c,v 1.35 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
*/
-
-
/*
* Format of first block
* next (4 bytes)
}
}
-static int read_indx (Records p, int sysno, void *buf, int itemsize,
+static int read_indx (Records p, SYSNO sysno, void *buf, int itemsize,
int ignoreError)
{
int r;
- int pos = (sysno-1)*itemsize;
+ zint pos = (sysno-1)*itemsize;
r = bf_read (p->index_BFile, 1+pos/128, pos%128, itemsize, buf);
if (r != 1 && !ignoreError)
return r;
}
-static void write_indx (Records p, int sysno, void *buf, int itemsize)
+static void write_indx (Records p, SYSNO sysno, void *buf, int itemsize)
{
- int pos = (sysno-1)*itemsize;
+ zint pos = (sysno-1)*itemsize;
bf_write (p->index_BFile, 1+pos/128, pos%128, itemsize, buf);
}
-static void rec_release_blocks (Records p, int sysno)
+static void rec_release_blocks (Records p, SYSNO sysno)
{
struct record_index_entry entry;
- int freeblock;
- char block_and_ref[sizeof(short) + sizeof(int)];
+ zint freeblock;
+ char block_and_ref[sizeof(short) + sizeof(zint)];
int dst_type;
int first = 1;
if (first)
{
short ref;
- memcpy (&ref, block_and_ref + sizeof(int), sizeof(ref));
+ memcpy (&ref, block_and_ref + sizeof(freeblock), sizeof(ref));
--ref;
- memcpy (block_and_ref + sizeof(int), &ref, sizeof(ref));
+ memcpy (block_and_ref + sizeof(freeblock), &ref, sizeof(ref));
if (ref)
{
if (bf_write (p->data_BFile[dst_type], freeblock, 0,
exit (1);
}
p->head.block_free[dst_type] = freeblock;
- memcpy (&freeblock, block_and_ref, sizeof(int));
+ memcpy (&freeblock, block_and_ref, sizeof(freeblock));
p->head.block_used[dst_type]--;
}
write_indx (p, rec->sysno, &entry, sizeof(entry));
}
-static void rec_write_tmp_buf (Records p, int size, int *sysnos)
+static void rec_write_tmp_buf (Records p, int size, SYSNO *sysnos)
{
struct record_index_entry entry;
int no_written = 0;
char *cptr = p->tmp_buf;
- int block_prev = -1, block_free;
+ zint block_prev = -1, block_free;
int dst_type = 0;
int i;
block_free, 0, sizeof(*p->head.block_free),
&p->head.block_free[dst_type]) != 1)
{
- logf (LOG_FATAL|LOG_ERRNO, "read in %s at free block %d",
+ logf (LOG_FATAL|LOG_ERRNO, "read in %s at free block " ZINT_FORMAT,
p->data_fname[dst_type], block_free);
exit (1);
}
}
else
{
- memcpy (cptr, &block_free, sizeof(int));
+ memcpy (cptr, &block_free, sizeof(block_free));
bf_write (p->data_BFile[dst_type], block_prev, 0, 0, cptr);
cptr = p->tmp_buf + no_written;
}
block_prev = block_free;
- no_written += p->head.block_size[dst_type] - sizeof(int);
+ no_written += p->head.block_size[dst_type] - sizeof(zint);
p->head.block_used[dst_type]++;
}
assert (block_prev != -1);
block_free = 0;
- memcpy (cptr, &block_free, sizeof(int));
+ memcpy (cptr, &block_free, sizeof(block_free));
bf_write (p->data_BFile[dst_type], block_prev, 0,
- sizeof(int) + (p->tmp_buf+size) - cptr, cptr);
+ sizeof(block_free) + (p->tmp_buf+size) - cptr, cptr);
}
Records rec_open (BFiles bfs, int rw, int compression_method)
*np = n;
}
+static void rec_encode_zint (zint n, unsigned char *buf, int *len)
+{
+ (*len) = 0;
+ while (n > 127)
+ {
+ buf[*len] = 128 + (n & 127);
+ n = n >> 7;
+ (*len)++;
+ }
+ buf[*len] = n;
+ (*len)++;
+}
+
+static void rec_decode_zint(zint *np, unsigned char *buf, int *len)
+{
+ zint n = 0;
+ zint w = 1;
+ (*len) = 0;
+
+ while (buf[*len] > 127)
+ {
+ n += w*(buf[*len] & 127);
+ w = w << 7;
+ (*len)++;
+ }
+ n += w * buf[*len];
+ (*len)++;
+ *np = n;
+}
+
static void rec_cache_flush_block1 (Records p, Record rec, Record last_rec,
char **out_buf, int *out_size,
int *out_offset)
}
if (i == 0)
{
- rec_encode_unsigned (rec->sysno, *out_buf + *out_offset, &len);
+ rec_encode_zint (rec->sysno, *out_buf + *out_offset, &len);
(*out_offset) += len;
}
if (rec->size[i] == 0)
int out_size = 1000;
int out_offset = 0;
char *out_buf = (char *) xmalloc (out_size);
- int *sysnos = (int *) xmalloc (sizeof(*sysnos) * (p->cache_cur + 1));
- int *sysnop = sysnos;
+ SYSNO *sysnos = (SYSNO *) xmalloc (sizeof(*sysnos) * (p->cache_cur + 1));
+ SYSNO *sysnop = sysnos;
for (i = 0; i<p->cache_cur - saveCount; i++)
{
#else
i = bzBuffToBuffCompress
#endif
- (p->tmp_buf+sizeof(int)+sizeof(short)+
+ (p->tmp_buf+sizeof(zint)+sizeof(short)+
sizeof(char),
&csize, out_buf, out_offset, 1, 0, 30);
if (i != BZ_OK)
/* either no compression or compression not supported ... */
csize = out_offset;
rec_tmp_expand (p, csize);
- memcpy (p->tmp_buf + sizeof(int) + sizeof(short) + sizeof(char),
+ memcpy (p->tmp_buf + sizeof(zint) + sizeof(short) + sizeof(char),
out_buf, out_offset);
csize = out_offset;
compression_method = REC_COMPRESS_NONE;
}
- memcpy (p->tmp_buf + sizeof(int), &ref_count, sizeof(ref_count));
- memcpy (p->tmp_buf + sizeof(int)+sizeof(short),
+ memcpy (p->tmp_buf + sizeof(zint), &ref_count, sizeof(ref_count));
+ memcpy (p->tmp_buf + sizeof(zint)+sizeof(short),
&compression_method, sizeof(compression_method));
/* -------- compression */
p->cache_cur = saveCount;
}
-static Record *rec_cache_lookup (Records p, int sysno,
+static Record *rec_cache_lookup (Records p, SYSNO sysno,
enum recordCacheFlag flag)
{
int i;
*pp = NULL;
}
-static Record rec_get_int (Records p, int sysno)
+static Record rec_get_int (Records p, SYSNO sysno)
{
int i, in_size, r;
Record rec, *recp;
struct record_index_entry entry;
- int freeblock, dst_type;
+ zint freeblock;
+ int dst_type;
char *nptr, *cptr;
char *in_buf = 0;
char *bz_buf = 0;
while (freeblock)
{
- int tmp;
+ zint tmp;
cptr += p->head.block_size[dst_type] - sizeof(freeblock);
rec = (Record) xmalloc (sizeof(*rec));
rec->sysno = sysno;
- memcpy (&compression_method, p->tmp_buf + sizeof(int) + sizeof(short),
+ memcpy (&compression_method, p->tmp_buf + sizeof(zint) + sizeof(short),
sizeof(compression_method));
- in_buf = p->tmp_buf + sizeof(int) + sizeof(short) + sizeof(char);
+ in_buf = p->tmp_buf + sizeof(zint) + sizeof(short) + sizeof(char);
in_size = entry.size - sizeof(short) - sizeof(char);
switch (compression_method)
{
nptr = in_buf; /* skip ref count */
while (nptr < in_buf + in_size)
{
- int this_sysno;
+ zint this_sysno;
int len;
- rec_decode_unsigned (&this_sysno, nptr, &len);
+ rec_decode_zint (&this_sysno, nptr, &len);
nptr += len;
for (i = 0; i < REC_NO_INFO; i++)
return rec;
}
-Record rec_get (Records p, int sysno)
+Record rec_get (Records p, SYSNO sysno)
{
Record rec;
zebra_mutex_lock (&p->mutex);
static Record rec_new_int (Records p)
{
- int sysno, i;
+ int i;
+ SYSNO sysno;
Record rec;
assert (p);
-/* $Id: recindex.h,v 1.20 2002-10-23 14:28:20 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: recindex.h,v 1.21 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#ifndef RECINDEX_H
#define RECINDEX_H
#define REC_NO_INFO 8
typedef struct record_info {
- int sysno;
+ SYSNO sysno;
int newFlag;
char *info[REC_NO_INFO];
size_t size[REC_NO_INFO];
void rec_rm (Record *recpp);
void rec_put (Records p, Record *recpp);
Record rec_new (Records p);
-Record rec_get (Records p, int sysno);
+Record rec_get (Records p, SYSNO sysno);
void rec_close (Records *p);
Records rec_open (BFiles bfs, int rw, int compression_method);
char *rec_strdup (const char *s, size_t *len);
-/* $Id: recindxp.h,v 1.12 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: recindxp.h,v 1.13 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#include "recindex.h"
#include <bfile.h>
#define REC_BLOCK_TYPES 2
#define REC_HEAD_MAGIC "recindex"
-#define REC_VERSION 4
+#define REC_VERSION 5
struct records_info {
int rw;
struct records_head {
char magic[8];
char version[4];
- int block_size[REC_BLOCK_TYPES];
- int block_free[REC_BLOCK_TYPES];
- int block_last[REC_BLOCK_TYPES];
- int block_used[REC_BLOCK_TYPES];
- int block_move[REC_BLOCK_TYPES];
+ zint block_size[REC_BLOCK_TYPES];
+ zint block_free[REC_BLOCK_TYPES];
+ zint block_last[REC_BLOCK_TYPES];
+ zint block_used[REC_BLOCK_TYPES];
+ zint block_move[REC_BLOCK_TYPES];
- int total_bytes;
- int index_last;
- int index_free;
- int no_records;
+ zint total_bytes;
+ zint index_last;
+ zint index_free;
+ zint no_records;
} head;
};
};
struct record_index_entry {
- int next; /* first block of record info / next free entry */
- int size; /* size of record or 0 if free entry */
+ zint next; /* first block of record info / next free entry */
+ int size; /* size of record or 0 if free entry */
};
YAZ_END_CDECL
-/* $Id: recstat.c,v 1.8 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: recstat.c,v 1.9 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
void rec_prstat (Records records)
{
int i;
- int total_bytes = 0;
+ zint total_bytes = 0;
logf (LOG_LOG,
- "Total records %8d",
+ "Total records %8" ZINT_FORMAT0,
records->head.no_records);
for (i = 0; i< REC_BLOCK_TYPES; i++)
{
- logf (LOG_LOG, "Record blocks of size %d",
+ logf (LOG_LOG, "Record blocks of size " ZINT_FORMAT,
records->head.block_size[i]);
logf (LOG_LOG,
- " Used/Total/Bytes used %d/%d/%d",
+ " Used/Total/Bytes used "
+ ZINT_FORMAT "/" ZINT_FORMAT "/" ZINT_FORMAT,
records->head.block_used[i], records->head.block_last[i]-1,
records->head.block_used[i] * records->head.block_size[i]);
total_bytes +=
records->head.block_used[i] * records->head.block_size[i];
}
logf (LOG_LOG,
- "Total size of record index in bytes %8d",
+ "Total size of record index in bytes %8" ZINT_FORMAT0,
records->head.total_bytes);
logf (LOG_LOG,
- "Total size with overhead %8d", total_bytes);
+ "Total size with overhead %8" ZINT_FORMAT0,
+ total_bytes);
}
-/* $Id: retrieve.c,v 1.21 2004-05-27 09:28:01 adam Exp $
+/* $Id: retrieve.c,v 1.22 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
fc->offset_end = off;
}
-int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream,
+int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, ODR stream,
oid_value input_format, Z_RecordComposition *comp,
oid_value *output_format, char **rec_bufp,
int *rec_lenp, char **basenamep)
rec = rec_get (zh->reg->records, sysno);
if (!rec)
{
- logf (LOG_DEBUG, "rec_get fail on sysno=%d", sysno);
+ logf (LOG_DEBUG, "rec_get fail on sysno=" ZINT_FORMAT, sysno);
*basenamep = 0;
return 14;
}
logf (LOG_WARN, "Retrieve: Cannot handle type %s", file_type);
return 14;
}
- logf (LOG_DEBUG, "retrieve localno=%d score=%d", sysno, score);
+ logf (LOG_DEBUG, "retrieve localno=" ZINT_FORMAT " score=%d", sysno,score);
retrieveCtrl.fh = &fc;
fc.fd = -1;
retrieveCtrl.fname = fname;
-/* $Id: sortidx.c,v 1.8 2002-12-10 12:54:24 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: sortidx.c,v 1.9 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
#define SORT_IDX_BLOCKSIZE 64
struct sortFileHead {
- int sysno_max;
+ SYSNO sysno_max;
};
struct sortFile {
struct sortIdx {
BFiles bfs;
int write_flag;
- int sysno;
+ SYSNO sysno;
char *entry_buf;
struct sortFile *current_file;
struct sortFile *files;
return 0;
}
-void sortIdx_sysno (SortIdx si, int sysno)
+void sortIdx_sysno (SortIdx si, SYSNO sysno)
{
si->sysno = sysno;
}
-/* $Id: trunc.c,v 1.28 2003-03-26 16:41:48 adam Exp $
+/* $Id: trunc.c,v 1.29 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <rsisams.h>
#include <rsisam.h>
#include <rsisamc.h>
-#include <rsisamd.h>
#include <rsisamb.h>
#if NEW_TRUNC
#include <rsm_or.h>
heap_close (ti);
xfree (ispt);
}
-
- else if (zi->reg->isamd)
- {
- ISAMD_PP *ispt;
- int i;
- struct trunc_info *ti;
-
- ispt = (ISAMD_PP *) xmalloc (sizeof(*ispt) * (to-from));
-
- ti = heap_init (to-from, sizeof(struct it_key),
- key_compare_it);
- for (i = to-from; --i >= 0; )
- {
- logf(LOG_FATAL, "isam_d does not (currently) support truncs");
- abort();
- /*ispt[i] = isamd_pp_open (zi->reg->isamd, isam_p[from+i]); */
- if (isamd_pp_read (ispt[i], ti->tmpbuf))
- heap_insert (ti, ti->tmpbuf, i);
- else
- isamd_pp_close (ispt[i]);
- }
- while (ti->heapnum)
- {
- int n = ti->indx[ti->ptr[1]];
-
- rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
- nn++;
-#if 0
-/* section that preserve all keys */
- heap_delete (ti);
- if (isamd_pp_read (ispt[n], ti->tmpbuf))
- heap_insert (ti, ti->tmpbuf, n);
- else
- isamd_pp_close (ispt[n]);
-#else
-/* section that preserve all keys with unique sysnos */
- while (1)
- {
- if (!isamd_pp_read (ispt[n], ti->tmpbuf))
- {
- heap_delete (ti);
- isamd_pp_close (ispt[n]);
- break;
- }
- if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > 1)
- {
- heap_delete (ti);
- heap_insert (ti, ti->tmpbuf, n);
- break;
- }
- }
-#endif
- }
- heap_close (ti);
- xfree (ispt);
- }
else if (zi->reg->isams)
{
ISAMS_PP *ispt;
return d;
return isc_block (i1) - isc_block (i2);
}
-static int isamd_trunc_cmp (const void *p1, const void *p2)
-{
- ISAMD_P i1 = *(ISAMD_P*) p1;
- ISAMD_P i2 = *(ISAMD_P*) p2;
- int d;
-
- d = isamd_type (i1) - isamd_type (i2);
- if (d)
- return d;
- return isamd_block (i1) - isamd_block (i2);
-}
RSET rset_trunc (ZebraHandle zi, ISAMS_P *isam_p, int no,
const char *term, int length, const char *flags,
#endif
qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp);
}
- else if (zi->reg->isamd)
- {
- if (no == 1)
- {
- rset_isamd_parms parms;
-
- logf(LOG_FATAL, "isam_d does not (currently) support truncs");
- abort();
- /* parms.pos = *isam_p; */
- parms.is = zi->reg->isamd;
- parms.rset_term = rset_term_create (term, length, flags,
- term_type);
- return rset_create (rset_kind_isamd, &parms);
- }
-#if NEW_TRUNC_NOT_DONE_FOR_ISAM_D
- else if (no < 10000)
- {
- rset_m_or_parms parms;
-
- parms.key_size = sizeof(struct it_key);
- parms.cmp = key_compare_it;
- parms.isc = 0;
- parms.isamd=zi->reg->isamd;
- parms.isam_positions = isam_p;
- parms.no_isam_positions = no;
- parms.no_save_positions = 100000;
- parms.rset_term = rset_term_create (term, length, flags);
- return rset_create (rset_kind_m_or, &parms);
- }
-#endif
- qsort (isam_p, no, sizeof(*isam_p), isamd_trunc_cmp);
- }
else if (zi->reg->isamb)
{
if (no == 1)
term_type);
return rset_create (rset_kind_isamb, &parms);
}
- qsort (isam_p, no, sizeof(*isam_p), isamd_trunc_cmp);
+ qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp);
}
else
{
-/* $Id: zebraapi.c,v 1.120 2004-07-28 08:15:45 adam Exp $
+/* $Id: zebraapi.c,v 1.121 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
reg->keys.buf_max = 0;
reg->keys.buf = 0;
+#if IT_KEY_NEW
+ reg->keys.codec_handle = iscz1_start();
+#endif
+
reg->sortKeys.buf = 0;
reg->sortKeys.buf_max = 0;
reg->matchDict = 0;
reg->isam = 0;
reg->isamc = 0;
- reg->isamd = 0;
reg->isamb = 0;
reg->zei = 0;
reg->matchDict = 0;
return 0;
}
}
- if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
- {
- struct ISAMD_M_s isamd_m;
-
- if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD,
- rw, key_isamd_m(res, &isamd_m))))
- {
- logf (LOG_WARN, "isamd_open");
- return 0;
- }
- }
if (res_get_match (res, "isam", "b", ISAM_DEFAULT))
{
struct ISAMC_M_s isamc_m;
is_close (reg->isam);
if (reg->isamc)
isc_close (reg->isamc);
- if (reg->isamd)
- isamd_close (reg->isamd);
if (reg->isamb)
isamb_close (reg->isamb);
rec_close (®->records);
xfree (reg->sortKeys.buf);
xfree (reg->keys.buf);
+#if IT_KEY_NEW
+ if (reg->keys.codec_handle)
+ iscz1_stop(reg->keys.codec_handle);
+#endif
xfree (reg->key_buf);
xfree (reg->name);
int zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
{
- int sysno;
+ SYSNO sysno;
int i;
ASSERTZH;
yaz_log(LOG_API,"zebra_admin_import_segment");
/* 3 = delete. Fail if does not exist */
/* 4 = update. Insert/replace */
{
- int sysno = 0;
+ SYSNO sysno = 0;
char *rinfo = 0;
char recid_z[256];
ASSERTZH;
int zebra_add_record(ZebraHandle zh,
const char *buf, int buf_size)
{
- int sysno = 0;
+ SYSNO sysno = 0;
return zebra_update_record(zh, 0, &sysno, 0, 0, buf, buf_size, 0);
}
int zebra_insert_record (ZebraHandle zh,
const char *recordType,
- int *sysno, const char *match, const char *fname,
+ SYSNO *sysno, const char *match, const char *fname,
const char *buf, int buf_size, int force_update)
{
int res;
- yaz_log(LOG_API,"zebra_insert_record sysno=%d", *sysno);
+ yaz_log(LOG_API,"zebra_insert_record sysno=" ZINT_FORMAT, *sysno);
if (buf_size < 1) buf_size = strlen(buf);
int zebra_update_record (ZebraHandle zh,
const char *recordType,
- int* sysno, const char *match, const char *fname,
+ SYSNO* sysno, const char *match, const char *fname,
const char *buf, int buf_size,
int force_update)
{
int res;
- yaz_log(LOG_API,"zebra_update_record sysno=%d", *sysno);
+ yaz_log(LOG_API,"zebra_update_record sysno=" ZINT_FORMAT, *sysno);
if (buf_size < 1) buf_size = strlen(buf);
int zebra_delete_record (ZebraHandle zh,
const char *recordType,
- int *sysno, const char *match, const char *fname,
+ SYSNO *sysno, const char *match, const char *fname,
const char *buf, int buf_size,
int force_update)
{
int res;
- yaz_log(LOG_API,"zebra_delete_record sysno=%d", *sysno);
+ yaz_log(LOG_API,"zebra_delete_record sysno=" ZINT_FORMAT, *sysno);
if (buf_size < 1) buf_size = strlen(buf);
-/* $Id: zebrash.c,v 1.27 2004-07-28 08:15:45 adam Exp $
+/* $Id: zebrash.c,v 1.28 2004-08-04 08:35:23 adam Exp $
Copyright (C) 2002,2003,2004
Index Data Aps
static int cmd_record_insert( char *args[], WRBUF outbuff)
{
- int sysno=0;
+ SYSNO sysno=0;
int rc;
char *rec=restargs(args,1);
-/* $Id: zinfo.c,v 1.37 2003-06-30 19:37:12 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: zinfo.c,v 1.38 2004-08-04 08:35:23 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
typedef struct zebAccessObjectB *zebAccessObject;
struct zebAccessObjectB {
void *handle;
- int sysno;
+ SYSNO sysno;
Odr_oid *oid;
zebAccessObject next;
};
typedef struct {
struct zebSUInfoB *SUInfo;
- int sysno;
+ SYSNO sysno;
int dirty;
int readFlag;
data1_node *data1_tree;
zebAttributeDetails attributeDetails;
char *databaseName;
data1_node *data1_database;
- int recordCount; /* records in db */
- int recordBytes; /* size of records */
- int sysno; /* sysno of database info */
+ zint recordCount; /* records in db */
+ zint recordBytes; /* size of records */
+ SYSNO sysno; /* sysno of database info */
int readFlag; /* 1: read is needed when referenced; 0 if not */
int dirty; /* 1: database is dirty: write is needed */
struct zebDatabaseInfoB *next;
struct zebraCategoryListInfo {
int dirty;
- int sysno;
+ SYSNO sysno;
data1_node *data1_categoryList;
};
struct zebraExplainInfo {
- int ordinalSU;
- int runNumber;
- int dirty;
+ int ordinalSU;
+ zint runNumber;
+ int dirty;
int write_flag;
Records records;
data1_handle dh;
int key_flush);
-static Record createRecord (Records records, int *sysno)
+static Record createRecord (Records records, SYSNO *sysno)
{
Record rec;
if (*sysno)
memcpy ((*zdip)->databaseName, node_name->u.data.data,
node_name->u.data.len);
(*zdip)->databaseName[node_name->u.data.len] = '\0';
- (*zdip)->sysno = atoi_n (node_id->u.data.data,
- node_id->u.data.len);
+ (*zdip)->sysno = atoi_zn (node_id->u.data.data,
+ node_id->u.data.len);
(*zdip)->attributeDetails = (zebAttributeDetails)
nmem_malloc (zei->nmem, sizeof(*(*zdip)->attributeDetails));
- (*zdip)->attributeDetails->sysno = atoi_n (node_aid->u.data.data,
- node_aid->u.data.len);
+ (*zdip)->attributeDetails->sysno = atoi_zn (node_aid->u.data.data,
+ node_aid->u.data.len);
(*zdip)->attributeDetails->readFlag = 1;
(*zdip)->attributeDetails->dirty = 0;
(*zdip)->attributeDetails->SUInfo = NULL;
"runNumber");
np = np->child;
assert (np && np->which == DATA1N_data);
- zei->runNumber = atoi_n (np->u.data.data, np->u.data.len);
- yaz_log (LOG_DEBUG, "read runnumber = %d", zei->runNumber);
+ zei->runNumber = atoi_zn (np->u.data.data, np->u.data.len);
+ yaz_log (LOG_DEBUG, "read runnumber=" ZINT_FORMAT, zei->runNumber);
*zdip = NULL;
}
rec_rm (&trec);
&& (np = data1_search_tag (zei->dh, node_zebra->child,
"recordBytes"))
&& np->child && np->child->which == DATA1N_data)
- zdi->recordBytes = atoi_n (np->child->u.data.data,
- np->child->u.data.len);
+ zdi->recordBytes = atoi_zn (np->child->u.data.data,
+ np->child->u.data.len);
if ((np = data1_search_tag (zei->dh, node_dbinfo->child,
"recordCount")) &&
(np = data1_search_tag (zei->dh, np->child,
"recordCountActual")) &&
np->child->which == DATA1N_data)
{
- zdi->recordCount = atoi_n (np->child->u.data.data,
- np->child->u.data.len);
+ zdi->recordCount = atoi_zn (np->child->u.data.data,
+ np->child->u.data.len);
}
zdi->readFlag = 0;
rec_rm (&rec);
int i;
Record drec;
data1_node *node_ci, *node_categoryList;
- int sysno = 0;
+ SYSNO sysno = 0;
static char *category[] = {
"CategoryList",
"TargetInfo",
/* record count */
node_count = data1_mk_tag_uni (zei->dh, zei->nmem,
"recordCount", node_dbinfo);
- data1_mk_tag_data_int (zei->dh, node_count, "recordCountActual",
- zdi->recordCount, zei->nmem);
+ data1_mk_tag_data_zint (zei->dh, node_count, "recordCountActual",
+ zdi->recordCount, zei->nmem);
/* zebra info (private) */
node_zebra = data1_mk_tag_uni (zei->dh, zei->nmem,
"zebraInfo", node_dbinfo);
- data1_mk_tag_data_int (zei->dh, node_zebra,
+ data1_mk_tag_data_zint (zei->dh, node_zebra,
"recordBytes", zdi->recordBytes, zei->nmem);
/* convert to "SGML" and write it */
#if ZINFO_DEBUG
"database", 0 /* attr */, node_list);
data1_mk_tag_data_text (zei->dh, node_db, "name",
zdi->databaseName, zei->nmem);
- data1_mk_tag_data_int (zei->dh, node_db, "id",
- zdi->sysno, zei->nmem);
- data1_mk_tag_data_int (zei->dh, node_db, "attributeDetailsId",
- zdi->attributeDetails->sysno, zei->nmem);
+ data1_mk_tag_data_zint (zei->dh, node_db, "id",
+ zdi->sysno, zei->nmem);
+ data1_mk_tag_data_zint (zei->dh, node_db, "attributeDetailsId",
+ zdi->attributeDetails->sysno, zei->nmem);
}
data1_mk_tag_data_int (zei->dh, node_zebra, "ordinalSU",
zei->ordinalSU, zei->nmem);
- data1_mk_tag_data_int (zei->dh, node_zebra, "runNumber",
- zei->runNumber, zei->nmem);
+ data1_mk_tag_data_zint (zei->dh, node_zebra, "runNumber",
+ zei->runNumber, zei->nmem);
#if ZINFO_DEBUG
data1_pr_tree (zei->dh, zei->data1_target, stderr);
-/* $Id: zrpn.c,v 1.141 2004-08-03 12:15:44 heikki Exp $
+/* $Id: zrpn.c,v 1.142 2004-08-04 08:35:23 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#ifdef TERM_COUNT
int *term_no;
#endif
- ISAMS_P *isam_p_buf;
+ ISAMC_P *isam_p_buf;
int isam_p_size;
int isam_p_indx;
ZebraHandle zh;
{
if (p->isam_p_indx == p->isam_p_size)
{
- ISAMS_P *new_isam_p_buf;
+ ISAMC_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 = (ISAMS_P *) xmalloc (sizeof(*new_isam_p_buf) *
+ new_isam_p_buf = (ISAMC_P *) xmalloc (sizeof(*new_isam_p_buf) *
p->isam_p_size);
if (p->isam_p_buf)
{
{
char term_dst[IT_MAX_WORD+1];
RSET rset[60], result;
- int rset_no = 0;
+ int rset_no = 0;
struct grep_info grep_info;
char *termz = normalize_term(zh, zapt, termz_org, stream, reg_type);
const char *termp = termz;
RSET result;
RSFD rsfd;
struct it_key key;
+ int sys;
rset_temp_parms parms;
parms.rset_term = rset_term_create (termz, -1, rank_type,
result = rset_create (rset_kind_temp, &parms);
rsfd = rset_open (result, RSETF_WRITE);
- key.sysno = atoi (termz);
+ sys = atoi(termz);
+ if (sys <= 0)
+ sys = 1;
+#if IT_KEY_NEW
+ key.mem[0] = sys;
+ key.mem[1] = 1;
+ key.len = 2;
+#else
+ key.sysno = sys;
key.seqno = 1;
if (key.sysno <= 0)
key.sysno = 1;
+#endif
rset_write (result, rsfd, &key);
rset_close (result, rsfd);
return result;
struct scan_info_entry {
char *term;
- ISAMS_P isam_p;
+ ISAMC_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(ISAMS_P));
- memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAMS_P));
+ assert (*info == sizeof(ISAMC_P));
+ memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAMC_P));
return 0;
}
rfd = rset_open (r, RSETF_READ);
while (rset_read (r, rfd, &key, &term_index))
{
+#if IT_KEY_NEW
+ if (key.mem[0] != psysno)
+ {
+ psysno = key.mem[0];
+ (*count)++;
+ }
+#else
if (key.sysno != psysno)
{
psysno = key.sysno;
(*count)++;
}
+#endif
kno++;
}
rset_close (r, rfd);
-/* $Id: zserver.c,v 1.117 2004-08-02 10:12:06 adam Exp $
+/* $Id: zserver.c,v 1.118 2004-08-04 08:35:24 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
Z_External *rec = notToKeep->elements[i]->record;
struct oident *oident = 0;
Odr_oct *opaque_recid = 0;
- int sysno = 0;
+ SYSNO sysno = 0;
if (notToKeep->elements[i]->u.opaque)
{
-/* $Id: zsets.c,v 1.49 2004-06-13 18:45:25 adam Exp $
+/* $Id: zsets.c,v 1.50 2004-08-04 08:35:24 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
};
struct zset_sort_entry {
- int sysno;
+ zint sysno;
int score;
char buf[ZSET_SORT_MAX_LEVEL][SORT_IDX_ENTRYSIZE];
};
{
int position = 0;
int num_i = 0;
- int psysno = 0;
+ zint psysno = 0;
int term_index;
RSFD rfd;
struct it_key key;
rfd = rset_open (rset, RSETF_READ);
while (num_i < num && rset_read (rset, rfd, &key, &term_index))
{
- if (key.sysno != psysno)
+#if IT_KEY_NEW
+ zint this_sys = key.mem[0];
+#else
+ zint this_sys = key.sysno;
+#endif
+ if (this_sys != psysno)
{
- psysno = key.sysno;
+ psysno = this_sys;
if (sort_info)
{
/* determine we alreay have this in our set */
void resultSetInsertSort (ZebraHandle zh, ZebraSet sset,
struct sortKeyInfo *criteria, int num_criteria,
- int sysno)
+ zint sysno)
{
struct zset_sort_entry this_entry;
struct zset_sort_entry *new_entry = NULL;
}
void resultSetInsertRank (ZebraHandle zh, struct zset_sort_info *sort_info,
- int sysno, int score, int relation)
+ zint sysno, int score, int relation)
{
struct zset_sort_entry *new_entry = NULL;
int i, j;
ZebraSet sset, RSET rset,
Z_SortKeySpecList *sort_sequence, int *sort_status)
{
- int i, psysno = 0;
+ int i;
+ zint psysno = 0;
struct it_key key;
struct sortKeyInfo sort_criteria[3];
int num_criteria;
rfd = rset_open (rset, RSETF_READ);
while (rset_read (rset, rfd, &key, &term_index))
{
- if (key.sysno != psysno)
+#if IT_KEY_NEW
+ zint this_sys = key.mem[0];
+#else
+ zint this_sys = key.sysno;
+#endif
+ if (this_sys != psysno)
{
(sset->hits)++;
- psysno = key.sysno;
+ psysno = this_sys;
resultSetInsertSort (zh, sset,
sort_criteria, num_criteria, psysno);
}
if (rset_read (rset, rfd, &key, &term_index))
{
- int psysno = key.sysno;
+#if IT_KEY_NEW
+ zint psysno = key.mem[0];
+#else
+ zint psysno = key.sysno;
+#endif
int score;
void *handle =
(*rc->begin) (zh->reg, rank_class->class_handle, rset);
(zebraSet->hits)++;
do
{
+#if IT_KEY_NEW
+ zint this_sys = key.mem[0];
+#else
+ zint this_sys = key.sysno;
+#endif
kno++;
- if (key.sysno != psysno)
+ if (this_sys != psysno)
{
score = (*rc->calc) (handle, psysno);
resultSetInsertRank (zh, sort_info, psysno, score, 'A');
(zebraSet->hits)++;
- psysno = key.sysno;
+ psysno = this_sys;
}
- (*rc->add) (handle, key.seqno, term_index);
+ (*rc->add) (handle, this_sys, term_index);
}
while (rset_read (rset, rfd, &key, &term_index));
score = (*rc->calc) (handle, psysno);
-/* $Id: zvrank.c,v 1.7 2004-06-13 18:44:57 adam Exp $
+/* $Id: zvrank.c,v 1.8 2004-08-04 08:35:24 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
* score should be between 0 and 1000. If score cannot be obtained
* -1 should be returned.
*/
-static int zv_calc (void *rsi, int sysno)
+static int zv_calc (void *rsi, zint sysno)
{
int i, veclen;
int score=0;
dscore=rs->sim_fct(rs->qdoc, rs->rdoc);
}
score = dscore * 1000;
- yaz_log (LOG_LOG, "sysno=%d score=%d", sysno, score);
+ yaz_log (LOG_LOG, "sysno=" ZINT_FORMAT " score=%d", sysno, score);
if (score > 1000) /* should not happen */
score = 1000;
return score;
-/* $Id: isamb.c,v 1.47 2004-08-03 14:54:41 heikki Exp $
+/* $Id: isamb.c,v 1.48 2004-08-04 08:35:24 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#endif
struct ISAMB_head {
- int first_block;
- int last_block;
+ zint first_block;
+ zint last_block;
int block_size;
int block_max;
- int free_list;
+ zint free_list;
};
#define ISAMB_DATA_OFFSET 3
#define CAT_NO 4
/* ISAMB_PTR_CODEC=1 var, =0 fixed */
-#define ISAMB_PTR_CODEC 0
+#define ISAMB_PTR_CODEC 0
struct ISAMB_cache_entry {
ISAMB_P pos;
#if ISAMB_PTR_CODEC
-static void encode_ptr (char **dst, unsigned pos)
+static void encode_ptr (char **dst, zint pos)
{
unsigned char *bp = (unsigned char*) *dst;
*dst = (char *) bp;
}
#else
-static void encode_ptr (char **dst, unsigned pos)
+static void encode_ptr (char **dst, zint pos)
{
memcpy(*dst, &pos, sizeof(pos));
(*dst) += sizeof(pos);
#endif
#if ISAMB_PTR_CODEC
-static void decode_ptr (char **src1, int *pos)
+static void decode_ptr (const char **src1, zint *pos)
{
- unsigned char **src = (unsigned char **) src1;
- unsigned d = 0;
+ const unsigned char **src = (const unsigned char **) src1;
+ zint d = 0;
unsigned char c;
unsigned r = 0;
while (((c = *(*src)++) & 128))
{
- d += ((c & 127) << r);
+ d += ((zint) (c & 127) << r);
r += 7;
}
- d += (c << r);
+ d += ((zint) c << r);
*pos = d;
}
#else
-static void decode_ptr (char **src, int *pos)
+static void decode_ptr (const char **src, zint *pos)
{
memcpy (pos, *src, sizeof(*pos));
(*src) += sizeof(*pos);
p->size = (p->buf[1] + 256 * p->buf[2]) - ISAMB_DATA_OFFSET;
if (p->size < 0)
{
- yaz_log (LOG_FATAL, "Bad block size %d in pos=%d\n", p->size, pos);
+ yaz_log (LOG_FATAL, "Bad block size %d in pos=" ZINT_FORMAT "\n",
+ p->size, pos);
}
assert (p->size >= 0);
p->offset = 0;
p->dirty = 0;
p->deleted = 0;
- p->decodeClientData = (*b->method->code_start)(ISAMC_DECODE);
- yaz_log (LOG_DEBUG, "isamb_open_block: Opened block %d ofs=%d",pos, p->offset);
+ p->decodeClientData = (*b->method->codec.start)();
+ yaz_log (LOG_DEBUG, "isamb_open_block: Opened block " ZINT_FORMAT " ofs=%d",pos, p->offset);
return p;
}
abort ();
}
}
- yaz_log (b->log_freelist, "got block %d from freelist %d:%d", p->pos,
+ yaz_log (b->log_freelist, "got block " ZINT_FORMAT " from freelist %d:" ZINT_FORMAT, p->pos,
cat, p->pos/CAT_MAX);
memcpy (&b->file[cat].head.free_list, p->buf, sizeof(int));
}
p->dirty = 1;
p->deleted = 0;
p->offset = 0;
- p->decodeClientData = (*b->method->code_start)(ISAMC_DECODE);
+ p->decodeClientData = (*b->method->codec.start)();
return p;
}
{
/* sanity check */
char *startp = p->bytes;
- char *src = startp;
+ const char *src = startp;
char *endp = p->bytes + p->size;
- int pos;
+ ISAMB_P pos;
decode_ptr (&src, &pos);
assert ((pos&CAT_MASK) == p->cat);
while (src != endp)
{
- int item_len;
+ zint item_len;
decode_ptr (&src, &item_len);
- assert (item_len > 0 && item_len < 30);
+ assert (item_len > 0 && item_len < 80);
src += item_len;
decode_ptr (&src, &pos);
assert ((pos&CAT_MASK) == p->cat);
return;
if (p->deleted)
{
- yaz_log (b->log_freelist, "release block %d from freelist %d:%d",
+ yaz_log (b->log_freelist, "release block " ZINT_FORMAT " from freelist %d:" ZINT_FORMAT,
p->pos, p->cat, p->pos/CAT_MAX);
memcpy (p->buf, &b->file[p->cat].head.free_list, sizeof(int));
b->file[p->cat].head.free_list = p->pos;
bf_write (b->file[p->cat].bf, p->pos/CAT_MAX, 0, 0, p->buf);
}
}
- (*b->method->code_stop)(ISAMC_DECODE, p->decodeClientData);
+ (*b->method->codec.stop)(p->decodeClientData);
xfree (p->buf);
xfree (p);
}
ISAMC_I *stream,
struct ISAMB_block **sp,
void *sub_item, int *sub_size,
- void *max_item);
+ const void *max_item);
int insert_int (ISAMB b, struct ISAMB_block *p, void *lookahead_item,
int *mode,
ISAMC_I *stream, struct ISAMB_block **sp,
- void *split_item, int *split_size, void *last_max_item)
+ void *split_item, int *split_size, const void *last_max_item)
{
char *startp = p->bytes;
- char *src = startp;
+ const char *src = startp;
char *endp = p->bytes + p->size;
- int pos;
+ ISAMB_P pos;
struct ISAMB_block *sub_p1 = 0, *sub_p2 = 0;
char sub_item[DST_ITEM_MAX];
int sub_size;
decode_ptr (&src, &pos);
while (src != endp)
{
- int item_len;
+ zint item_len;
int d;
- char *src0 = src;
+ const char *src0 = src;
decode_ptr (&src, &item_len);
d = (*b->method->compare_item)(src, lookahead_item);
if (d > 0)
char dst_buf[DST_BUF_SIZE];
char *dst = dst_buf;
- assert (sub_size < 30 && sub_size > 1);
+ assert (sub_size < 80 && sub_size > 1);
memcpy (dst, startp, src - startp);
}
else
{
+ zint split_size_tmp;
int p_new_size;
- char *half;
+ const char *half;
src = dst_buf;
endp = dst;
decode_ptr (&src, &pos);
while (src <= half)
{
- decode_ptr (&src, split_size);
+ decode_ptr (&src, &split_size_tmp);
+ *split_size = split_size_tmp;
+
src += *split_size;
decode_ptr (&src, &pos);
}
p_new_size = src - dst_buf;
memcpy (p->bytes, dst_buf, p_new_size);
- decode_ptr (&src, split_size);
+ decode_ptr (&src, &split_size_tmp);
+ *split_size = split_size_tmp;
memcpy (split_item, src, *split_size);
src += *split_size;
return more;
}
-
int insert_leaf (ISAMB b, struct ISAMB_block **sp1, void *lookahead_item,
int *lookahead_mode, ISAMC_I *stream,
struct ISAMB_block **sp2,
void *sub_item, int *sub_size,
- void *max_item)
+ const void *max_item)
{
struct ISAMB_block *p = *sp1;
- char *src = 0, *endp = 0;
+ char *endp = 0;
+ const char *src = 0;
char dst_buf[DST_BUF_SIZE], *dst = dst_buf;
int new_size;
- void *c1 = (*b->method->code_start)(ISAMC_DECODE);
- void *c2 = (*b->method->code_start)(ISAMC_ENCODE);
+ void *c1 = (*b->method->codec.start)();
+ void *c2 = (*b->method->codec.start)();
int more = 1;
int quater = b->file[b->no_cat-1].head.block_max / CAT_MAX;
char *cut = dst_buf + quater * 2;
src = p->bytes;
endp = p->bytes + p->size;
- (*b->method->code_item)(ISAMC_DECODE, c1, &file_item, &src);
+ (*b->method->codec.decode)(c1, &file_item, &src);
while (1)
{
- char *dst_item = 0;
+ const char *dst_item = 0;
char *dst_0 = dst;
char *lookahead_next;
int d = -1;
}
else if (!half1 && dst > cut)
{
- char *dst_item_0 = dst_item;
+ const char *dst_item_0 = dst_item;
half1 = dst; /* candidate for splitting */
- (*b->method->code_item)(ISAMC_ENCODE, c2, &dst, &dst_item);
+ (*b->method->codec.encode)(c2, &dst, &dst_item);
cut_item_size = dst_item - dst_item_0;
+ assert(cut_item_size > 0);
memcpy (cut_item_buf, dst_item_0, cut_item_size);
half2 = dst;
}
else
- (*b->method->code_item)(ISAMC_ENCODE, c2, &dst, &dst_item);
+ (*b->method->codec.encode)(c2, &dst, &dst_item);
if (d > 0)
{
if (dst > maxp)
if (src == endp)
break;
file_item = file_item_buf;
- (*b->method->code_item)(ISAMC_DECODE, c1, &file_item, &src);
+ (*b->method->codec.decode)(c1, &file_item, &src);
}
else
{
if (src == endp)
break;
file_item = file_item_buf;
- (*b->method->code_item)(ISAMC_DECODE, c1, &file_item, &src);
+ (*b->method->codec.decode)(c1, &file_item, &src);
}
}
}
maxp = dst_buf + b->file[b->no_cat-1].head.block_max + quater;
while (lookahead_item)
{
- char *dst_item = lookahead_item;
+ char *dst_item;
+ const char *src = lookahead_item;
char *dst_0 = dst;
if (max_item &&
}
else if (!half1 && dst > cut)
{
- char *dst_item_0 = dst_item;
+ const char *src_0 = src;
half1 = dst; /* candidate for splitting */
- (*b->method->code_item)(ISAMC_ENCODE, c2, &dst, &dst_item);
+ (*b->method->codec.encode)(c2, &dst, &src);
- cut_item_size = dst_item - dst_item_0;
- memcpy (cut_item_buf, dst_item_0, cut_item_size);
+ cut_item_size = src - src_0;
+ assert(cut_item_size > 0);
+ memcpy (cut_item_buf, src_0, cut_item_size);
half2 = dst;
}
else
- (*b->method->code_item)(ISAMC_ENCODE, c2, &dst, &dst_item);
+ (*b->method->codec.encode)(c2, &dst, &src);
if (dst > maxp)
{
if (new_size > b->file[p->cat].head.block_max)
{
char *first_dst;
- char *cut_item = cut_item_buf;
+ const char *cut_item = cut_item_buf;
assert (half1);
assert (half2);
- /* first half */
+ assert(cut_item_size > 0);
+
+ /* first half */
p->size = half1 - dst_buf;
memcpy (p->bytes, dst_buf, half1 - dst_buf);
/* second half */
*sp2 = new_leaf (b, p->cat);
- (*b->method->code_reset)(c2);
+ (*b->method->codec.reset)(c2);
first_dst = (*sp2)->bytes;
- (*b->method->code_item)(ISAMC_ENCODE, c2, &first_dst, &cut_item);
+ (*b->method->codec.encode)(c2, &first_dst, &cut_item);
memcpy (first_dst, half2, dst - half2);
memcpy (p->bytes, dst_buf, dst - dst_buf);
p->size = new_size;
}
- (*b->method->code_stop)(ISAMC_DECODE, c1);
- (*b->method->code_stop)(ISAMC_ENCODE, c2);
+ (*b->method->codec.stop)(c1);
+ (*b->method->codec.stop)(c2);
*sp1 = p;
return more;
}
ISAMC_I *stream,
struct ISAMB_block **sp,
void *sub_item, int *sub_size,
- void *max_item)
+ const void *max_item)
{
if (!*p || (*p)->leaf)
return insert_leaf (b, p, new_item, mode, stream, sp, sub_item,
p1->deleted = 1;
if (!p1->leaf)
{
- int sub_p;
- int item_len;
- char *src = p1->bytes + p1->offset;
+ zint sub_p;
+ zint item_len;
+ const char *src = p1->bytes + p1->offset;
decode_ptr(&src, &sub_p);
isamb_unlink(b, sub_p);
return 0;
}
-int isamb_merge (ISAMB b, ISAMC_P pos, ISAMC_I *stream)
+ISAMB_P isamb_merge (ISAMB b, ISAMC_P pos, ISAMC_I *stream)
{
char item_buf[DST_ITEM_MAX];
char *item_ptr;
char *dst = p2->bytes + p2->size;
encode_ptr (&dst, p->pos);
- assert (sub_size < 20);
+ assert (sub_size < 40);
encode_ptr (&dst, sub_size);
memcpy (dst, sub_item, sub_size);
dst += sub_size;
while (1)
{
struct ISAMB_block *p = open_block (isamb, pos);
- char *src = p->bytes + p->offset;
+ const char *src = p->bytes + p->offset;
pp->block[pp->level] = p;
pp->total_size += p->size;
if (pos)
{
struct ISAMB_block *p = open_block (b, pos);
- sprintf(prefix_str, "%*s %d cat=%d size=%d max=%d", level*2, "",
+ sprintf(prefix_str, "%*s " ZINT_FORMAT " cat=%d size=%d max=%d", level*2, "",
pos, p->cat, p->size, b->file[p->cat].head.block_max);
(*pr)(prefix_str);
- sprintf(prefix_str, "%*s %d", level*2, "", pos);
+ sprintf(prefix_str, "%*s " ZINT_FORMAT, level*2, "", pos);
if (p->leaf)
{
while (p->offset < p->size)
{
- char *src = p->bytes + p->offset;
+ const char *src = p->bytes + p->offset;
char *dst = buf;
- (*b->method->code_item)(ISAMC_DECODE, p->decodeClientData,
- &dst, &src);
+ (*b->method->codec.decode)(p->decodeClientData, &dst, &src);
(*b->method->log_item)(LOG_DEBUG, buf, prefix_str);
p->offset = src - (char*) p->bytes;
}
}
else
{
- char *src = p->bytes + p->offset;
- int sub;
- int item_len;
+ const char *src = p->bytes + p->offset;
+ ISAMB_P sub;
+ zint item_len;
decode_ptr (&src, &sub);
p->offset = src - (char*) p->bytes;
assert (p->offset < p->size);
assert (p->leaf);
src = p->bytes + p->offset;
- (*pp->isamb->method->code_item)(ISAMC_DECODE, p->decodeClientData,
+ (*pp->isamb->method->codec.code_item)(ISAMC_DECODE, p->decodeClientData,
&dst, &src);
p->offset = src - (char*) p->bytes;
/* key_logdump_txt(LOG_DEBUG,buf, "isamb_pp_read returning 1"); */
#else
int isamb_pp_read (ISAMB_PP pp, void *buf)
{
- return isamb_pp_forward(pp,buf,0);
+ return isamb_pp_forward(pp, buf, 0);
}
#endif
/* call with pp->level to begin with */
struct ISAMB_block *p;
int cmp;
- char *src;
- int item_len;
+ const char *src;
+ zint item_len;
assert(level>=0);
if ( level == 0) {
#if ISAMB_DEBUG
{
assert(p->offset>0);
src=p->bytes + p->offset;
- decode_ptr(&src,&item_len);
+ decode_ptr(&src, &item_len);
#if ISAMB_DEBUG
- (*pp->isamb->method->log_item)(LOG_DEBUG,untilbuf,"on_leaf: until");
- (*pp->isamb->method->log_item)(LOG_DEBUG,src,"on_leaf: value");
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG,untilbuf,"on_leaf: until");
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG,src,"on_leaf: value");
#endif
cmp=(*pp->isamb->method->compare_item)(untilbuf,src);
if (cmp<2) {
{ /* reads the next item on the current leaf, returns 0 if end of leaf*/
struct ISAMB_block *p = pp->block[pp->level];
char *dst;
- char *src;
+ const char *src;
assert(pp);
assert(buf);
if (p->offset == p->size) {
}
src=p->bytes + p->offset;
dst=buf;
- (*pp->isamb->method->code_item)
- (ISAMC_DECODE, p->decodeClientData,&dst, &src);
+ (*pp->isamb->method->codec.decode)(p->decodeClientData,&dst, &src);
p->offset = src - (char*) p->bytes;
/*
#if ISAMB_DEBUG
- (*pp->isamb->method->log_item)(LOG_DEBUG, buf, "read_on_leaf returning 1");
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG, buf, "read_on_leaf returning 1");
#endif
*/
return 1;
}
} /* forward_on_leaf */
-static int isamb_pp_climb_level(ISAMB_PP pp, int *pos)
+static int isamb_pp_climb_level(ISAMB_PP pp, ISAMB_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];
- char *src;
- int item_len;
+ const char *src;
+ zint item_len;
#if ISAMB_DEBUG
logf(LOG_DEBUG,"isamb_pp_climb_level starting "
"at level %d node %d ofs=%d sz=%d",
/* parent node, but that gets messy. Presumably the cost is */
/* pretty low anyway */
struct ISAMB_block *p = pp->block[pp->level];
- char *src=p->bytes + p->offset;
- int item_len;
+ const char *src=p->bytes + p->offset;
+ zint item_len;
int cmp;
- int nxtpos;
+ zint nxtpos;
#if ISAMB_DEBUG
int skips=0;
logf(LOG_DEBUG,"isamb_pp_forward_unode starting "
} /* forward_unode */
-static void isamb_pp_descend_to_leaf(ISAMB_PP pp, int pos, const void *untilbuf)
+static void isamb_pp_descend_to_leaf(ISAMB_PP pp, ISAMB_P pos, const void *untilbuf)
{ /* climbs down the tree, from pos, to the leftmost leaf */
struct ISAMB_block *p = pp->block[pp->level];
- char *src;
+ const char *src;
assert(!p->leaf);
#if ISAMB_DEBUG
logf(LOG_DEBUG,"isamb_pp_descend_to_leaf "
static int isamb_pp_find_next_leaf(ISAMB_PP pp)
{ /* finds the next leaf by climbing up and down */
- int pos;
+ ISAMB_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, void *buf, const void *untilbuf)
{ /* climbs up and descends to a leaf where values >= *untilbuf are found */
- int pos;
+ ISAMB_P pos;
#if ISAMB_DEBUG
struct ISAMB_block *p = pp->block[pp->level];
logf(LOG_DEBUG,"isamb_pp_climb_desc starting "
* in the node just read.
*/
char *dst = buf;
- char *src;
+ const char *src;
struct ISAMB_block *p = pp->block[pp->level];
int cmp;
int item_len;
#if ISAMB_DEBUG
logf(LOG_DEBUG,"isamb_pp_forward starting [%p] p=%d",pp,p->pos);
- (*pp->isamb->method->log_item)(LOG_DEBUG, untilbuf, "until");
- (*pp->isamb->method->log_item)(LOG_DEBUG, buf, "buf");
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG, untilbuf, "until");
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG, buf, "buf");
#endif
while (1)
src = p->bytes + p->offset;
decode_ptr(&src, &item_len);
#if ISAMB_DEBUG
- (*pp->isamb->method->log_item)(LOG_DEBUG, src,
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG, src,
" isamb_pp_forward "
"climb skipping old key");
#endif
logf(LOG_DEBUG,"isamb_pp_forward (B) on a high node. "
"ofs=%d sz=%d nxtpos=%d ",
p->offset,p->size,pos);
- (*pp->isamb->method->log_item)(LOG_DEBUG, src, "");
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG, src, "");
#endif
if (untilbuf)
cmp=(*pp->isamb->method->compare_item)(untilbuf,src);
assert (p->offset < p->size);
src = p->bytes + p->offset;
dst=buf;
- (*pp->isamb->method->code_item)(ISAMC_DECODE, p->decodeClientData,
+ (*pp->isamb->method->codec.decode)(p->decodeClientData,
&dst, &src);
p->offset = src - (char*) p->bytes;
if (untilbuf)
#if ISAMB_DEBUG
logf(LOG_DEBUG,"isamb_pp_forward on a leaf. cmp=%d",
cmp);
- (*pp->isamb->method->log_item)(LOG_DEBUG, buf, "");
+ (*pp->isamb->method->codec.log_item)(LOG_DEBUG, buf, "");
#endif
if (cmp <2)
{
#if ISAMB_DEBUG
if (untilbuf)
{
- (*pp->isamb->method->log_item)(
+ (*pp->isamb->method->codec.log_item)(
LOG_DEBUG, buf, "isamb_pp_forward returning 1");
}
else
{
- (*pp->isamb->method->log_item)(
+ (*pp->isamb->method->codec.log_item)(
LOG_DEBUG, buf, "isamb_pp_read returning 1 (fwd)");
}
#endif
int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilb)
{
char *dst = buf;
- char *src;
+ const char *src;
struct ISAMB_block *p = pp->block[pp->level];
if (!p)
return 0;
{
char *dst0 = dst;
src = p->bytes + p->offset;
- (*pp->isamb->method->code_item)(ISAMC_DECODE, p->decodeClientData,
- &dst, &src);
+ (*pp->isamb->method->codec.decode)(p->decodeClientData, &dst, &src);
p->offset = src - (char*) p->bytes;
if (!untilb || (*pp->isamb->method->compare_item)(untilb, dst0) <= 1)
break;
int *current, int *total, void *dummybuf )
{
struct ISAMB_block *p = pp->block[pp->level];
- char *src=p->bytes;
+ const char *src=p->bytes;
char *end=p->bytes+p->size;
char *cur=p->bytes+p->offset;
char *dst;
while(src < end) {
dst=dummybuf;
- (*pp->isamb->method->code_item)
- (ISAMC_DECODE, p->decodeClientData,&dst, &src);
+ (*pp->isamb->method->codec.decode)(p->decodeClientData,&dst, &src);
assert(dst<(char*) dummybuf+100); /*FIXME */
(*total)++;
if (src<=cur)
int size, int level )
{ /* estimates total/current occurrences from here up, excl leaf */
struct ISAMB_block *p = pp->block[level];
- char *src=p->bytes;
+ const char *src=p->bytes;
char *end=p->bytes+p->size;
char *cur=p->bytes+p->offset;
- int item_size;
- int child;
+ zint item_size;
+ ISAMB_P child;
assert(level>=0);
assert(!p->leaf);
logf(LOG_DEBUG,"isamb_pp_upper_pos at beginning l=%d "
- "cur=%d tot=%d ofs=%d sz=%d pos=%d",
+ "cur=%d tot=%d ofs=%d sz=%d pos=" ZINT_FORMAT,
level, *current, *total, p->offset, p->size, p->pos);
assert (p->offset <= p->size);
- decode_ptr (&src, &child ); /* first child */
+ decode_ptr (&src, &child ); /* first child */
while(src < end) {
if (src!=cur) {
*total += size;
if (src < cur)
*current +=size;
}
- decode_ptr (&src, &item_size );
+ decode_ptr (&src, &item_size );
assert(src+item_size<=end);
src += item_size;
decode_ptr (&src, &child );
-/* $Id: tstisamb.c,v 1.7 2004-08-03 14:54:41 heikki Exp $
+/* $Id: tstisamb.c,v 1.8 2004-08-04 08:35:24 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
return ia - ib;
}
-void *code_start(int mode)
+void *code_start()
{
return 0;
}
-void code_item(int mode, void *p, char **dst, char **src)
+void code_item(void *p, char **dst, const char **src)
{
memcpy (*dst, *src, sizeof(int));
(*dst) += sizeof(int);
void code_reset(void *p)
{
}
-void code_stop(int mode, void *p)
+void code_stop(void *p)
{
}
/* setup method (attributes) */
method.compare_item = compare_item;
method.log_item = log_item;
- method.code_start = code_start;
- method.code_item = code_item;
- method.code_reset = code_reset;
- method.code_stop = code_stop;
+ method.codec.start = code_start;
+ method.codec.encode = code_item;
+ method.codec.decode = code_item;
+ method.codec.reset = code_reset;
+ method.codec.stop = code_stop;
/* create block system */
bfs = bfs_create(0, 0);
-## $Id: Makefile.am,v 1.4 2004-06-16 20:49:18 adam Exp $
+## $Id: Makefile.am,v 1.5 2004-08-04 08:35:24 adam Exp $
noinst_LIBRARIES = libisamc.a
-libisamc_a_SOURCES = isamc.c isamd.c merge.c merge-d.c isamc-p.h isamd-p.h
+libisamc_a_SOURCES = isamc.c merge.c isamc-p.h
AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../index $(YAZINC)
-/* $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
+/* $Id: isamc-p.h,v 1.10 2004-08-04 08:35:24 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
#include <bfile.h>
#include <isamc.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+YAZ_BEGIN_CDECL
typedef struct {
- int lastblock;
- int freelist;
+ zint lastblock;
+ zint freelist;
} ISAMC_head;
typedef unsigned ISAMC_BLOCK_SIZE;
ISAMC_BLOCK_SIZE offset;
ISAMC_BLOCK_SIZE size;
int cat;
- int pos;
- int next;
+ zint pos;
+ zint next;
ISAMC is;
void *decodeClientData;
int deleteFlag;
- int numKeys;
+ zint numKeys;
};
-#define ISAMC_BLOCK_OFFSET_N (sizeof(int)+sizeof(ISAMC_BLOCK_SIZE))
-#define ISAMC_BLOCK_OFFSET_1 (sizeof(int)+sizeof(ISAMC_BLOCK_SIZE)+sizeof(int))
-int isc_alloc_block (ISAMC is, int cat);
-void isc_release_block (ISAMC is, int cat, int pos);
-int isc_read_block (ISAMC is, int cat, int pos, char *dst);
-int isc_write_block (ISAMC is, int cat, int pos, char *src);
+/*
+ first block consists of
+ next pointer : zint
+ size : ISAMC_BLOCK_SIZE (int)
+ numkeys : zint
+ data
+ other blocks consists of
+ next pointer : zint
+ size : ISAMC_BLOCK_SIZE (int)
+ data
+*/
+#define ISAMC_BLOCK_OFFSET_1 (sizeof(zint)+sizeof(ISAMC_BLOCK_SIZE)+sizeof(zint))
+#define ISAMC_BLOCK_OFFSET_N (sizeof(zint)+sizeof(ISAMC_BLOCK_SIZE))
+
+zint isc_alloc_block (ISAMC is, int cat);
+void isc_release_block (ISAMC is, int cat, zint pos);
+int isc_read_block (ISAMC is, int cat, zint pos, char *dst);
+int isc_write_block (ISAMC is, int cat, zint pos, char *src);
+
+YAZ_END_CDECL
-#ifdef __cplusplus
-}
-#endif
-/* $Id: isamc.c,v 1.24 2004-06-01 12:56:39 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: isamc.c,v 1.25 2004-08-04 08:35:24 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
/*
* TODO:
* Reduction to lower categories in isc_merge
static void release_fc (ISAMC is, int cat);
static void init_fc (ISAMC is, int cat);
-#define ISAMC_FREELIST_CHUNK 1
+#define ISAMC_FREELIST_CHUNK 0
#define SMALL_TEST 0
{ 32, 28, 0, 3 },
{ 64, 54, 30, 0 },
#else
- { 32, 26, 20, 10 },
+ { 64, 56, 40, 5 },
{ 128, 120, 100, 10 },
{ 512, 490, 350, 10 },
{ 2048, 1900, 1700, 10 },
};
m->filecat = def_cat;
- m->code_start = NULL;
- m->code_item = NULL;
- m->code_stop = NULL;
- m->code_reset = NULL;
+ m->codec.start = NULL;
+ m->codec.decode = NULL;
+ m->codec.encode = NULL;
+ m->codec.stop = NULL;
+ m->codec.reset = NULL;
m->compare_item = NULL;
m->log_item = NULL;
}
is->files[i].alloc_entries_num = 0;
is->files[i].alloc_entries_max =
- is->method->filecat[i].bsize / sizeof(int) - 1;
+ is->method->filecat[i].bsize / sizeof(zint) - 1;
is->files[i].alloc_buf = (char *)
xmalloc (is->method->filecat[i].bsize);
is->files[i].no_writes = 0;
return is;
}
-int isc_block_used (ISAMC is, int type)
+zint isc_block_used (ISAMC is, int type)
{
if (type < 0 || type >= is->no_files)
return -1;
return 0;
}
-int isc_read_block (ISAMC is, int cat, int pos, char *dst)
+int isc_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, int pos, char *src)
+int isc_write_block (ISAMC is, int cat, zint pos, char *src)
{
++(is->files[cat].no_writes);
if (is->method->debug > 2)
- logf (LOG_LOG, "isc: write_block %d %d", cat, pos);
+ logf (LOG_LOG, "isc: write_block %d " ZINT_FORMAT, cat, pos);
return bf_write (is->files[cat].bf, pos, 0, 0, src);
}
-int isc_write_dblock (ISAMC is, int cat, int pos, char *src,
- int nextpos, int offset)
+int isc_write_dblock (ISAMC is, int cat, zint pos, char *src,
+ zint nextpos, int offset)
{
ISAMC_BLOCK_SIZE size = offset + ISAMC_BLOCK_OFFSET_N;
if (is->method->debug > 2)
- logf (LOG_LOG, "isc: write_dblock. size=%d nextpos=%d",
+ logf (LOG_LOG, "isc: write_dblock. size=%d nextpos=" ZINT_FORMAT,
(int) size, nextpos);
src -= ISAMC_BLOCK_OFFSET_N;
- memcpy (src, &nextpos, sizeof(int));
- memcpy (src + sizeof(int), &size, sizeof(size));
+ memcpy (src, &nextpos, sizeof(nextpos));
+ memcpy (src + sizeof(nextpos), &size, sizeof(size));
return isc_write_block (is, cat, pos, src);
}
static void flush_block (ISAMC is, int cat)
{
char *abuf = is->files[cat].alloc_buf;
- int block = is->files[cat].head.freelist;
+ zint block = is->files[cat].head.freelist;
if (block && is->files[cat].alloc_entries_num)
{
- memcpy (abuf, &is->files[cat].alloc_entries_num, sizeof(int));
+ memcpy (abuf, &is->files[cat].alloc_entries_num, sizeof(block));
bf_write (is->files[cat].bf, block, 0, 0, abuf);
is->files[cat].alloc_entries_num = 0;
}
xfree (abuf);
}
-static int alloc_block (ISAMC is, int cat)
+static zint alloc_block (ISAMC is, int cat)
{
- int block = is->files[cat].head.freelist;
+ zint block = is->files[cat].head.freelist;
char *abuf = is->files[cat].alloc_buf;
(is->files[cat].no_allocated)++;
if (!is->files[cat].alloc_entries_num) /* last one in block? */
{
memcpy (&is->files[cat].head.freelist, abuf + sizeof(int),
- sizeof(int));
+ sizeof(zint));
is->files[cat].head_is_dirty = 1;
if (is->files[cat].head.freelist)
}
}
else
- memcpy (&block, abuf + sizeof(int) + sizeof(int) *
- is->files[cat].alloc_entries_num, sizeof(int));
+ memcpy (&block, abuf + sizeof(zint) + sizeof(int) *
+ is->files[cat].alloc_entries_num, sizeof(zint));
}
return block;
}
-static void release_block (ISAMC is, int cat, int pos)
+static void release_block (ISAMC is, int cat, zint pos)
{
char *abuf = is->files[cat].alloc_buf;
- int block = is->files[cat].head.freelist;
+ zint block = is->files[cat].head.freelist;
(is->files[cat].no_released)++;
}
if (!is->files[cat].alloc_entries_num) /* make new buffer? */
{
- memcpy (abuf + sizeof(int), &block, sizeof(int));
+ memcpy (abuf + sizeof(int), &block, sizeof(zint));
is->files[cat].head.freelist = pos;
is->files[cat].head_is_dirty = 1;
}
else
{
memcpy (abuf + sizeof(int) +
- is->files[cat].alloc_entries_num*sizeof(int),
- &pos, sizeof(int));
+ is->files[cat].alloc_entries_num*sizeof(zint),
+ &pos, sizeof(zint));
}
is->files[cat].alloc_entries_num++;
}
xfree (abuf);
}
-static int alloc_block (ISAMC is, int cat)
+static zint alloc_block (ISAMC is, int cat)
{
- int block;
- char buf[sizeof(int)];
+ zint block;
+ char buf[sizeof(zint)];
is->files[cat].head_is_dirty = 1;
(is->files[cat].no_allocated)++;
if ((block = is->files[cat].head.freelist))
{
- bf_read (is->files[cat].bf, block, 0, sizeof(int), buf);
- memcpy (&is->files[cat].head.freelist, buf, sizeof(int));
+ bf_read (is->files[cat].bf, block, 0, sizeof(zint), buf);
+ memcpy (&is->files[cat].head.freelist, buf, sizeof(zint));
}
else
block = (is->files[cat].head.lastblock)++;
return block;
}
-static void release_block (ISAMC is, int cat, int pos)
+static void release_block (ISAMC is, int cat, zint pos)
{
- char buf[sizeof(int)];
+ char buf[sizeof(zint)];
(is->files[cat].no_released)++;
is->files[cat].head_is_dirty = 1;
- memcpy (buf, &is->files[cat].head.freelist, sizeof(int));
+ memcpy (buf, &is->files[cat].head.freelist, sizeof(zint));
is->files[cat].head.freelist = pos;
- bf_write (is->files[cat].bf, pos, 0, sizeof(int), buf);
+ bf_write (is->files[cat].bf, pos, 0, sizeof(zint), buf);
}
#endif
-int isc_alloc_block (ISAMC is, int cat)
+zint isc_alloc_block (ISAMC is, int cat)
{
- int block = 0;
+ zint block = 0;
if (is->files[cat].fc_list)
{
- int j, nb;
+ int j;
+ zint nb;
for (j = 0; j < is->files[cat].fc_max; j++)
if ((nb = is->files[cat].fc_list[j]) && (!block || nb < block))
{
if (!block)
block = alloc_block (is, cat);
if (is->method->debug > 3)
- logf (LOG_LOG, "isc: alloc_block in cat %d: %d", cat, block);
+ logf (LOG_LOG, "isc: alloc_block in cat %d: " ZINT_FORMAT, cat, block);
return block;
}
-void isc_release_block (ISAMC is, int cat, int pos)
+void isc_release_block (ISAMC is, int cat, zint pos)
{
if (is->method->debug > 3)
- logf (LOG_LOG, "isc: release_block in cat %d: %d", cat, pos);
+ logf (LOG_LOG, "isc: release_block in cat %d:" ZINT_FORMAT, cat, pos);
if (is->files[cat].fc_list)
{
int j;
{
ISAMC is = pp->is;
- (*is->method->code_stop)(ISAMC_DECODE, pp->decodeClientData);
+ (*is->method->codec.stop)(pp->decodeClientData);
xfree (pp->buf);
xfree (pp);
}
pp->size = 0;
pp->offset = 0;
pp->is = is;
- pp->decodeClientData = (*is->method->code_start)(ISAMC_DECODE);
+ pp->decodeClientData = (*is->method->codec.start)();
pp->deleteFlag = 0;
pp->numKeys = 0;
src += sizeof(pp->size);
memcpy (&pp->numKeys, src, sizeof(pp->numKeys));
src += sizeof(pp->numKeys);
- assert (pp->next != pp->pos);
+ if (pp->next == pp->pos)
+ {
+ yaz_log(LOG_FATAL|LOG_LOG, "pp->next = " ZINT_FORMAT, pp->next);
+ yaz_log(LOG_FATAL|LOG_LOG, "pp->pos = " ZINT_FORMAT, pp->pos);
+ assert (pp->next != pp->pos);
+ }
pp->offset = src - pp->buf;
assert (pp->offset == ISAMC_BLOCK_OFFSET_1);
if (is->method->debug > 2)
- logf (LOG_LOG, "isc: read_block size=%d %d %d next=%d",
- pp->size, pp->cat, pp->pos, pp->next);
+ logf (LOG_LOG, "isc: read_block size=%d %d " ZINT_FORMAT " next="
+ ZINT_FORMAT, pp->size, pp->cat, pp->pos, pp->next);
}
return pp;
}
/* returns non-zero if item could be read; 0 otherwise */
int isc_pp_read (ISAMC_PP pp, void *buf)
{
- return isc_read_item (pp, (char **) &buf);
+ char *cp = buf;
+ return isc_read_item (pp, &cp);
}
/* read one item from file - decode and store it in *dst.
int isc_read_item (ISAMC_PP pp, char **dst)
{
ISAMC is = pp->is;
- char *src = pp->buf + pp->offset;
+ const char *src = pp->buf + pp->offset;
if (pp->offset >= pp->size)
{
pp->pos = pp->next;
src = pp->buf;
/* read block and save 'next' and 'size' entry */
- isc_read_block (is, pp->cat, pp->pos, src);
+ isc_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));
src += sizeof(pp->size);
/* assume block is non-empty */
assert (src - pp->buf == ISAMC_BLOCK_OFFSET_N);
- assert (pp->next != pp->pos);
+
+ if (pp->next == pp->pos)
+ {
+ yaz_log(LOG_FATAL|LOG_LOG, "pp->next = " ZINT_FORMAT, pp->next);
+ yaz_log(LOG_FATAL|LOG_LOG, "pp->pos = " ZINT_FORMAT, pp->pos);
+ assert (pp->next != pp->pos);
+ }
+
if (pp->deleteFlag)
isc_release_block (is, pp->cat, pp->pos);
- (*is->method->code_item)(ISAMC_DECODE, pp->decodeClientData, dst, &src);
+ (*is->method->codec.decode)(pp->decodeClientData, dst, &src);
pp->offset = src - pp->buf;
if (is->method->debug > 2)
- logf (LOG_LOG, "isc: read_block size=%d %d %d next=%d",
- pp->size, pp->cat, pp->pos, pp->next);
+ logf (LOG_LOG, "isc: read_block size=%d %d " ZINT_FORMAT " next="
+ ZINT_FORMAT, pp->size, pp->cat, pp->pos, pp->next);
return 2;
}
- (*is->method->code_item)(ISAMC_DECODE, pp->decodeClientData, dst, &src);
+ (*is->method->codec.decode)(pp->decodeClientData, dst, &src);
pp->offset = src - pp->buf;
return 1;
}
-int isc_pp_num (ISAMC_PP pp)
+zint isc_pp_num (ISAMC_PP pp)
{
return pp->numKeys;
}
-/* $Id: merge.c,v 1.23 2003-06-23 15:36:11 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: merge.c,v 1.24 2004-08-04 08:35:24 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
02111-1307, USA.
*/
-
-
#include <stdlib.h>
#include <assert.h>
#include <string.h>
struct isc_merge_block {
int offset; /* offset in r_buf */
- int block; /* block number of file (0 if none) */
+ zint block; /* block number of file (0 if none) */
int dirty; /* block is different from that on file */
};
#endif
static void flush_blocks (ISAMC is, struct isc_merge_block *mb, int ptr,
- char *r_buf, int *firstpos, int cat, int last,
- int *numkeys)
+ char *r_buf, zint *firstpos, int cat, int last,
+ zint *numkeys)
{
int i;
if (!*firstpos)
*firstpos = mb[i].block;
if (is->method->debug > 2)
- logf (LOG_LOG, "isc: skip ptr=%d size=%d %d %d",
+ logf (LOG_LOG, "isc: skip ptr=%d size=%d %d " ZINT_FORMAT,
i, ssize, cat, mb[i].block);
++(is->files[cat].no_skip_writes);
continue;
src = r_buf + mb[i].offset - ISAMC_BLOCK_OFFSET_1;
ssize += ISAMC_BLOCK_OFFSET_1;
- memcpy (src+sizeof(int)+sizeof(ssize), numkeys,
- sizeof(*numkeys));
+ memcpy (src+sizeof(zint)+sizeof(ssize), numkeys, sizeof(*numkeys));
if (is->method->debug > 2)
- logf (LOG_LOG, "isc: flush ptr=%d numk=%d size=%d nextpos=%d",
- i, *numkeys, (int) ssize, mb[i+1].block);
+ logf (LOG_LOG, "isc: flush ptr=%d numk=" ZINT_FORMAT " size=%d nextpos="
+ ZINT_FORMAT, i, *numkeys, (int) ssize, mb[i+1].block);
}
else
{
src = r_buf + mb[i].offset - ISAMC_BLOCK_OFFSET_N;
ssize += ISAMC_BLOCK_OFFSET_N;
if (is->method->debug > 2)
- logf (LOG_LOG, "isc: flush ptr=%d size=%d nextpos=%d",
+ logf (LOG_LOG, "isc: flush ptr=%d size=%d nextpos=" ZINT_FORMAT,
i, (int) ssize, mb[i+1].block);
}
- memcpy (src, &mb[i+1].block, sizeof(int));
- memcpy (src+sizeof(int), &ssize, sizeof(ssize));
+ memcpy (src, &mb[i+1].block, sizeof(zint));
+ memcpy (src+sizeof(zint), &ssize, sizeof(ssize));
isc_write_block (is, cat, mb[i].block, src);
}
}
struct isc_merge_block mb[200];
- int firstpos = 0;
+ zint firstpos = 0;
int cat = 0;
char r_item_buf[128]; /* temporary result output */
char *r_buf; /* block with resulting data */
int ptr = 0; /* pointer */
void *r_clientData; /* encode client data */
int border;
- int numKeys = 0;
+ zint numKeys = 0;
- r_clientData = (*is->method->code_start)(ISAMC_ENCODE);
+ r_clientData = (*is->method->codec.start)();
r_buf = is->merge_buf + 128;
pp = isc_pp_open (is, ipos);
cat = pp->cat;
if (debug > 1)
- logf (LOG_LOG, "isc: isc_merge begin %d %d", cat, pp->pos);
+ logf (LOG_LOG, "isc: isc_merge begin %d " ZINT_FORMAT, cat, pp->pos);
/* read first item from i */
i_item_ptr = i_item;
if (r_item) /* insert resulting item? */
{
char *r_out_ptr = r_buf + r_offset;
+ const char *src = r_item;
int new_offset;
- (*is->method->code_item)(ISAMC_ENCODE, r_clientData,
- &r_out_ptr, &r_item);
+ (*is->method->codec.encode)(r_clientData, &r_out_ptr, &src);
new_offset = r_out_ptr - r_buf;
numKeys++;
if (numKeys != isc_pp_num (pp))
{
if (debug > 2)
- logf (LOG_LOG, "isc: patch num keys firstpos=%d num=%d",
+ logf (LOG_LOG, "isc: patch num keys firstpos=" ZINT_FORMAT " num=" ZINT_FORMAT,
firstpos, numKeys);
bf_write (is->files[cat].bf, firstpos, ISAMC_BLOCK_OFFSET_N,
sizeof(numKeys), &numKeys);
/* flush rest of block(s) in r_buf */
flush_blocks (is, mb, ptr, r_buf, &firstpos, cat, 1, &numKeys);
- (*is->method->code_stop)(ISAMC_ENCODE, r_clientData);
+ (*is->method->codec.stop)(r_clientData);
if (!firstpos)
cat = 0;
if (debug > 1)
- logf (LOG_LOG, "isc: isc_merge return %d %d", cat, firstpos);
+ logf (LOG_LOG, "isc: isc_merge return %d " ZINT_FORMAT, cat, firstpos);
isc_pp_close (pp);
return cat + firstpos * 8;
}
-/*
- * $Log: merge.c,v $
- * 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
- * Towards GPL
- *
- * Revision 1.20 1999/11/30 13:48:04 adam
- * Improved installation. Updated for inclusion of YAZ header files.
- *
- * Revision 1.19 1999/07/14 12:12:07 heikki
- * Large-block isam-h (may not work too well... Abandoning for isam-d)
- *
- * Revision 1.17 1999/07/13 14:22:17 heikki
- * Better allocation strategy in isamh_merge
- *
- * Revision 1.16 1999/07/08 14:23:27 heikki
- * Fixed a bug in isamh_pp_read and cleaned up a bit
- *
- * Revision 1.15 1999/07/07 09:36:04 heikki
- * Fixed an assertion in isamh
- *
- * Revision 1.13 1999/07/06 09:37:05 heikki
- * Working on isamh - not ready yet.
- *
- * Revision 1.12 1999/06/30 15:03:55 heikki
- * first take on isamh, the append-only isam structure
- *
- * Revision 1.11 1999/05/26 07:49:14 adam
- * C++ compilation.
- *
- * Revision 1.10 1998/03/19 12:22:09 adam
- * Minor change.
- *
- * Revision 1.9 1998/03/19 10:04:38 adam
- * Minor changes.
- *
- * Revision 1.8 1998/03/18 09:23:55 adam
- * Blocks are stored in chunks on free list - up to factor 2 in speed.
- * Fixed bug that could occur in block category rearrangemen.
- *
- * Revision 1.7 1998/03/11 11:18:18 adam
- * Changed the isc_merge to take into account the mfill (minimum-fill).
- *
- * Revision 1.6 1998/03/06 13:54:03 adam
- * Fixed two nasty bugs in isc_merge.
- *
- * Revision 1.5 1997/02/12 20:42:43 adam
- * Bug fix: during isc_merge operations, some pages weren't marked dirty
- * even though they should be. At this point the merge operation marks
- * a page dirty if the previous page changed at all. A better approach is
- * to mark it dirty if the last key written changed in previous page.
- *
- * Revision 1.4 1996/11/08 11:15:31 adam
- * Number of keys in chain are stored in first block and the function
- * to retrieve this information, isc_pp_num is implemented.
- *
- * Revision 1.3 1996/11/04 14:08:59 adam
- * Optimized free block usage.
- *
- * Revision 1.2 1996/11/01 13:36:46 adam
- * New element, max_blocks_mem, that control how many blocks of max size
- * to store in memory during isc_merge.
- * Function isc_merge now ignores delete/update of identical keys and
- * the proper blocks are then non-dirty and not written in flush_blocks.
- *
- * Revision 1.1 1996/11/01 08:59:15 adam
- * First version of isc_merge that supports update/delete.
- *
- */
-
-
-/* $Id: isams.c,v 1.5 2004-06-01 12:56:39 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
+/* $Id: isams.c,v 1.6 2004-08-04 08:35:24 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
void isams_getmethod (ISAMS_M *m)
{
- m->code_start = NULL;
- m->code_item = NULL;
- m->code_stop = NULL;
+ m->codec.start = NULL;
+ m->codec.decode = NULL;
+ m->codec.encode = NULL;
+ m->codec.stop = NULL;
+ m->codec.reset = NULL;
m->compare_item = NULL;
m->log_item = NULL;
ISAMS_P isams_merge (ISAMS is, ISAMS_I data)
{
- char i_item[128], *i_item_ptr;
+ char i_item[128];
int i_more, i_mode;
void *r_clientData;
int first_block = is->head.last_block;
int first_offset = is->head.last_offset;
int count = 0;
- r_clientData = (*is->method->code_start)(ISAMC_ENCODE);
+ r_clientData = (*is->method->codec.start)();
is->head.last_offset += sizeof(int);
if (is->head.last_offset > is->block_size)
}
while (1)
{
- i_item_ptr = i_item;
- i_more = (*data->read_item)(data->clientData, &i_item_ptr, &i_mode);
+ char *tmp_ptr = i_item;
+ i_more = (*data->read_item)(data->clientData, &tmp_ptr, &i_mode);
assert (i_mode);
if (!i_more)
{
char *r_out_ptr = is->merge_buf + is->head.last_offset;
- i_item_ptr = i_item;
- (*is->method->code_item)(ISAMC_ENCODE, r_clientData,
- &r_out_ptr, &i_item_ptr);
+ const char *i_item_ptr = i_item;
+ (*is->method->codec.encode)(r_clientData, &r_out_ptr, &i_item_ptr);
is->head.last_offset = r_out_ptr - is->merge_buf;
if (is->head.last_offset > is->block_size)
{
count++;
}
}
- (*is->method->code_stop)(ISAMC_ENCODE, r_clientData);
+ (*is->method->codec.stop)(r_clientData);
if (first_block == is->head.last_block)
memcpy(is->merge_buf + first_offset, &count, sizeof(int));
else if (first_block == is->head.last_block-1)
if (is->debug > 1)
logf (LOG_LOG, "isams: isams_pp_open pos=%ld", (long) pos);
pp->is = is;
- pp->decodeClientData = (*is->method->code_start)(ISAMC_DECODE);
+ pp->decodeClientData = (*is->method->codec.start)();
pp->numKeys = 0;
pp->numRead = 0;
pp->buf = (char *) xmalloc(is->block_size*2);
void isams_pp_close (ISAMS_PP pp)
{
- (*pp->is->method->code_stop)(ISAMC_DECODE, pp->decodeClientData);
+ (*pp->is->method->codec.stop)(pp->decodeClientData);
xfree(pp->buf);
xfree(pp);
}
int isams_pp_read (ISAMS_PP pp, void *buf)
{
- return isams_read_item (pp, (char **) &buf);
+ char *cp = buf;
+ return isams_read_item (pp, &cp);
}
int isams_read_item (ISAMS_PP pp, char **dst)
{
- char *src;
+ const char *src;
if (pp->numRead >= pp->numKeys)
return 0;
(pp->numRead)++;
pp->buf + pp->is->block_size);
}
src = pp->buf + pp->block_offset;
- (*pp->is->method->code_item)(ISAMC_DECODE, pp->decodeClientData,
- dst, &src);
+ (*pp->is->method->codec.decode)(pp->decodeClientData, dst, &src);
pp->block_offset = src - pp->buf;
return 1;
}
char *errString; /* error string */
int position; /* position of record in result set (1,2,..) */
char *base;
- int sysno;
+ long long sysno;
int score;
char *format; /* record syntax */
RetrievalRecordBuf *buf;
If not, and match_criteria is provided, then sysno is guessed
If not, and a record is provided, then sysno is got from there */
-%apply int *REFERENCE { int *sysno };
+%apply int *REFERENCE { long long *sysno };
%name(insert_record)
int zebra_insert_record (ZebraHandle zh,
const char *recordType,
- int *sysno,
+ long long *sysno,
const char *match,
const char *fname,
const char *buf,
%name(update_record)
int zebra_update_record (ZebraHandle zh,
const char *recordType,
- int *sysno,
+ long long *sysno,
const char *match,
const char *fname,
const char *buf,
%name(delete_record)
int zebra_delete_record (ZebraHandle zh,
const char *recordType,
- int *sysno,
+ long long *sysno,
const char *match,
const char *fname,
const char *buf,
sub NEXTKEY { }
+sub FETCH {
+ my ($self,$field) = @_;
+ my $member_func = "swig_${field}_get";
+ $self->$member_func();
+}
+
+sub STORE {
+ my ($self,$field,$newval) = @_;
+ my $member_func = "swig_${field}_set";
+ $self->$member_func($newval);
+}
+
sub this {
my $ptr = shift;
return tied(%$ptr);
*resultSetTerms = *IDZebrac::resultSetTerms;
*sort = *IDZebrac::sort;
*scan_PQF = *IDZebrac::scan_PQF;
-sub getScanEntry {
- my @args = @_;
- my $result = IDZebrac::getScanEntry(@args);
- return undef if (!defined($result));
- my %resulthash;
- tie %resulthash, ref($result), $result;
- return bless \%resulthash, ref($result);
-}
+*getScanEntry = *IDZebrac::getScanEntry;
*nmem_create = *IDZebrac::nmem_create;
*nmem_destroy = *IDZebrac::nmem_destroy;
*data1_create = *IDZebrac::data1_create;
package IDZebra::RetrievalObj;
@ISA = qw( IDZebra );
%OWNER = ();
-%BLESSEDMEMBERS = (
-);
-
%ITERATORS = ();
*swig_noOfRecords_get = *IDZebrac::RetrievalObj_noOfRecords_get;
*swig_noOfRecords_set = *IDZebrac::RetrievalObj_noOfRecords_set;
*swig_records_set = *IDZebrac::RetrievalObj_records_set;
sub new {
my $pkg = shift;
- my @args = @_;
- my $self = IDZebrac::new_RetrievalObj(@args);
- return undef if (!defined($self));
- $OWNER{$self} = 1;
- my %retval;
- tie %retval, "IDZebra::RetrievalObj", $self;
- return bless \%retval, $pkg;
+ my $self = IDZebrac::new_RetrievalObj(@_);
+ bless $self, $pkg if defined($self);
}
sub DESTROY {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
- };
+}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
- };
-
-sub FETCH {
- my ($self,$field) = @_;
- my $member_func = "swig_${field}_get";
- my $val = $self->$member_func();
- if (exists $BLESSEDMEMBERS{$field}) {
- return undef if (!defined($val));
- my %retval;
- tie %retval,$BLESSEDMEMBERS{$field},$val;
- return bless \%retval, $BLESSEDMEMBERS{$field};
- }
- return $val;
-}
-
-sub STORE {
- my ($self,$field,$newval) = @_;
- my $member_func = "swig_${field}_set";
- if (exists $BLESSEDMEMBERS{$field}) {
- $self->$member_func(tied(%{$newval}));
- } else {
- $self->$member_func($newval);
- }
}
package IDZebra::RetrievalRecord;
@ISA = qw( IDZebra );
%OWNER = ();
-%BLESSEDMEMBERS = (
-);
-
%ITERATORS = ();
*swig_errCode_get = *IDZebrac::RetrievalRecord_errCode_get;
*swig_errCode_set = *IDZebrac::RetrievalRecord_errCode_set;
*swig_buf_set = *IDZebrac::RetrievalRecord_buf_set;
sub new {
my $pkg = shift;
- my @args = @_;
- my $self = IDZebrac::new_RetrievalRecord(@args);
- return undef if (!defined($self));
- $OWNER{$self} = 1;
- my %retval;
- tie %retval, "IDZebra::RetrievalRecord", $self;
- return bless \%retval, $pkg;
+ my $self = IDZebrac::new_RetrievalRecord(@_);
+ bless $self, $pkg if defined($self);
}
sub DESTROY {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
- };
+}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
- };
-
-sub FETCH {
- my ($self,$field) = @_;
- my $member_func = "swig_${field}_get";
- my $val = $self->$member_func();
- if (exists $BLESSEDMEMBERS{$field}) {
- return undef if (!defined($val));
- my %retval;
- tie %retval,$BLESSEDMEMBERS{$field},$val;
- return bless \%retval, $BLESSEDMEMBERS{$field};
- }
- return $val;
-}
-
-sub STORE {
- my ($self,$field,$newval) = @_;
- my $member_func = "swig_${field}_set";
- if (exists $BLESSEDMEMBERS{$field}) {
- $self->$member_func(tied(%{$newval}));
- } else {
- $self->$member_func($newval);
- }
}
package IDZebra::scanEntry;
@ISA = qw( IDZebra );
%OWNER = ();
-%BLESSEDMEMBERS = (
-);
-
%ITERATORS = ();
*swig_occurrences_get = *IDZebrac::scanEntry_occurrences_get;
*swig_occurrences_set = *IDZebrac::scanEntry_occurrences_set;
*swig_term_set = *IDZebrac::scanEntry_term_set;
sub new {
my $pkg = shift;
- my @args = @_;
- my $self = IDZebrac::new_scanEntry(@args);
- return undef if (!defined($self));
- $OWNER{$self} = 1;
- my %retval;
- tie %retval, "IDZebra::scanEntry", $self;
- return bless \%retval, $pkg;
+ my $self = IDZebrac::new_scanEntry(@_);
+ bless $self, $pkg if defined($self);
}
sub DESTROY {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
- };
+}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
- };
-
-sub FETCH {
- my ($self,$field) = @_;
- my $member_func = "swig_${field}_get";
- my $val = $self->$member_func();
- if (exists $BLESSEDMEMBERS{$field}) {
- return undef if (!defined($val));
- my %retval;
- tie %retval,$BLESSEDMEMBERS{$field},$val;
- return bless \%retval, $BLESSEDMEMBERS{$field};
- }
- return $val;
-}
-
-sub STORE {
- my ($self,$field,$newval) = @_;
- my $member_func = "swig_${field}_set";
- if (exists $BLESSEDMEMBERS{$field}) {
- $self->$member_func(tied(%{$newval}));
- } else {
- $self->$member_func($newval);
- }
}
package IDZebra::ScanObj;
@ISA = qw( IDZebra );
%OWNER = ();
-%BLESSEDMEMBERS = (
- entries => 'IDZebra::scanEntry',
-);
-
%ITERATORS = ();
*swig_num_entries_get = *IDZebrac::ScanObj_num_entries_get;
*swig_num_entries_set = *IDZebrac::ScanObj_num_entries_set;
*swig_entries_set = *IDZebrac::ScanObj_entries_set;
sub new {
my $pkg = shift;
- my @args = @_;
- my $self = IDZebrac::new_ScanObj(@args);
- return undef if (!defined($self));
- $OWNER{$self} = 1;
- my %retval;
- tie %retval, "IDZebra::ScanObj", $self;
- return bless \%retval, $pkg;
+ my $self = IDZebrac::new_ScanObj(@_);
+ bless $self, $pkg if defined($self);
}
sub DESTROY {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
- };
+}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
- };
-
-sub FETCH {
- my ($self,$field) = @_;
- my $member_func = "swig_${field}_get";
- my $val = $self->$member_func();
- if (exists $BLESSEDMEMBERS{$field}) {
- return undef if (!defined($val));
- my %retval;
- tie %retval,$BLESSEDMEMBERS{$field},$val;
- return bless \%retval, $BLESSEDMEMBERS{$field};
- }
- return $val;
-}
-
-sub STORE {
- my ($self,$field,$newval) = @_;
- my $member_func = "swig_${field}_set";
- if (exists $BLESSEDMEMBERS{$field}) {
- $self->$member_func(tied(%{$newval}));
- } else {
- $self->$member_func($newval);
- }
}
package IDZebra::ZebraTransactionStatus;
@ISA = qw( IDZebra );
%OWNER = ();
-%BLESSEDMEMBERS = (
-);
-
%ITERATORS = ();
*swig_processed_get = *IDZebrac::ZebraTransactionStatus_processed_get;
*swig_processed_set = *IDZebrac::ZebraTransactionStatus_processed_set;
*swig_stime_set = *IDZebrac::ZebraTransactionStatus_stime_set;
sub new {
my $pkg = shift;
- my @args = @_;
- my $self = IDZebrac::new_ZebraTransactionStatus(@args);
- return undef if (!defined($self));
- $OWNER{$self} = 1;
- my %retval;
- tie %retval, "IDZebra::ZebraTransactionStatus", $self;
- return bless \%retval, $pkg;
+ my $self = IDZebrac::new_ZebraTransactionStatus(@_);
+ bless $self, $pkg if defined($self);
}
sub DESTROY {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
- };
+}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
- };
-
-sub FETCH {
- my ($self,$field) = @_;
- my $member_func = "swig_${field}_get";
- my $val = $self->$member_func();
- if (exists $BLESSEDMEMBERS{$field}) {
- return undef if (!defined($val));
- my %retval;
- tie %retval,$BLESSEDMEMBERS{$field},$val;
- return bless \%retval, $BLESSEDMEMBERS{$field};
- }
- return $val;
-}
-
-sub STORE {
- my ($self,$field,$newval) = @_;
- my $member_func = "swig_${field}_set";
- if (exists $BLESSEDMEMBERS{$field}) {
- $self->$member_func(tied(%{$newval}));
- } else {
- $self->$member_func($newval);
- }
}
char *errString; /* error string */
int position; /* position of record in result set (1,2,..) */
char *base;
- int sysno;
+ SYSNO sysno;
int score;
char *format; /* record syntax */
RetrievalRecordBuf *buf;
-/* $Id: regxread.c,v 1.50 2004-05-25 12:13:15 adam Exp $
+/* $Id: regxread.c,v 1.51 2004-08-04 08:35:25 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#if HAVE_TCL_H
static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv)
+ int argc, const char **argv)
{
struct lexSpec *spec = (struct lexSpec *) clientData;
if (argc < 2)
return TCL_ERROR;
if (!strcmp(argv[1], "record") && argc == 3)
{
- char *absynName = argv[2];
+ const char *absynName = argv[2];
data1_node *res;
#if REGX_DEBUG
}
static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv)
+ int argc, const char **argv)
{
struct lexSpec *spec = (struct lexSpec *) clientData;
if (argc < 2)
else if (!strcmp (argv[1], "element"))
{
int min_level = 2;
- char *element = 0;
+ const char *element = 0;
if (argc >= 3 && !strcmp(argv[2], "-record"))
{
min_level = 0;
}
static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv)
+ int argc, const char **argv)
{
int argi = 1;
int textFlag = 0;
}
static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv)
+ int argc, const char **argv)
{
struct lexSpec *spec = (struct lexSpec *) clientData;
int argi = 1;
-## $Id: Makefile.am,v 1.6 2004-06-16 20:49:18 adam Exp $
+## $Id: Makefile.am,v 1.7 2004-08-04 08:35:26 adam Exp $
noinst_LIBRARIES = librset.a
librset_a_SOURCES = rset.c rstemp.c rsisam.c rsnull.c rsbool.c rsbetween.c \
- rsisamc.c rsm_or.c rsisams.c rsisamd.c rsisamb.c rsprox.c
+ rsisamc.c rsm_or.c rsisams.c rsisamb.c rsprox.c
AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC)
-/* $Id: t5.c,v 1.4 2004-07-28 08:15:47 adam Exp $
+/* $Id: t5.c,v 1.5 2004-08-04 08:35:26 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
int main(int argc, char **argv)
{
- int i, hits = -1;
+ int i;
int exit_code = 0;
ZebraService zs;
ZebraHandle zh;
-#include "../index/index.h"
+/* $Id: tstcodec.c,v 1.2 2004-08-04 08:35:26 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
+ Index Data Aps
+This file is part of the Zebra server.
-void tst_encode(int num)
+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 "../../index/index.h"
+
+char *prog = "";
+
+int tst_encode(int num)
{
struct it_key key;
int i;
- void *codec_handle =iscz1_code_start(ISAMC_ENCODE);
+ void *codec_handle =iscz1_start();
+ char *dst_buf = malloc(200 + num * 10);
+ char *dst = dst_buf;
+ if (!dst_buf)
+ {
+ printf ("%s: out of memory (num=%d)\n", prog, num);
+ return 10;
+ }
for (i = 0; i<num; i++)
{
- char dst_buf[200];
- char *dst = dst_buf;
- char *src = (char*) &key;
+ const char *src = (const char *) &key;
+#if IT_KEY_NEW
+ key.len = 2;
+ key.mem[0] = i >> 8;
+ key.mem[1] = i & 255;
+#else
key.sysno = num;
key.seqno = 1;
- iscz1_code_item (ISAMC_ENCODE, codec_handle, &dst, &src);
+#endif
+ iscz1_encode (codec_handle, &dst, &src);
+ if (dst > dst_buf + num*10)
+ {
+ printf ("%s: i=%d size overflow\n", prog, i);
+ return 1;
+ }
}
- iscz1_code_stop(ISAMC_ENCODE, codec_handle);
+ iscz1_stop(codec_handle);
+
+ codec_handle =iscz1_start();
+
+ if (1)
+ {
+ const char *src = dst_buf;
+ for (i = 0; i<num; i++)
+ {
+ char *dst = (char *) &key;
+ const char *src0 = src;
+ iscz1_decode(codec_handle, &dst, &src);
+
+#if IT_KEY_NEW
+ if (key.len != 2)
+ {
+ printf ("%s: i=%d key.len=%d expected 2\n", prog,
+ i, key.len);
+ while (src0 != src)
+ {
+ printf (" %02X (%d decimal)", *src0, *src0);
+ src0++;
+ }
+ printf ("\n");
+ return 2;
+ }
+ if (key.mem[0] != (i>>8))
+ {
+ printf ("%s: i=%d mem[0]=" ZINT_FORMAT " expected "
+ "%d\n", prog, i, key.mem[0], i>>8);
+ while (src0 != src)
+ {
+ printf (" %02X (%d decimal)", *src0, *src0);
+ src0++;
+ }
+ printf ("\n");
+ return 3;
+ }
+ if (key.mem[1] != (i&255))
+ {
+ printf ("%s: i=%d mem[0]=" ZINT_FORMAT " expected %d\n",
+ prog, i, key.mem[1], i&255);
+ while (src0 != src)
+ {
+ printf (" %02X (%d decimal)", *src0, *src0);
+ src0++;
+ }
+ printf ("\n");
+ return 4;
+ }
+#else
+
+#endif
+ }
+ }
+
+ iscz1_stop(codec_handle);
+ free(dst_buf);
+ return 0;
}
int main(int argc, char **argv)
{
- tst_encode(1000000);
- exit(0);
+ int num = 0;
+ prog = *argv;
+ if (argc > 1)
+ num = atoi(argv[1]);
+ if (num < 1 || num > 100000000)
+ num = 10000;
+ exit(tst_encode(num));
}
-## $Id: Makefile.am,v 1.8 2004-06-16 20:49:18 adam Exp $
+## $Id: Makefile.am,v 1.9 2004-08-04 08:35:27 adam Exp $
noinst_LIBRARIES = libutil.a
AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) -DDEFAULT_PROFILE_PATH=\"$(pkgdatadir)/tab\"
LDADD = libutil.a $(YAZLIB) $(TCL_LIB)
-libutil_a_SOURCES = res.c charmap.c zebramap.c passwddb.c zebra-lock.c dirent.c xpath.c
+libutil_a_SOURCES = res.c charmap.c zebramap.c passwddb.c zebra-lock.c dirent.c xpath.c atoi_zn.c
passtest_SOURCES = passtest.c
--- /dev/null
+/* $Id: atoi_zn.c,v 1.1 2004-08-04 08:35:27 adam Exp $
+ Copyright (C) 2003,2004
+ 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 <ctype.h>
+#include <zebrautl.h>
+
+zint atoi_zn (const char *buf, zint len)
+{
+ zint val = 0;
+
+ while (--len >= 0)
+ {
+ if (isdigit (*buf))
+ val = val*10 + (*buf - '0');
+ buf++;
+ }
+ return val;
+}
+