The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DBIx::BatchChunker::LoopState - Loop state object for DBIx::BatchChunker

VERSION

version v1.0.1

SYNOPSIS

    sub chunk_method {
        my ($bc, $rs) = @_;

        my $loop_state = $bc->loop_state;
        # introspect stuff
    }

DESCRIPTION

This is the loop state object used during BatchChunker runs. It only exists within the BatchChunker execution loop, and would generally only be accessible through the coderef or method referenced within that loop.

This is a quasi-private object and its API may be subject to change, but the module is in a pretty stable state at this point. While permissions are available to write to the attributes, it is highly recommended to not do so unless you know exactly what you doing. These are mostly available for introspection of loop progress.

ATTRIBUTES

batch_chunker

Reference back to the parent DBIx::BatchChunker object.

progress_bar

The progress bar being used in the loop. This may be different than "progress_bar" in DBIx::BatchChunker, since it could be auto-generated.

If you're trying to access the progress bar for debug or display purposes, it's best to use this attribute:

    my $progress_bar = $bc->loop_state->progress_bar;
    $progress_bar->message('Found something here');

total_timer

Epoch timer for the start of the entire operation.

chunk_timer

Epoch timer for the start of each chunk.

start

The real start ID that the loop is currently on. May continue to exist within iterations if chunk resizing is trying to find a valid range. Otherwise, this value will become undef when a chunk is finally processed.

end

The real end ID that the loop is currently looking at. This is always redefined at the beginning of the loop.

prev_end

Last "processed" value of "end". This also includes skipped blocks. Used in "start" calculations and to determine if the end of the loop has been reached.

last_range

A hashref of min/max values used for the bisecting of one block, measured in chunk multipliers. Cleared out after a block has been processed or skipped.

last_timings

An arrayref of hashrefs, containing data for the previous 5 runs. This data is used for runtime targeting.

multiplier_range

The range (in units of "chunk_size") between the start and end IDs. This starts at 1 (at the beginning of the loop), but may expand or shrink depending on chunk count checks. Resets after block processing.

multiplier_step

Determines how fast "multiplier_range" increases, so that chunk resizing happens at an accelerated pace. Speeds or slows depending on what kind of limits the chunk count checks are hitting. Resets after block processing.

checked_count

A check counter to make sure the chunk resizing isn't taking too long. After ten checks, it will give up, assuming the block is safe to process.

chunk_size

The current chunk size, which might be adjusted by runtime targeting.

chunk_count

Records the results of the COUNT(*) query for chunk resizing.

prev_check

A short string recording what happened during the last chunk resizing check. Exists purely for debugging purposes.

prev_runtime

The number of seconds the previously processed chunk took to run, not including sleep time.

AUTHOR

Grant Street Group <developers@grantstreet.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 - 2023 by Grant Street Group.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)