1 # $Id: zoomtst3.pl,v 1.2 2006-04-07 11:25:58 mike Exp $
3 # See ../README for a description of this program.
4 # perl -I../../blib/lib -I../../blib/arch zoomtst3.pl <t1> [...] <tN> <query>
11 print STDERR "Usage: $0 target1 target2 ... targetN query\n";
12 print STDERR " eg. $0 bagel.indexdata.dk/gils localhost:9999 fish\n";
17 my(@z, @r); # connections, result sets
18 my $o = new ZOOM::Options();
19 $o->option(async => 1);
21 # Get first 10 records of result set (using piggyback)
22 $o->option(count => 10);
24 # Preferred record syntax
25 $o->option(preferredRecordSyntax => "usmarc");
26 $o->option(elementSetName => "F");
28 # Connect to all targets: options are the same for all of them
29 for (my $i = 0; $i < $n; $i++) {
30 $z[$i] = create ZOOM::Connection($o);
31 $z[$i]->connect($ARGV[$i]);
35 for (my $i = 0; $i < $n; $i++) {
36 $r[$i] = $z[$i]->search_pqf($ARGV[-1]);
39 # Network I/O. Pass number of connections and array of connections
40 while ((my $i = ZOOM::event(\@z)) != 0) {
41 my $ev = $z[$i-1]->last_event();
42 print("connection ", $i-1, ": event $ev (", ZOOM::event_str($ev), ")\n");
43 ### It would be nice to display results as they come in.
46 # No more to be done. Inspect results
47 for (my $i = 0; $i < $n; $i++) {
48 my $tname = $ARGV[$i];
49 my($error, $errmsg, $addinfo, $diagset) = $z[$i]->error_x();
51 print STDERR "$tname error: $errmsg ($error) $addinfo\n";
55 # OK, no major errors. Look at the result count
56 my $size = $r[$i]->size();
57 print "$tname: $size hits\n";
59 # Go through all records at target
60 $size = 10 if $size > 10;
61 for (my $pos = 0; $pos < $size; $pos++) {
62 print "$tname: fetching ", $pos+1, " of $size\n";
63 my $tmp = $r[$i]->record($pos);
65 print "$tname: can't get record ", $pos+1, "\n";
68 my $rec = $tmp->render();
70 print "$tname: can't render record ", $pos+1, "\n";
73 print $pos+1, "\n", $rec, "\n";
78 for (my $i = 0; $i < $n; $i++) {