/[BackupPC]/trunk/lib/BackupPC/SearchLib.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/BackupPC/SearchLib.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 116 by dpavlin, Thu Sep 1 18:30:51 2005 UTC revision 117 by dpavlin, Sun Sep 11 13:05:06 2005 UTC
# Line 175  sub getFiles($) { Line 175  sub getFiles($) {
175          return ($results, \@ret);          return ($results, \@ret);
176  }  }
177    
178    sub getHyperEstraier_url($) {
179            my ($use_hest) = @_;
180    
181            return unless $use_hest;
182    
183            use HyperEstraier;
184            my ($index_path, $index_node_url);
185    
186            if ($use_hest =~ m#^http://#) {
187                    $index_node_url = $use_hest;
188            } else {
189                    $index_path = $TopDir . '/' . $index_path;
190                    $index_path =~ s#//#/#g;
191            }
192            return ($index_path, $index_node_url);
193    }
194    
195  sub getFilesHyperEstraier($) {  sub getFilesHyperEstraier($) {
196          my ($param) = @_;          my ($param) = @_;
197    
# Line 185  sub getFilesHyperEstraier($) { Line 202  sub getFilesHyperEstraier($) {
202    
203          use HyperEstraier;          use HyperEstraier;
204    
205            my ($index_path, $index_node_url) = getHyperEstraier_url($index_path);
206    
207          # open the database          # open the database
208          my $db = HyperEstraier::Database->new();          my $db;
209          $db->open($index_path, $HyperEstraier::ESTDBREADER);          if ($index_path) {
210                    $db = HyperEstraier::Database->new();
211                    $db->open($index_path, $HyperEstraier::ESTDBREADER);
212            } elsif ($index_node_url) {
213                    $db ||= HyperEstraier::Node->new($index_node_url);
214                    $db->set_auth('admin', 'admin');
215            } else {
216                    die "BUG: unimplemented";
217            }
218    
219          # create a search condition object          # create a search condition object
220          my $cond = HyperEstraier::Condition->new();          my $cond = HyperEstraier::Condition->new();
# Line 219  sub getFilesHyperEstraier($) { Line 246  sub getFilesHyperEstraier($) {
246          $cond->set_order( 'date NUMA' );          $cond->set_order( 'date NUMA' );
247    
248          # get the result of search          # get the result of search
         my $result = $db->search($cond, 0);  
   
249          my @res;          my @res;
250          my $hits = $result->size;          my ($result, $hits);
251    
252            if ($index_path) {
253                    $result = $db->search($cond, 0);
254                    $hits = $result->size;
255            } elsif ($index_node_url) {
256                    $result = $db->search($cond, 0);
257                    $hits = $result->doc_num;
258            } else {
259                    die "BUG: unimplemented";
260            }
261    
262          # for each document in result          # for each document in result
263          for my $i ($offset .. ($offset + $on_page - 1)) {          for my $i ($offset .. ($offset + $on_page - 1)) {
264                  last if ($i >= $hits);                  last if ($i >= $hits);
265    
266                  my $id = $result->get($i);                  my $doc;
267                  my $doc = $db->get_doc($id, 0);                  if ($index_path) {
268                            my $id = $result->get($i);
269                            $doc = $db->get_doc($id, 0);
270                    } elsif ($index_node_url) {
271                            $doc = $result->get_doc($i);
272                    } else {
273                            die "BUG: unimplemented";
274                    }
275    
276                  my $row;                  my $row;
277                  foreach my $c (qw/fid hname sname backupnum fiilename filepath date type size/) {                  foreach my $c (qw/fid hname sname backupnum fiilename filepath date type size/) {

Legend:
Removed from v.116  
changed lines
  Added in v.117

  ViewVC Help
Powered by ViewVC 1.1.26