197 |
return $self->{'max_mfn'} = $maxmfn; |
return $self->{'max_mfn'} = $maxmfn; |
198 |
} |
} |
199 |
|
|
200 |
=head2 fetch_rec |
=head2 fetch |
201 |
|
|
202 |
Fetch next record from database. It will also displays progress bar. |
Fetch next record from database. It will also displays progress bar. |
203 |
|
|
204 |
my $rec = $webpac->fetch_rec; |
my $rec = $isis->fetch; |
205 |
|
|
206 |
You should rearly have the need to call this function directly. Instead use |
Record from this function should probably go to C<data_structure> for |
207 |
C<fetch_data_structure> which returns normalised data. |
normalisation. |
208 |
|
|
209 |
=cut |
=cut |
210 |
|
|
211 |
sub fetch_rec { |
sub fetch { |
212 |
my $self = shift; |
my $self = shift; |
213 |
|
|
214 |
my $log = $self->_get_logger(); |
my $log = $self->_get_logger(); |
238 |
} |
} |
239 |
} |
} |
240 |
|
|
241 |
=head2 fetch_data_structure |
=head2 pos |
242 |
|
|
243 |
Fetch data structure of next record from database. |
Returns current record number (MFN). |
244 |
|
|
245 |
|
print $isis->pos; |
246 |
|
|
247 |
my @ds = $webpac->fetch_data_structure; |
First record in database has position 1. |
248 |
|
|
249 |
=cut |
=cut |
250 |
|
|
251 |
sub fetch_data_structure { |
sub pos { |
252 |
my $self = shift; |
my $self = shift; |
253 |
|
return $self->{'current_mfn'}; |
254 |
|
} |
255 |
|
|
256 |
|
|
257 |
|
=head2 size |
258 |
|
|
259 |
|
Returns number of records in database |
260 |
|
|
261 |
|
print $isis->size; |
262 |
|
|
263 |
|
=cut |
264 |
|
|
265 |
return $self->data_structure( |
sub size { |
266 |
$self->fetch_rec(@_) |
my $self = shift; |
267 |
); |
return $self->{'max_mfn'}; |
268 |
} |
} |
269 |
|
|
270 |
=head2 mfn |
=head2 seek |
271 |
|
|
272 |
Returns current record number (MFN). |
Seek to specified MFN in file. |
273 |
|
|
274 |
|
$isis->seek(42); |
275 |
|
|
276 |
print $webpac->mfn; |
First record in database has position 1. |
277 |
|
|
278 |
=cut |
=cut |
279 |
|
|
280 |
sub mfn { |
sub seek { |
281 |
my $self = shift; |
my $self = shift; |
282 |
return $self->{'current_mfn'}; |
my $pos = shift || return; |
283 |
|
|
284 |
|
my $log = $self->_get_logger(); |
285 |
|
|
286 |
|
if ($pos < 1) { |
287 |
|
$log->warn("seek before first record"); |
288 |
|
$pos = 1; |
289 |
|
} elsif ($pos > $self->{'max_mfn'}) { |
290 |
|
$log->warn("seek beyond last record"); |
291 |
|
$pos = $self->{'max_mfn'}; |
292 |
|
} |
293 |
|
|
294 |
|
return $self->{'current_mfn'} = (($pos - 1) || -1); |
295 |
} |
} |
296 |
|
|
297 |
=head1 AUTHOR |
=head1 AUTHOR |