Bugzilla – Attachment 82585 Details for
Bug 21872
Elasticsearch indexing faster by making it multi-threaded
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21872: Fix some issues with record_batches.pl
Bug-21872-Fix-some-issues-with-recordbatchespl.patch (text/plain), 3.97 KB, created by
David Gustafsson
on 2018-11-22 18:10:35 UTC
(
hide
)
Description:
Bug 21872: Fix some issues with record_batches.pl
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2018-11-22 18:10:35 UTC
Size:
3.97 KB
patch
obsolete
>From a0feb355eeca7c2f68abe08e82b6b684a7c60d4e Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Thu, 22 Nov 2018 19:01:04 +0100 >Subject: [PATCH] Bug 21872: Fix some issues with record_batches.pl > >Fix behavior for case where no biblios or just one biblio exists. >Improve performance by only selecting items greater than last end >of range instead of increasing offset by batch size. Also don't use >underscore for option names. >--- > misc/record_batches.pl | 61 ++++++++++++++++++++++++++++---------------------- > 1 file changed, 34 insertions(+), 27 deletions(-) > mode change 100644 => 100755 misc/record_batches.pl > >diff --git a/misc/record_batches.pl b/misc/record_batches.pl >old mode 100644 >new mode 100755 >index e003c8ef5c..1e1e442287 >--- a/misc/record_batches.pl >+++ b/misc/record_batches.pl >@@ -5,12 +5,12 @@ use C4::Context; > use Getopt::Long; > use Pod::Usage; > >-my $gt_biblionumber; >+my $start_biblionumber; > my $batch_size; > my $help; > GetOptions( >- 'gt_biblionumber=i' => \$gt_biblionumber, >- 'batch_size=i' => \$batch_size, >+ 'startbiblionumber=i' => \$start_biblionumber, >+ 'batchsize=i' => \$batch_size, > 'h|help|?' => \$help > ); > if ($help) { >@@ -18,31 +18,38 @@ if ($help) { > } > > my $dbh = C4::Context->dbh; >-my $step = $batch_size || 25000; >-my $offset = 0; >-my $prev_biblionumber; >-my ($max_biblionumber) = @{ $dbh->selectcol_arrayref(qq{SELECT MAX(`biblionumber`) FROM `biblio`}) }; >-my @ranges; >-my $biblionumber; >+$batch_size ||= 25000; # TODO: Assert positive number >+ >+if (!$start_biblionumber) { >+ my ($min_biblionumber) = @{ $dbh->selectcol_arrayref(qq{SELECT MIN(`biblionumber`) FROM `biblio`}) }; >+ $start_biblionumber = $min_biblionumber; >+} > > while (1) { >- my $query = $gt_biblionumber ? >- qq{SELECT `biblionumber` FROM `biblio` WHERE `biblionumber` >= $gt_biblionumber ORDER BY `biblionumber` ASC LIMIT 1 OFFSET $offset} : >- qq{SELECT `biblionumber` FROM `biblio` ORDER BY `biblionumber` ASC LIMIT 1 OFFSET $offset}; >- my ($biblionumber) = @{ $dbh->selectcol_arrayref($query) }; >- if (!$biblionumber) { >- push @ranges, [$prev_biblionumber, $max_biblionumber]; >+ my $offset = $batch_size - 1; >+ my $query = >+ qq{SELECT `biblionumber` FROM `biblio` WHERE `biblionumber` >= $start_biblionumber ORDER BY `biblionumber` ASC LIMIT 2 OFFSET $offset}; >+ my ($end_biblionumber, $next_biblionumber) = @{ $dbh->selectcol_arrayref($query) }; >+ if (!$end_biblionumber) { >+ if ($start_biblionumber) { >+ my ($max_biblionumber) = @{ $dbh->selectcol_arrayref(qq{SELECT MAX(`biblionumber`) FROM `biblio`}) }; >+ if($max_biblionumber >= $start_biblionumber) { >+ # @TODO: Option for argument and range separator? >+ print join(' ', ($start_biblionumber, $max_biblionumber)) . "\n"; >+ >+ } >+ } > last; > } >- elsif ($prev_biblionumber) { >- push @ranges, [$prev_biblionumber, $biblionumber - 1]; >+ else { >+ print join(' ', ($start_biblionumber, $end_biblionumber)) . "\n"; >+ } >+ if ($next_biblionumber) { >+ $start_biblionumber = $next_biblionumber; >+ } >+ else { >+ last; > } >- $prev_biblionumber = $biblionumber; >- $offset += $step; >-} >- >-foreach my $range (@ranges) { >- print join(' ', @{$range}) . "\n"; # @TODO: Option for argument and range separtor? > } > > =head1 NAME >@@ -51,7 +58,7 @@ record batches - This script outputs ranges of biblionumbers > > =head1 SYNOPSIS > >-record_batches.pl [-h|--help] [--gt_biblionumber=BIBLIONUMBER] >+record_batches.pl [-h|--help] [--startbiblionumber=BIBLIONUMBER] > > =head1 OPTIONS > >@@ -61,8 +68,8 @@ record_batches.pl [-h|--help] [--gt_biblionumber=BIBLIONUMBER] > > Print a brief help message. > >-=item B<--gt_biblionumber> >+=item B<--startbiblionumber> > >- --gt_biblionumber=BIBLIONUMBER Output batches with biblionumber >= BIBLIONUMBER >+ --startbiblionumber=BIBLIONUMBER Output batches with biblionumber >= BIBLIONUMBER > >-=item B<--batch_size> >+=item B<--batchsize> >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21872
:
82582
|
82583
|
82584
|
82585
|
82586
|
82598
|
82599
|
82780
|
85119
|
85121
|
85975
|
85976
|
85977
|
85978
|
85979
|
86053
|
86054
|
86055
|
86056
|
86057
|
89109
|
89110
|
89111
|
89112
|
89113