[Namazu-cvs 754] r215 - Search-Namazu/trunk

cvsd @ vaj.namazu.org cvsd @ vaj.namazu.org
2006年 3月 27日 (月) 11:35:30 JST


Author: knok
Date: 2006-03-27 11:35:30 +0900 (Mon, 27 Mar 2006)
New Revision: 215

Modified:
   Search-Namazu/trunk/ChangeLog
   Search-Namazu/trunk/Namazu.pm
Log:
Added a new parameter.


Modified: Search-Namazu/trunk/ChangeLog
===================================================================
--- Search-Namazu/trunk/ChangeLog	2006-03-27 02:20:31 UTC (rev 214)
+++ Search-Namazu/trunk/ChangeLog	2006-03-27 02:35:30 UTC (rev 215)
@@ -1,5 +1,7 @@
 2006-03-27  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
 
+	* Namazu.pm (Search): Add a new parameter 'returnas'.
+
 	* Namazu.xs: Fixed prototype.
 	  Splitted common code from call_search_main.
 	  (call_search_main_ref): New native function to return 

Modified: Search-Namazu/trunk/Namazu.pm
===================================================================
--- Search-Namazu/trunk/Namazu.pm	2006-03-27 02:20:31 UTC (rev 214)
+++ Search-Namazu/trunk/Namazu.pm	2006-03-27 02:35:30 UTC (rev 215)
@@ -72,6 +72,11 @@
         query => 'foo'
         );
 
+  $resultref = Search::Namazu::Search(
+  	index => ['/var/www/index/site1', '/var/www/index/site2'],
+        query => 'bar', returnas => 'reference'
+        );
+
 =head3 query
 
 Specify a query expression as string. Expression syntax is same as
@@ -121,10 +126,15 @@
 
 Specify language.
 
-=head4 maxhit
+=head3 maxhit
 
 Speciry maximum numbers of hits. Same as MaxHit directive in namazurc.
 
+=head4 returnas
+
+Specify return method, if the parameter is set as 'reference', it
+returns a reference of array as a result.
+
 =head2 Search::Namazu::Result
 
 Search::Namazu::Result object is for keeping result information.
@@ -224,6 +234,7 @@
     my $lang = $args{'lang'};
     my $query = $args{'query'};
     my $maxhit = $args{'maxhit'};
+    my $returnas = $args{'returnas'};
 
 # initialize
 
@@ -281,15 +292,23 @@
 
 # create Search::Namazu::Result object
 
-    my @hlists = call_search_main($query);
-
-    my $status = nmz_getstatus();
-    if ($status != NMZ_SUCCESS) {
-	return $status;
+    if ($returnas eq 'reference') {
+	my $hlistref = call_search_main_ref($query);
+	my $status = nmz_getstatus();
+	if ($status != NMZ_SUCCESS) {
+	    return $status;
+	}
+	# return objects
+	return $hlistref;
+    } else {
+	my @hlists = call_search_main($query);
+	my $status = nmz_getstatus();
+	if ($status != NMZ_SUCCESS) {
+	    return $status;
+	}
+	# return objects
+	return @hlists;
     }
-
-# return objects
-    return @hlists;
 }
 
 package Search::Namazu::Result;




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