Namazu-devel-ja(旧)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: missing cache in 'nmz/field.c - nmz_get_field_data()'
- From: knok@xxxxxxxxxxxxx (NOKUBI Takatsugu)
- Date: Thu, 14 Nov 2002 19:44:27 JST
- X-ml-name: namazu-devel-ja
- X-mail-count: 02699
<200210070703.QAA15309@xxxxxxxxxxxxxxxxxx>の記事において
私は書きました。
>> >> nmz_free_internal()にcacheのクリアを実装した方が良くないでしょうか?
>>
>> そうですね。いただいたパッチのままで問題なさそうです。
field_cache の定義を libnamazu.h の方にもってゆきました。基本的には
いただいたパッチのままです。
>> # この場合 LTVERSION は 6:0:3 から 7:0:4 にすればいいのかな?
こうしたら libnmz.so は 3.4.0 になりました。問題なさそうです。
一応できあがったパッチを添付しておきます。commit は明日にでも。
--
野首 貴嗣
E-mail: knok@xxxxxxxxxxxxx
knok@xxxxxxxxxx / knok@xxxxxxxxxx
Index: configure.in
===================================================================
RCS file: /storage/cvsroot/namazu/configure.in,v
retrieving revision 1.137.4.40
diff -u -r1.137.4.40 configure.in
--- configure.in 4 Sep 2002 15:12:31 -0000 1.137.4.40
+++ configure.in 14 Nov 2002 10:44:10 -0000
@@ -79,7 +79,7 @@
# change to C+1:0:0
# - If the interface is the same as the previous version, change to C:R+1:A
-LTVERSION="6:0:3"
+LTVERSION="7:0:4"
AC_SUBST(LTVERSION)
dnl *
Index: nmz/field.c
===================================================================
RCS file: /storage/cvsroot/namazu/nmz/field.c,v
retrieving revision 1.29.8.3
diff -u -r1.29.8.3 field.c
--- nmz/field.c 21 Dec 2001 05:36:40 -0000 1.29.8.3
+++ nmz/field.c 14 Nov 2002 10:44:12 -0000
@@ -49,6 +49,13 @@
#include "idxname.h"
/*
+ * Private variables
+ */
+
+static int cache_idx = 0, cache_num = 0;
+static struct field_cache fc[FIELD_CACHE_SIZE];
+
+/*
*
* Private functions
*
@@ -58,6 +65,7 @@
static int is_field_safe_char ( int c );
static void make_fullpathname_field ( int n );
+
static void
apply_field_alias(char *field)
{
@@ -154,15 +162,7 @@
char fname[BUFSIZE];
char tmpfield[BUFSIZE];
int i;
- static int cache_idx = 0, cache_num = 0;
FILE *fp_field, *fp_field_idx;
- struct field_cache {
- int idxid;
- int docid;
- char field[BUFSIZE];
- char data[BUFSIZE];
- };
- static struct field_cache fc[FIELD_CACHE_SIZE];
strcpy(data, ""); /* For safety. */
@@ -225,4 +225,15 @@
}
}
-
+void
+nmz_free_field_cache(void)
+{
+ int i;
+ for(i=0; i++; i < cache_num) {
+ fc[i].idxid =0;
+ fc[i].docid =0;
+ strcpy(fc[i].field, "");
+ strcpy(fc[i].data, "");
+ }
+ cache_num = 0;
+}
Index: nmz/field.h
===================================================================
RCS file: /storage/cvsroot/namazu/nmz/field.h,v
retrieving revision 1.9
diff -u -r1.9 field.h
--- nmz/field.h 9 Jan 2000 08:52:27 -0000 1.9
+++ nmz/field.h 14 Nov 2002 10:44:12 -0000
@@ -10,5 +10,6 @@
extern int nmz_isfield ( const char *key );
extern char *nmz_get_field_name ( const char *fieldpat );
extern void nmz_get_field_data ( int idxid, int docid, const char *field, char *data );
+extern void nmz_free_field_cache ( void );
#endif /* _FIELD_H */
Index: nmz/libnamazu.c
===================================================================
RCS file: /storage/cvsroot/namazu/nmz/libnamazu.c,v
retrieving revision 1.35.8.4
diff -u -r1.35.8.4 libnamazu.c
--- nmz/libnamazu.c 26 Mar 2002 10:49:33 -0000 1.35.8.4
+++ nmz/libnamazu.c 14 Nov 2002 10:44:12 -0000
@@ -62,6 +62,7 @@
#include "codeconv.h"
#include "search.h"
#include "hlist.h"
+#include "field.h"
#include "i18n.h"
#include "regex.h"
#include "var.h"
@@ -95,6 +96,7 @@
nmz_free_idxnames();
nmz_free_aliases();
nmz_free_replaces();
+ nmz_free_field_cache();
}
void
Index: nmz/libnamazu.h
===================================================================
RCS file: /storage/cvsroot/namazu/nmz/libnamazu.h,v
retrieving revision 1.46.4.2
diff -u -r1.46.4.2 libnamazu.h
--- nmz/libnamazu.h 26 Mar 2002 10:49:33 -0000 1.46.4.2
+++ nmz/libnamazu.h 14 Nov 2002 10:44:12 -0000
@@ -228,6 +228,16 @@
struct nmz_hitnumlist *next;
};
+/*
+ * Field cache information
+ */
+struct field_cache {
+ int idxid;
+ int docid;
+ char field[BUFSIZE];
+ char data[BUFSIZE];
+};
+
extern void nmz_free_aliases ( void );
extern void nmz_free_replaces ( void );
extern void nmz_set_sortmethod ( enum nmz_sortmethod method );