BerkeleyDB
view release on metacpan or search on metacpan
BerkeleyDB.pod view on Meta::CPAN
Truncates the database and returns the number or records deleted
in C<$count>.
=head2 $status = $db->compact($start, $stop, $c_data, $flags, $end);
Compacts the database C<$db>.
All the parameters are optional - if only want to make use of some of them,
use C<undef> for those you don't want. Trailing unused parameters can be
omitted. For example, if you only want to use the C<$c_data> parameter to
set the C<compact_fillpercent>, write you code like this
my %hash;
$hash{compact_fillpercent} = 50;
$db->compact(undef, undef, \%hash);
The parameters operate identically to the C equivalent of this method.
The C<$c_data> needs a bit of explanation - it must be a hash reference.
The values of the following keys can be set before calling C<compact> and
will affect the operation of the compaction.
=over 5
=item * compact_fillpercent
=item * compact_timeout
=back
The following keys, along with associated values, will be created in the
hash reference if the C<compact> operation was successful.
=over 5
BerkeleyDB.pod.P view on Meta::CPAN
Truncates the database and returns the number or records deleted
in C<$count>.
=head2 $status = $db->compact($start, $stop, $c_data, $flags, $end);
Compacts the database C<$db>.
All the parameters are optional - if only want to make use of some of them,
use C<undef> for those you don't want. Trailing unused parameters can be
omitted. For example, if you only want to use the C<$c_data> parameter to
set the C<compact_fillpercent>, write you code like this
my %hash;
$hash{compact_fillpercent} = 50;
$db->compact(undef, undef, \%hash);
The parameters operate identically to the C equivalent of this method.
The C<$c_data> needs a bit of explanation - it must be a hash reference.
The values of the following keys can be set before calling C<compact> and
will affect the operation of the compaction.
=over 5
=item * compact_fillpercent
=item * compact_timeout
=back
The following keys, along with associated values, will be created in the
hash reference if the C<compact> operation was successful.
=over 5
BerkeleyDB.xs view on Meta::CPAN
stop_p = &stop_key;
DBM_ckFilter(stop, filter_store_key, "filter_store_key");
GetKey(db, stop, stop_p);
}
if (end) {
end_p = &end_key;
}
if (c_data && SvOK(c_data)) {
hash = (HV*) SvRV(c_data) ;
cmpt_p = & cmpt;
cmpt.compact_fillpercent = GetValue_iv(hash,"compact_fillpercent") ;
cmpt.compact_timeout = (db_timeout_t) GetValue_iv(hash, "compact_timeout");
}
RETVAL = (db->dbp)->compact(db->dbp, db->txn, start_p, stop_p, cmpt_p, flags, end_p);
if (RETVAL == 0 && hash) {
hv_store_iv(hash, "compact_deadlock", cmpt.compact_deadlock) ;
hv_store_iv(hash, "compact_levels", cmpt.compact_levels) ;
hv_store_iv(hash, "compact_pages_free", cmpt.compact_pages_free) ;
hv_store_iv(hash, "compact_pages_examine", cmpt.compact_pages_examine) ;
hv_store_iv(hash, "compact_pages_truncated", cmpt.compact_pages_truncated) ;
}
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok $ret == 0, " Created some data" ;
my $key;
my $end;
my %hash;
$hash{compact_filepercent} = 20;
ok $db->compact("red", "green", \%hash, 0, $end) == 0, " Compacted ok";
if (0)
{
diag "end at $end";
for my $key (sort keys %hash)
{
diag "[$key][$hash{$key}]\n";
}
( run in 0.419 second using v1.01-cache-2.11-cpan-709fd43a63f )