/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
+ Copyright (C) Index Data
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
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
memcpy(&ent, (const char *)b + sizeof(sys) + 1, len);
yaz_log(YLOG_LOG, "%s " ZINT_FORMAT " next=" ZINT_FORMAT " sz=%d", txt, sys,
ent.next, ent.size);
-
+
}
else
yaz_log(YLOG_LOG, "%s " ZINT_FORMAT, txt, sys);
recindex_t p = xmalloc(sizeof(*p));
p->index_BFile = 0;
p->isamb = 0;
-
+
p->index_fname = "reci";
p->index_BFile = bf_open(bfs, p->index_fname, RIDX_CHUNK, rw);
if (p->index_BFile == NULL)
xfree(p);
return 0;
}
-
+
if (use_isamb)
{
int isam_block_size = 4096;
assert(p);
assert(p->index_BFile);
-
+
r = bf_write(p->index_BFile, 0, 0, len, buf);
if (r)
{
return ZEBRA_OK;
}
-int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize,
+int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize,
int ignoreError)
{
int r = 0;
char item[256];
char *st = item;
char untilbuf[sizeof(zint) + 1];
-
+
ISAMB_PP isam_pp = isamb_pp_open(p->isamb, p->isam_p, 1);
-
+
memcpy(untilbuf, &sysno, sizeof(sysno));
untilbuf[sizeof(sysno)] = 0;
r = isamb_pp_forward(isam_pp, st, untilbuf);
-
+
isamb_pp_close(isam_pp);
if (!r)
return 0;
-
+
if (item[sizeof(sysno)] != itemsize)
{
yaz_log(YLOG_WARN, "unexpected entry size %d != %d",
zint pos = (sysno-1)*itemsize;
int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK);
int sz1 = RIDX_CHUNK - off; /* sz1 is size of buffer to read.. */
-
+
if (sz1 > itemsize)
sz1 = itemsize; /* no more than itemsize bytes */
-
+
r = bf_read(p->index_BFile, 1+pos/RIDX_CHUNK, off, sz1, buf);
if (r == 1 && sz1 < itemsize) /* boundary? - must read second part */
r = bf_read(p->index_BFile, 2+pos/RIDX_CHUNK, 0, itemsize - sz1,
#if 0
{
struct record_index_entry *ep = buf;
- yaz_log(YLOG_LOG, "read r=%d sysno=" ZINT_FORMAT " next=" ZINT_FORMAT
+ yaz_log(YLOG_LOG, "read r=%d sysno=" ZINT_FORMAT " next=" ZINT_FORMAT
" sz=%d", r, sysno, ep->next, ep->size);
}
#endif
int bt_code_read(void *vp, char **dst, int *insertMode)
{
struct code_read_data *s = (struct code_read_data *) vp;
-
+
if (s->no == 0)
return 0;
(s->no)--;
-
+
memcpy(*dst, &s->sysno, sizeof(zint));
*dst += sizeof(zint);
**dst = s->itemsize;
zint pos = (sysno-1)*itemsize;
int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK);
int sz1 = RIDX_CHUNK - off; /* sz1 is size of buffer to read.. */
-
+
if (sz1 > itemsize)
sz1 = itemsize; /* no more than itemsize bytes */
-
+
bf_write(p->index_BFile, 1+pos/RIDX_CHUNK, off, sz1, buf);
if (sz1 < itemsize) /* boundary? must write second part */
bf_write(p->index_BFile, 2+pos/RIDX_CHUNK, 0, itemsize - sz1,
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab