[Namazu-cvs 764] r252 - Search-Namazu/trunk/Search-Namazu

cvsd @ vaj.namazu.org cvsd @ vaj.namazu.org
2006年 4月 3日 (月) 16:39:09 JST


Author: knok
Date: 2006-04-03 16:39:08 +0900 (Mon, 03 Apr 2006)
New Revision: 252

Modified:
   Search-Namazu/trunk/Search-Namazu/ChangeLog
   Search-Namazu/trunk/Search-Namazu/Namazu.pm
   Search-Namazu/trunk/Search-Namazu/Namazu.xs
Log:
Added 5 methods in ResultXS.


Modified: Search-Namazu/trunk/Search-Namazu/ChangeLog
===================================================================
--- Search-Namazu/trunk/Search-Namazu/ChangeLog	2006-03-30 06:40:23 UTC (rev 251)
+++ Search-Namazu/trunk/Search-Namazu/ChangeLog	2006-04-03 07:39:08 UTC (rev 252)
@@ -1,3 +1,8 @@
+2006-04-03  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
+
+	* Namazu.xs: Added 5 methods in ResultXS:
+	 score(), rank(), date(), docid(), idxid().
+
 2006-03-30  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
 
 	* Namazu.pm (Search): Added "sortField" method.

Modified: Search-Namazu/trunk/Search-Namazu/Namazu.pm
===================================================================
--- Search-Namazu/trunk/Search-Namazu/Namazu.pm	2006-03-30 06:40:23 UTC (rev 251)
+++ Search-Namazu/trunk/Search-Namazu/Namazu.pm	2006-04-03 07:39:08 UTC (rev 252)
@@ -44,7 +44,7 @@
 				fields => ["uri", "from"]);
 
   foreach my $rxs (@$x) {
-      print ($rxs->get("uri"), $rxs->get("score"), $rxs->get("from"));
+      print ($rxs->get("uri"), $rxs->score, $rxs->get("from"));
   }
 
 =head1 DESCRIPTION
@@ -200,10 +200,29 @@
 Search::Namazu::ResultXS object is also for keeping result information.
 It has the following methods:
 
+=head3 score
+
+It returns score.
+
+=head3 date
+
+It returns date.
+
+=head3 rank
+
+It returns ranking number.
+
+=head3 docid
+
+It returns id of document.
+
+=head3 idxid
+
+It returns id of index.
+
 =head3 get
 
-It returns specified value of field. "score", "date" and "rank" is
-set by default.
+It returns specified value of field.
 
 =head1 COPYRIGHT
 

Modified: Search-Namazu/trunk/Search-Namazu/Namazu.xs
===================================================================
--- Search-Namazu/trunk/Search-Namazu/Namazu.xs	2006-03-30 06:40:23 UTC (rev 251)
+++ Search-Namazu/trunk/Search-Namazu/Namazu.xs	2006-04-03 07:39:08 UTC (rev 252)
@@ -55,12 +55,16 @@
 #endif
 
 #define SEARCH_NAMAZU_FIELDS 5
-#define SCORE "score"
+#define SCORE "//score"
 #define SCORE_LEN strlen(SCORE)
-#define DATE "date"
+#define DATE "//date"
 #define DATE_LEN strlen(DATE)
-#define RANK "rank"
+#define RANK "//rank"
 #define RANK_LEN strlen(RANK)
+#define DOCID "//docid"
+#define DOCID_LEN strlen(DOCID)
+#define IDXID "//idxid"
+#define IDXID_LEN strlen(IDXID)
 
 static int status = 0;
 
@@ -141,7 +145,7 @@
 		if (i < maxget) {
 			HV *hash;
 			SV *ref;
-			SV *score, *date, *rank;
+			SV *score, *date, *rank, *docid, *idxid;
 			int j;
 			char fcont[BUFSIZE];
 
@@ -156,9 +160,13 @@
 			score = newSViv(hlist.data[i].score);
 			date = newSViv(hlist.data[i].date);
 			rank = newSViv(hlist.data[i].rank);
+			docid = newSViv(hlist.data[i].docid);
+			idxid = newSViv(hlist.data[i].idxid);
 			hv_store(hash, SCORE, SCORE_LEN, score, 0);
 			hv_store(hash, DATE, DATE_LEN, date, 0);
 			hv_store(hash, RANK, RANK_LEN, rank, 0);
+			hv_store(hash, DOCID, IDXID_LEN, docid, 0);
+			hv_store(hash, IDXID, IDXID_LEN, idxid, 0);
 
 			ref = newRV_inc((SV*) hash);
 			sv_bless(ref, stash);
@@ -366,3 +374,87 @@
 	OUTPUT:
 		RETVAL
 
+SV *
+res_score(self)
+	      SV *self
+	CODE:
+		HV *hash;
+		SV **ret;
+
+		hash = (HV *) SvRV(self);
+		ret = hv_fetch(hash, SCORE, SCORE_LEN, 0);
+		if (ret == NULL) {
+			RETVAL = &PL_sv_undef;
+		} else {
+			RETVAL = SvREFCNT_inc(*ret);
+		}
+	OUTPUT:
+		RETVAL
+
+SV *
+res_date(self)
+	      SV *self
+	CODE:
+		HV *hash;
+		SV **ret;
+
+		hash = (HV *) SvRV(self);
+		ret = hv_fetch(hash, DATE, DATE_LEN, 0);
+		if (ret == NULL) {
+			RETVAL = &PL_sv_undef;
+		} else {
+			RETVAL = SvREFCNT_inc(*ret);
+		}
+	OUTPUT:
+		RETVAL
+
+SV *
+res_rank(self)
+	      SV *self
+	CODE:
+		HV *hash;
+		SV **ret;
+
+		hash = (HV *) SvRV(self);
+		ret = hv_fetch(hash, RANK, RANK_LEN, 0);
+		if (ret == NULL) {
+			RETVAL = &PL_sv_undef;
+		} else {
+			RETVAL = SvREFCNT_inc(*ret);
+		}
+	OUTPUT:
+		RETVAL
+
+SV *
+res_docid(self)
+	      SV *self
+	CODE:
+		HV *hash;
+		SV **ret;
+
+		hash = (HV *) SvRV(self);
+		ret = hv_fetch(hash, DOCID, DOCID_LEN, 0);
+		if (ret == NULL) {
+			RETVAL = &PL_sv_undef;
+		} else {
+			RETVAL = SvREFCNT_inc(*ret);
+		}
+	OUTPUT:
+		RETVAL
+
+SV *
+res_idxid(self)
+	      SV *self
+	CODE:
+		HV *hash;
+		SV **ret;
+
+		hash = (HV *) SvRV(self);
+		ret = hv_fetch(hash, IDXID, IDXID_LEN, 0);
+		if (ret == NULL) {
+			RETVAL = &PL_sv_undef;
+		} else {
+			RETVAL = SvREFCNT_inc(*ret);
+		}
+	OUTPUT:
+		RETVAL




Namazu-cvs メーリングリストの案内