NAME

Alzabo::Runtime::Cursor - Base class for Alzabo cursors

SYNOPSIS

use Alzabo::Runtime::Cursor;

DESCRIPTION

This is the base class for cursors.

METHODS

new

Virtual method.

all_rows

Virtual method.

reset

Resets the cursor so that the next next call will return the first row of the set.

count

Returns

The number of rows returned by the cursor so far.

next_as_hash

Returns

The next row or rows in a hash, where the hash key is the table name and the hash value is the row object.

RATIONALE FOR CURSORS

Using cursors is definitely more complicated. However, there are two excellent reasons for using them: speed and memory savings. As an example, I did a test with the old code (which returned all its objects at once) against a table with about 8,000 rows using the Alzabo::Runtime::Table->all_rows method. Under the old implementation, it took significantly longer to return the first row. Even more importantly than that, the old implementation used up about 10MB of memory versus about 4MB! Now imagine that with a 1,000,000 row table.

Thus Alzabo uses cursors so it can scale better. This is a particularly big win in the case where you are working through a long list of rows and may stop before the end is reached. With cursors, Alzabo creates only as many rows as you need. Plus the start up time on your loop is much, much quicker. In the end, your program is quicker and less of a memory hog. This is good.

AUTHOR

Dave Rolsky, <autarch@urth.org>