Ace::Iterator(3pm)
π Ace::Iterator β the Ace::Iterator(3pm) manual, bestie edition π
okay so you found Ace::Iterator, a Perl module living its best life in the User Contributed Perl Documentation section, and honestly? it's giving cursor energy. let's get into it π¦
β¨ NAME β¨
Ace::Iterator β iterate across an ACEDB query. yes that's the whole name, short and iconic π
πΈ SYNOPSIS πΈ
use Ace;
$db = Ace->connect(-host => 'beta.crbm.cnrs-mop.fr',
-port => 20000100);
$i = $db->fetch_many(Sequence=>'*'); # fetch a cursor
while ($obj = $i->next) {
print $obj->asTable;
}
like, look at that. connect, grab a cursor, loop it, print it. no notes. π
π DESCRIPTION π
The Ace::Iterator class implements a persistent query on an Ace database. fr fr. you can have multiple simultaneous queries going at once and pull objects out of each one independently of the others β they do not talk to each other, they do not gossip, they mind their business π
and why do you care? bc this is the move when a query is expected to return more objects than can easily fit into memory. no cap. the iterator is essentially a database "cursor," so it just... holds your place and hands you one thing at a time. main character energy but make it polite β¨
π new() Method π
$iterator = Ace::Iterator->new(-db => $db,
-query => $query,
-filled => $filled,
-chunksize => $chunksize);
so an Ace::Iterator is returned by the Ace accessor's object's fetch_many() method. you usually will not have cause to call the new() method directly, bestie β let fetch_many() do it for you. but if you do call it yourself, here's the tea on the parameters:
-dbβ the Ace database accessor object to use. that's it, that's the whole vibe.-queryβ a query, written in Ace query language, to pass to the database. this query should return a list of objects. lowercase list, big deal list, either way π-filledβ if true, then retrieve complete objects from the database, rather than empty object stubs. retrieving filled objects uses more memory and network bandwidth than retrieving unfilled objects, but it's recommended if you know in advance that you will be accessing most or all of the objects' fields β for example, for the purposes of displaying the objects. basically: if you're gonna read the whole thing anyway, just get the whole thing π-chunksizeβ the iterator will fetch objects from the database in chunks controlled by this argument. the default is 40. you may want to tune the chunksize to optimize the retrieval for your application. it's giving β¨tunableβ¨
π¦ next() method π¦
$object = $iterator->next;
this method retrieves the next object from the query, performing whatever database accesses it needs along the way. after the last object has been fetched, next() will return undef. usually you will call next() inside a loop like this:
while (my $object = $iterator->next) {
# do something with $object
}
and now the part where i have to be real with you π because of the way that object caching works, next() will be most efficient if you are only looping over one iterator at a time. although parallel access will work correctly, it will be less efficient than serial access. so if possible, avoid this type of code:
my $iterator1 = $db->fetch_many(-query=>$query1);
my $iterator2 = $db->fetch_many(-query=>$query2);
do {
my $object1 = $iterator1->next;
my $object2 = $iterator2->next;
} while $object1 && $object2;
warning bestie π it works, it's just slower. don't come for me, come for the object cache.
π SEE ALSO π
AceAce::ModelAce::Object
go read those too, they're all in the same friend group π«Ά
π AUTHOR π
Lincoln Stein <lstein@cshl.org> with extensive help from Jean Thierry-Mieg <mieg@kaa.crbm.cnrs-mop.fr> β legends, honestly β
Copyright (c) 1997-1998 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.
that's the whole page, no crumbs left π this was perl v5.42.3, dated 2026-08-19, and the page is Ace::Iterator(3pm). slay, go loop responsibly π
β¨
π¦ where this page comes from
- ubuntu stonking: libace-perl 1.92-14build1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms