Lines 64-69
Only index the supplied biblionumber, mostly for testing purposes. May be
Link Here
|
64 |
repeated. This also applies to authorities via authid, so if you're using it, |
64 |
repeated. This also applies to authorities via authid, so if you're using it, |
65 |
you probably only want to do one or the other at a time. |
65 |
you probably only want to do one or the other at a time. |
66 |
|
66 |
|
|
|
67 |
=item B<-s|--slice> |
68 |
|
69 |
Only index a slice of the records. A slice is defined as two integers separated |
70 |
by a comma. The first one is the slice to process and the second one is total |
71 |
number of slices. e.g. --slice=1,3 processes every third record starting from |
72 |
the first and --slice=2,3 processes every third record starting from the |
73 |
second. |
74 |
|
67 |
=item B<-v|--verbose> |
75 |
=item B<-v|--verbose> |
68 |
|
76 |
|
69 |
By default, this program only emits warnings and errors. This makes it talk |
77 |
By default, this program only emits warnings and errors. This makes it talk |
Lines 94-114
use Pod::Usage;
Link Here
|
94 |
|
102 |
|
95 |
my $verbose = 0; |
103 |
my $verbose = 0; |
96 |
my $commit = 5000; |
104 |
my $commit = 5000; |
97 |
my ($delete, $help, $man); |
105 |
my ($delete, $help, $man, $slice); |
98 |
my ($index_biblios, $index_authorities); |
106 |
my ($index_biblios, $index_authorities); |
99 |
my (@biblionumbers); |
107 |
my (@biblionumbers); |
100 |
|
108 |
|
101 |
$|=1; # flushes output |
109 |
$|=1; # flushes output |
102 |
|
110 |
|
103 |
GetOptions( |
111 |
GetOptions( |
104 |
'c|commit=i' => \$commit, |
112 |
'c|commit=i' => \$commit, |
105 |
'd|delete' => \$delete, |
113 |
'd|delete' => \$delete, |
106 |
'a|authorities' => \$index_authorities, |
114 |
'a|authorities' => \$index_authorities, |
107 |
'b|biblios' => \$index_biblios, |
115 |
'b|biblios' => \$index_biblios, |
108 |
'bn|bnumber=i' => \@biblionumbers, |
116 |
'bn|bnumber=i' => \@biblionumbers, |
109 |
'v|verbose+' => \$verbose, |
117 |
's|slice=s' => \$slice, |
110 |
'h|help' => \$help, |
118 |
'v|verbose+' => \$verbose, |
111 |
'man' => \$man, |
119 |
'h|help' => \$help, |
|
|
120 |
'man' => \$man, |
112 |
); |
121 |
); |
113 |
|
122 |
|
114 |
# Default is to do both |
123 |
# Default is to do both |
Lines 121-126
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
Link Here
|
121 |
|
130 |
|
122 |
sanity_check(); |
131 |
sanity_check(); |
123 |
|
132 |
|
|
|
133 |
my %iterator_options; |
134 |
if ($slice) { |
135 |
my ($slice_index, $slice_count) = $slice =~ /^(\d+),(\d+)$/; |
136 |
_log(1, "Processing slice $slice_index of $slice_count\n"); |
137 |
$iterator_options{slice} = { index => $slice_index, count => $slice_count }; |
138 |
} |
139 |
|
124 |
my $next; |
140 |
my $next; |
125 |
if ($index_biblios) { |
141 |
if ($index_biblios) { |
126 |
_log(1, "Indexing biblios\n"); |
142 |
_log(1, "Indexing biblios\n"); |
Lines 131-137
if ($index_biblios) {
Link Here
|
131 |
return ($r, Koha::BiblioUtils->get_from_biblionumber($r, item_data => 1 )); |
147 |
return ($r, Koha::BiblioUtils->get_from_biblionumber($r, item_data => 1 )); |
132 |
}; |
148 |
}; |
133 |
} else { |
149 |
} else { |
134 |
my $records = Koha::BiblioUtils->get_all_biblios_iterator(); |
150 |
my $records = Koha::BiblioUtils->get_all_biblios_iterator(%iterator_options); |
135 |
$next = sub { |
151 |
$next = sub { |
136 |
$records->next(); |
152 |
$records->next(); |
137 |
} |
153 |
} |
Lines 148-154
if ($index_authorities) {
Link Here
|
148 |
return ($r, $a->record); |
164 |
return ($r, $a->record); |
149 |
}; |
165 |
}; |
150 |
} else { |
166 |
} else { |
151 |
my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator(); |
167 |
my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator(%iterator_options); |
152 |
$next = sub { |
168 |
$next = sub { |
153 |
$records->next(); |
169 |
$records->next(); |
154 |
} |
170 |
} |
Lines 191-202
sub do_reindex {
Link Here
|
191 |
push @id_buffer, $id; |
207 |
push @id_buffer, $id; |
192 |
push @commit_buffer, $record; |
208 |
push @commit_buffer, $record; |
193 |
if ( !( --$commit_count ) ) { |
209 |
if ( !( --$commit_count ) ) { |
194 |
_log( 1, "Committing $commit records..." ); |
210 |
_log( 1, "Committing $commit records...\n" ); |
195 |
$indexer->update_index( \@id_buffer, \@commit_buffer ); |
211 |
$indexer->update_index( \@id_buffer, \@commit_buffer ); |
196 |
$commit_count = $commit; |
212 |
$commit_count = $commit; |
197 |
@id_buffer = (); |
213 |
@id_buffer = (); |
198 |
@commit_buffer = (); |
214 |
@commit_buffer = (); |
199 |
_log( 1, " done\n" ); |
215 |
_log( 1, "Commit complete\n" ); |
200 |
} |
216 |
} |
201 |
} |
217 |
} |
202 |
|
218 |
|
Lines 222-226
sub sanity_check {
Link Here
|
222 |
sub _log { |
238 |
sub _log { |
223 |
my ($level, $msg) = @_; |
239 |
my ($level, $msg) = @_; |
224 |
|
240 |
|
225 |
print $msg if ($verbose >= $level); |
241 |
print "[$$] $msg" if ($verbose >= $level); |
226 |
} |
242 |
} |
227 |
- |
|
|