Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > c0b2316b5320756fc35b43f35335d7ce > files > 146

perl-AcePerl-1.920.0-1mdv2010.0.i586.rpm

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ace::Iterator - Iterate Across an ACEDB Query</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">


<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<!--

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#new___method"><code>new()</code> Method</a></li>
		<li><a href="#next___method"><code>next()</code> method</a></li>
	</ul>

	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#author">AUTHOR</a></li>
</ul>

-->


</div>
<!-- INDEX END -->

<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Ace::Iterator - Iterate Across an ACEDB Query</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
    use Ace;
    $db = Ace-&gt;connect(-host =&gt; 'beta.crbm.cnrs-mop.fr',
                       -port =&gt; 20000100);</pre>
<pre>
    $i  = $db-&gt;fetch_many(Sequence=&gt;'*');  # fetch a cursor
    while ($obj = $i-&gt;next) {
       print $obj-&gt;asTable;
    }</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The Ace::Iterator class implements a persistent query on an Ace
database.  You can create multiple simultaneous queries and retrieve
objects from each one independently of the others.  This is useful
when a query is expected to return more objects than can easily fit
into memory.  The iterator is essentially a database &quot;cursor.&quot;</p>
<p>
</p>
<h2><a name="new___method"><code>new()</code> Method</a></h2>
<pre>
  $iterator = Ace::Iterator-&gt;new(-db        =&gt; $db,
                                 -query     =&gt; $query,
                                 -filled    =&gt; $filled,
                                 -chunksize =&gt; $chunksize);</pre>
<p>An Ace::Iterator is returned by the Ace accessor's object's
<code>fetch_many()</code> method. You usually will not have cause to call the <code>new()</code>
method directly.  If you do so, the parameters are as follows:</p>
<dl>
<dt><strong><a name="db" class="item">-db</a></strong>

<dd>
<p>The Ace database accessor object to use.</p>
</dd>
</li>
<dt><strong><a name="query" class="item">-query</a></strong>

<dd>
<p>A query, written in Ace query language, to pass to the database.  This
query should return a list of objects.</p>
</dd>
</li>
<dt><strong><a name="filled" class="item">-filled</a></strong>

<dd>
<p>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.</p>
</dd>
</li>
<dt><strong><a name="chunksize" class="item">-chunksize</a></strong>

<dd>
<p>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.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="next___method"><code>next()</code> method</a></h2>
<pre>
  $object = $iterator-&gt;next;</pre>
<p>This method retrieves the next object from the query, performing
whatever database accesses it needs.  After the last object has been
fetched, the <code>next()</code> will return undef.  Usually you will call <code>next()</code>
inside a loop like this:</p>
<pre>
  while (my $object = $iterator-&gt;next) {
     # do something with $object
  }</pre>
<p>Because of the way that object caching works, <code>next()</code> 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.  If possible, avoid this type of code:</p>
<pre>
  my $iterator1 = $db-&gt;fetch_many(-query=&gt;$query1);
  my $iterator2 = $db-&gt;fetch_many(-query=&gt;$query2);
  do {
     my $object1 = $iterator1-&gt;next;
     my $object2 = $iterator2-&gt;next;
  } while $object1 &amp;&amp; $object2;</pre>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="/AcePerl/docs/./Ace.html">the Ace manpage</a>, <a href="/AcePerl/docs/./Ace/Model.html">the Ace::Model manpage</a>, <a href="/AcePerl/docs/./Ace/Object.html">the Ace::Object manpage</a></p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Lincoln Stein &lt;<a href="mailto:lstein@cshl.org">lstein@cshl.org</a>&gt; with extensive help from Jean
Thierry-Mieg &lt;<a href="mailto:mieg@kaa.crbm.cnrs-mop.fr">mieg@kaa.crbm.cnrs-mop.fr</a>&gt;</p>
<p>Copyright (c) 1997-1998 Cold Spring Harbor Laboratory</p>
<p>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.</p>

</body>

</html>