1Ace::Iterator(3)      User Contributed Perl Documentation     Ace::Iterator(3)
2
3
4

NAME

6       Ace::Iterator - Iterate Across an ACEDB Query
7

SYNOPSIS

9           use Ace;
10           $db = Ace->connect(-host => 'beta.crbm.cnrs-mop.fr',
11                              -port => 20000100);
12
13           $i  = $db->fetch_many(Sequence=>'*');  # fetch a cursor
14           while ($obj = $i->next) {
15              print $obj->asTable;
16           }
17

DESCRIPTION

19       The Ace::Iterator class implements a persistent query on an Ace
20       database.  You can create multiple simultaneous queries and retrieve
21       objects from each one independently of the others.  This is useful when
22       a query is expected to return more objects than can easily fit into
23       memory.  The iterator is essentially a database "cursor."
24
25   new() Method
26         $iterator = Ace::Iterator->new(-db        => $db,
27                                        -query     => $query,
28                                        -filled    => $filled,
29                                        -chunksize => $chunksize);
30
31       An Ace::Iterator is returned by the Ace accessor's object's
32       fetch_many() method. You usually will not have cause to call the new()
33       method directly.  If you do so, the parameters are as follows:
34
35       -db The Ace database accessor object to use.
36
37       -query
38           A query, written in Ace query language, to pass to the database.
39           This query should return a list of objects.
40
41       -filled
42           If true, then retrieve complete objects from the database, rather
43           than empty object stubs.  Retrieving filled objects uses more
44           memory and network bandwidth than retrieving unfilled objects, but
45           it's recommended if you know in advance that you will be accessing
46           most or all of the objects' fields, for example, for the purposes
47           of displaying the objects.
48
49       -chunksize
50           The iterator will fetch objects from the database in chunks
51           controlled by this argument.  The default is 40.  You may want to
52           tune the chunksize to optimize the retrieval for your application.
53
54   next() method
55         $object = $iterator->next;
56
57       This method retrieves the next object from the query, performing
58       whatever database accesses it needs.  After the last object has been
59       fetched, the next() will return undef.  Usually you will call next()
60       inside a loop like this:
61
62         while (my $object = $iterator->next) {
63            # do something with $object
64         }
65
66       Because of the way that object caching works, next() will be most
67       efficient if you are only looping over one iterator at a time.
68       Although parallel access will work correctly, it will be less efficient
69       than serial access.  If possible, avoid this type of code:
70
71         my $iterator1 = $db->fetch_many(-query=>$query1);
72         my $iterator2 = $db->fetch_many(-query=>$query2);
73         do {
74            my $object1 = $iterator1->next;
75            my $object2 = $iterator2->next;
76         } while $object1 && $object2;
77

SEE ALSO

79       Ace, Ace::Model, Ace::Object
80

AUTHOR

82       Lincoln Stein <lstein@cshl.org> with extensive help from Jean Thierry-
83       Mieg <mieg@kaa.crbm.cnrs-mop.fr>
84
85       Copyright (c) 1997-1998 Cold Spring Harbor Laboratory
86
87       This library is free software; you can redistribute it and/or modify it
88       under the same terms as Perl itself.  See DISCLAIMER.txt for
89       disclaimers of warranty.
90
91
92
93perl v5.32.0                      2020-07-28                  Ace::Iterator(3)
Impressum