* Copyright (C) 1995-2002, Index Data
* All rights reserved.
*
- * $Id: zebraapi.c,v 1.52 2002-04-04 20:50:37 adam Exp $
+ * $Id: zebraapi.c,v 1.61 2002-07-03 14:10:12 adam Exp $
*/
#include <assert.h>
static void zebra_flush_reg (ZebraHandle zh)
{
- zebraExplain_flush (zh->reg->zei, 1, zh);
+ zebraExplain_flush (zh->reg->zei, zh);
extract_flushWriteKeys (zh);
zebra_index_merge (zh);
const char *reg_path);
static void zebra_register_close (ZebraService zs, struct zebra_register *reg);
-static int zebra_begin_read (ZebraHandle zh);
-static void zebra_end_read (ZebraHandle zh);
-
ZebraHandle zebra_open (ZebraService zs)
{
ZebraHandle zh;
zh->admin_databaseName = 0;
+ zh->shadow_enable = 1;
+
zebra_mutex_cond_lock (&zs->session_lock);
zh->next = zs->sessions;
reg->sortIdx = 0;
reg->isams = 0;
reg->matchDict = 0;
-#if ZMBOL
reg->isam = 0;
reg->isamc = 0;
reg->isamd = 0;
-#endif
+ reg->isamb = 0;
reg->zei = 0;
reg->matchDict = 0;
return 0;
}
}
-#if ZMBOL
- else if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
+ if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
{
if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
sizeof (struct it_key), res)))
return 0;
}
}
- else if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
+ if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
{
struct ISAMC_M_s isamc_m;
if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
return 0;
}
}
- else if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
+ if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
{
struct ISAMD_M_s isamd_m;
return 0;
}
}
-#endif
+ if (res_get_match (res, "isam", "b", ISAM_DEFAULT))
+ {
+ struct ISAMC_M_s isamc_m;
+
+ if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
+ rw, key_isamc_m(res, &isamc_m))))
+ {
+ logf (LOG_WARN, "isamb_open");
+ return 0;
+ }
+ }
reg->zei = zebraExplain_open (reg->records, reg->dh,
res, rw, reg,
explain_extract);
zebra_chdir (zs);
if (reg->records)
{
- zebraExplain_close (reg->zei, 0);
+ zebraExplain_close (reg->zei);
dict_close (reg->dict);
if (reg->matchDict)
dict_close (reg->matchDict);
sortIdx_close (reg->sortIdx);
if (reg->isams)
isams_close (reg->isams);
-#if ZMBOL
if (reg->isam)
is_close (reg->isam);
if (reg->isamc)
isc_close (reg->isamc);
if (reg->isamd)
isamd_close (reg->isamd);
-#endif
+ if (reg->isamb)
+ isamb_close (reg->isamb);
rec_close (®->records);
}
zebra_mutex_cond_unlock (&zs->session_lock);
xfree (zh->reg_name);
xfree (zh);
- yaz_log (LOG_LOG, "zebra_close zh=%p end", zh);}
+}
struct map_baseinfo {
ZebraHandle zh;
{
int i;
const char *cp;
- size_t len = 0;
+ int len = 0;
char *new_reg = 0;
if (num_bases < 1)
zh->errCode = 23;
return -1;
}
- if (len != cp - basenames[i] ||
+ if (len != cp1 - basenames[i] ||
memcmp (basenames[i], new_reg, len))
{
zh->errCode = 23;
zh->errString = odr_strdup (stream, setname);
return;
}
+
+ zh->errCode = 0;
if (zebra_begin_read (zh))
return;
xfree (fname);
}
-static int zebra_begin_read (ZebraHandle zh)
+int zebra_begin_read (ZebraHandle zh)
{
int dirty = 0;
char val;
zebra_flush_reg (zh);
return 0;
}
+#if HAVE_SYS_TIMES_H
+ times (&zh->tms1);
+#endif
if (!zh->res)
{
(zh->trans_no)--;
return 0;
}
-static void zebra_end_read (ZebraHandle zh)
+void zebra_end_read (ZebraHandle zh)
{
(zh->trans_no)--;
if (zh->trans_no != 0)
return;
+#if HAVE_SYS_TIMES_H
+ times (&zh->tms2);
+ logf (LOG_LOG, "user/system: %ld/%ld",
+ (long) (zh->tms2.tms_utime - zh->tms1.tms_utime),
+ (long) (zh->tms2.tms_stime - zh->tms1.tms_stime));
+
+#endif
+
zebra_unlock (zh->lock_normal);
zebra_unlock (zh->lock_shadow);
}
int pass;
int seqno = 0;
char val = '?';
- const char *rval;
+ const char *rval = 0;
assert (zh->res);
}
yaz_log (LOG_LOG, "zebra_begin_trans");
+
+ zh->records_inserted = 0;
+ zh->records_updated = 0;
+ zh->records_deleted = 0;
+ zh->records_processed = 0;
+
#if HAVE_SYS_TIMES_H
times (&zh->tms1);
#endif
/* lock */
- rval = res_get (zh->res, "shadow");
+ if (zh->shadow_enable)
+ rval = res_get (zh->res, "shadow");
for (pass = 0; pass < 2; pass++)
{
yaz_log (LOG_LOG, "zebra_end_trans");
rval = res_get (zh->res, "shadow");
+ zebraExplain_runNumberIncrement (zh->reg->zei, 1);
+
zebra_flush_reg (zh);
zebra_register_close (zh->service, zh->reg);
zh->reg = 0;
+
+ yaz_log (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
+ zh->records_processed, zh->records_inserted,
+ zh->records_updated, zh->records_deleted);
+
zebra_get_state (zh, &val, &seqno);
if (val != 'd')
{
zebra_set_state (zh, 'c', seqno);
logf (LOG_LOG, "commit start");
- sleep (2);
bf_commitExec (bfs);
#ifndef WIN32
sync ();
*addinfo = zh->errString;
}
+void zebra_shadow_enable (ZebraHandle zh, int value)
+{
+ zh->shadow_enable = value;
+}
+