X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=index%2Fzebraapi.c;h=a34301425af64bdd91beabf8e249ce04f0d098e0;hb=8d8fd83ac10dd174264826c11cc301002a9313c1;hp=202f7bbf56a6b149411559f97e46e96a428fcd34;hpb=cd02e9c5558d2f0db2ab83fcad810a6522fd2319;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 202f7bb..a343014 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1995-2008 Index Data + Copyright (C) 1994-2009 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 @@ -199,11 +199,14 @@ ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) log_level = yaz_log_module_level("zebraapi"); log_level_initialized = 1; } - + + *system_str = '\0'; + *version_str = '\0'; zebra_get_version(version_str, system_str); - yaz_log(YLOG_LOG, "zebra_start %s %s", version_str, - configName ? configName : ""); + yaz_log(YLOG_LOG, "zebra_start %s %s", version_str, system_str); + if (configName) + yaz_log(YLOG_LOG, "config %s", configName); if ((res = res_open(def_res, over_res))) { @@ -407,6 +410,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, /* installing rank classes */ zebraRankInstall(reg, rank_1_class); + zebraRankInstall(reg, rank_2_class); zebraRankInstall(reg, rank_similarity_class); zebraRankInstall(reg, rank_static_class); @@ -1427,7 +1431,6 @@ int delete_w_handle(const char *info, void *handle) { ZebraHandle zh = (ZebraHandle) handle; ISAM_P pos; - ASSERTZH; if (*info == sizeof(pos)) { @@ -1437,18 +1440,52 @@ int delete_w_handle(const char *info, void *handle) return 0; } -static int delete_SU_handle(void *handle, int ord) +int delete_w_all_handle(const char *info, void *handle) +{ + ZebraHandle zh = (ZebraHandle) handle; + ISAM_P pos; + + if (*info == sizeof(pos)) + { + ISAMB_PP pt; + memcpy(&pos, info+1, sizeof(pos)); + pt = isamb_pp_open(zh->reg->isamb, pos, 2); + if (pt) + { + struct it_key key; + key.mem[0] = 0; + while (isamb_pp_read(pt, &key)) + { + Record rec; + rec = rec_get(zh->reg->records, key.mem[0]); + rec_del(zh->reg->records, &rec); + } + isamb_pp_close(pt); + } + } + return delete_w_handle(info, handle); +} + +static int delete_SU_handle(void *handle, int ord, + const char *index_type, const char *string_index, + zinfo_index_category_t cat) { ZebraHandle zh = (ZebraHandle) handle; char ord_buf[20]; int ord_len; - +#if 0 + yaz_log(YLOG_LOG, "ord=%d index_type=%s index=%s cat=%d", ord, + index_type, string_index, (int) cat); +#endif ord_len = key_SU_encode(ord, ord_buf); ord_buf[ord_len] = '\0'; assert(zh->reg->isamb); + assert(zh->reg->records); dict_delete_subtree(zh->reg->dict, ord_buf, - zh, delete_w_handle); + zh, + !strcmp(string_index, "_ALLRECORDS") ? + delete_w_all_handle : delete_w_handle); return 0; } @@ -2268,7 +2305,6 @@ ZEBRA_RES zebra_update_record(ZebraHandle zh, return ZEBRA_FAIL; res = zebra_buffer_extract_record(zh, buf, buf_size, action, - 0, /* test_mode */ recordType, sysno, match, @@ -2420,6 +2456,7 @@ void zebra_lock_prefix(Res res, char *path) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab