/[Sack]/trunk/lib/Sack/From.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

Contents of /trunk/lib/Sack/From.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 95 - (show annotations)
Sun Oct 4 12:17:52 2009 UTC (14 years, 9 months ago) by dpavlin
File size: 791 byte(s)
make correct shards
1 package Sack::From;
2
3 use warnings;
4 use strict;
5
6 use Data::Dump qw(dump);
7
8 use lib "/srv/webpac2/lib/";
9 use WebPAC::Input::ISI;
10
11 $WebPAC::Input::ISI::subfields = undef; # disable parsing of subfields
12
13 sub new {
14 my $class = shift;
15 my $self = bless {@_}, $class;
16
17 warn "from ",dump( @_ );
18
19 $self->{input} = WebPAC::Input::ISI->new( @_ );
20 warn "got ", $self->{input}->size, " records for ", dump @_;
21
22 $self->{pos} = 1;
23 $self->{shard} = 0;
24
25 return $self;
26 }
27
28 sub input { $_[0]->{input} }
29
30 sub shard {
31 my ($self,$limit) = @_;
32
33 my $start_pos = $self->{pos};
34 $self->{shard}++;
35 my $data;
36
37 foreach my $pos ( 1 .. $limit ) {
38 push @$data, $self->input->fetch_rec( $self->{pos}++ );
39 }
40
41 warn "shard $self->{shard} range: $start_pos - $self->{pos} / $limit\n";
42
43 return $data;
44 }
45
46 1;

  ViewVC Help
Powered by ViewVC 1.1.26