mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-18 01:33:14 +00:00
Implement dynamic chunk size, set_chunk_size().
This commit is contained in:
@@ -39,7 +39,7 @@ if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 18;
|
||||
plan tests => 19;
|
||||
}
|
||||
|
||||
my $q = new Quoter();
|
||||
@@ -403,6 +403,36 @@ SKIP: {
|
||||
);
|
||||
}
|
||||
|
||||
# ############################################################################
|
||||
# Reset chunk size on-the-fly.
|
||||
# ############################################################################
|
||||
$ni = make_nibble_iter(
|
||||
sql_file => "a-z.sql",
|
||||
db => 'test',
|
||||
tbl => 't',
|
||||
argv => [qw(--databases test --chunk-size 5)],
|
||||
);
|
||||
|
||||
@rows = ();
|
||||
my $i = 0;
|
||||
while (my $row = $ni->next()) {
|
||||
push @{$rows[$ni->nibble_number()]}, @$row;
|
||||
if ( ++$i == 5 ) {
|
||||
$ni->set_chunk_size(20);
|
||||
}
|
||||
}
|
||||
|
||||
is_deeply(
|
||||
\@rows,
|
||||
[
|
||||
undef, # no 0 nibble
|
||||
[ ('a'..'e') ], # nibble 1
|
||||
[ ('f'..'y') ], # nibble 2, should contain 20 chars
|
||||
[ 'z' ], # last nibble
|
||||
],
|
||||
"Change chunk size while nibbling"
|
||||
) or print STDERR Dumper(\@rows);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
Reference in New Issue
Block a user