2 package ZOOM::IRSpy::Task::Search;
9 our @ISA = qw(ZOOM::IRSpy::Task);
13 ZOOM::IRSpy::Task::Search - a searching task for IRSpy
29 die "$class: unrecognised query type '$qtype'"
30 if !grep { $qtype eq $_ } qw(pqf cql);
32 my $this = $class->SUPER::new(@_);
33 $this->{qtype} = $qtype;
34 $this->{qstr} = $qstr;
44 my $conn = $this->conn();
45 $conn->connect($conn->option("host"));
47 my $qtype = $this->{qtype};
48 my $qstr = $this->{qstr};
49 $this->irspy()->log("irspy_task", $conn->option("host"),
50 " searching for '$qtype:$qstr'");
51 die "task $this has resultset?!" if defined $this->{rs};
54 if ($qtype eq "pqf") {
55 $query = new ZOOM::Query::PQF($qstr);
56 } elsif ($qtype eq "cql") {
57 $query = new ZOOM::Query::CQL($qstr);
62 ### Note well that when this task runs, it creates a result-set
63 # object which MUST BE DESTROYED in order to prevent large-scale
64 # memory leakage. So when creating a Task::Search, it is the
65 # APPLICATION'S RESPONSIBILITY to ensure that the callback
66 # invoked on success OR FAILURE makes arrangements for the set
69 $this->{rs} = $conn->search($query);
71 die "remote search '$query' had error: '$@'";
74 warn "no ZOOM-C level events queued by $this"
80 # Unique to Task::Search, used only for logging
83 return $this->{qtype} . ":" . $this->{qstr}
88 return ref($this) . "(" . $this->render_query() . ")";
91 use overload '""' => \&render;
100 Mike Taylor, E<lt>mike@indexdata.comE<gt>
102 =head1 COPYRIGHT AND LICENSE
104 Copyright (C) 2006 by Index Data ApS.
106 This library is free software; you can redistribute it and/or modify
107 it under the same terms as Perl itself, either Perl version 5.8.7 or,
108 at your option, any later version of Perl 5 you may have available.