Skip to content

Commit

Permalink
use bulk indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
monken authored and oalders committed Apr 1, 2012
1 parent 345566e commit 52b992c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/MetaCPAN/Script/Tickets.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ sub run {
sub index_bug_summary { sub index_bug_summary {
my ( $self, $summary ) = @_; my ( $self, $summary ) = @_;


my $bulk = $self->index->bulk( size => 300 );
for my $dist ( keys %{$summary} ) { for my $dist ( keys %{$summary} ) {
my $dist_data = $self->index->type('distribution')->raw->get($dist) my $dist_data = $self->index->type('distribution')->raw->get($dist)
or next; or next;


$self->index->type('distribution')->put( delete $dist_data->{exists};
{ %{ $dist_data->{_source} }, rt_bug_count => $summary->{$dist}, $bulk->put(
}, { %$dist_data,
{ refresh => 1 } _source => {
%{ $dist_data->{_source} },
rt_bug_count => $summary->{$dist},
}
}
); );
} }
$bulk->commit;
} }


sub retrieve_bug_summary { sub retrieve_bug_summary {
Expand All @@ -56,8 +62,10 @@ sub parse_tsv {
my ( $self, $tsv ) = @_; my ( $self, $tsv ) = @_;
$tsv =~ s/^#.*\n//mg; $tsv =~ s/^#.*\n//mg;


my $tsv_parser = Parse::CSV->new( handle => IO::String->new($tsv), my $tsv_parser = Parse::CSV->new(
sep_char => "\t" ); handle => IO::String->new($tsv),
sep_char => "\t"
);


my %summary; my %summary;
while ( my $row = $tsv_parser->fetch ) { while ( my $row = $tsv_parser->fetch ) {
Expand Down

0 comments on commit 52b992c

Please sign in to comment.