Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 10451

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>This factory method creates a hash from a file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="quickhashstringinthash.getsize.html">QuickHashStringIntHash::getSize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="quickhashstringinthash.loadfromstring.html">QuickHashStringIntHash::loadFromString</a></div>
 <div class="up"><a href="class.quickhashstringinthash.html">QuickHashStringIntHash</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="quickhashstringinthash.loadfromfile" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">QuickHashStringIntHash::loadFromFile</h1>
  <p class="verinfo">(No version information available, might only be in SVN)</p><p class="refpurpose"><span class="refname">QuickHashStringIntHash::loadFromFile</span> &mdash; <span class="dc-title">This factory method creates a hash from a file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-quickhashstringinthash.loadfromfile-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="type"><a href="class.quickhashstringinthash.html" class="type QuickHashStringIntHash">QuickHashStringIntHash</a></span> <span class="methodname"><strong>QuickHashStringIntHash::loadFromFile</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   This factory method creates a new hash from a definition file on disk. The
   file format consists of a signature &#039;QH\0x21\0&#039;, the number of elements as
   a 32 bit signed integer in system Endianness, an unsigned 32 bit integer
   containing the number of element data to follow in characters. This element
   data contains all the strings. The follows another signed 32 bit integer
   containing the number of bucket lists.  After the header and the strings,
   the elements follow. They are ordered by bucket list so that the keys don&#039;t
   have to be hashed in order to restore the hash. For each bucket list, the
   following information is stored (all as 32 bit integers): the bucket list
   index, the number of elements in that list, and then in pairs of two
   unsigned 32 bit integers the elements, where the first one is the index
   into the string list containing the keys, and the second one the value.  An
   example could be:
  </p>
  <p class="para">
   <div class="example" id="example-5157">
    <p><strong>Example #1 QuickHash StringIntHash file format</strong></p>
    <div class="example-contents screen"><div class="descriptioncode"><pre class="descriptioncode">00000000  51 48 21 00 02 00 00 00  09 00 00 00 40 00 00 00  |QH!.........@...|
00000010  4f 4e 45 00 4e 49 4e 45  00 07 00 00 00 01 00 00  |ONE.NINE........|
00000020  00 00 00 00 00 01 00 00  00 2f 00 00 00 01 00 00  |........./......|
00000030  00 04 00 00 00 03 00 00  00                       |.........|
00000039</pre>
</div></div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-5158">
    <p><strong>Example #2 QuickHash IntHash file format</strong></p>
    <div class="example-contents screen"><div class="descriptioncode"><pre class="descriptioncode">header signature (&#039;QH&#039;; key type: 2; value type: 1; filler: \0x00)
00000000  51 48 21 00

number of elements:
00000004  02 00 00 00

length of string values (9 characters):
00000008  09 00 00 00

number of hash bucket lists (this is configured for hashes as argument to the
constructor normally, 64 in this case):
0000000C  40 00 00 00

string values:
00000010  4f 4e 45 00 4e 49 4e 45  00

bucket lists:
  bucket list 1 (with key 7, and 1 element):
    header:
    07 00 00 00 01 00 00 00
    elements (key index: 0 (&#039;ONE&#039;), value = 0):
    00 00 00 00 01 00 00 00
  bucket list 2 (with key 0x2f, and 1 element):
    header:
    2f 00 00 00 01 00 00 00
    elements (key index: 4 (&#039;NINE&#039;), value = 3):
    04 00 00 00 03 00 00 00</pre>
</div></div>
   </div>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-quickhashstringinthash.loadfromfile-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">filename</code></em></span>
     <dd>

      <p class="para">
       The filename of the file to read the hash from.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">size</code></em></span>
     <dd>

      <p class="para">
       The amount of bucket lists to configure. The number you pass in will be
       automatically rounded up to the next power of two. It is also
       automatically limited from 4 to 4194304.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">options</code></em></span>
     <dd>

      <p class="para">
       The same options that the class&#039; constructor takes; except that the size
       option is ignored. It is read from the file format (unlike the
       QuickHashIntHash and QuickHashIntStringHash classes, where it is
       automatically calculated from the number of entries in the hash.)
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-quickhashstringinthash.loadfromfile-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a new QuickHashStringIntHash.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-quickhashstringinthash.loadfromfile-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-5159">
    <p><strong>Example #3  <span class="function"><strong>QuickHashStringIntHash::loadFromFile()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">__FILE__&nbsp;</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"/simple.hash.string"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$hash&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">QuickHashStringIntHash</span><span style="color: #007700">::</span><span style="color: #0000BB">loadFromFile</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$file</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">QuickHashStringIntHash</span><span style="color: #007700">::</span><span style="color: #0000BB">DO_NOT_USE_ZEND_ALLOC<br /></span><span style="color: #007700">);<br />foreach(&nbsp;</span><span style="color: #0000BB">range</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0x0f&nbsp;</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">48712&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">1631</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$k&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">base_convert</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">36&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$k</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'&nbsp;=&gt;&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$hash</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$k&nbsp;</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
11l4 =&gt; 48712
12uf =&gt; 50343
143q =&gt; 51974
15d1 =&gt; 53605
16mc =&gt; 55236
17vn =&gt; 56867
194y =&gt; 58498
1ae9 =&gt; 60129
1bnk =&gt; 61760
1cwv =&gt; 63391
1e66 =&gt; 65022
1ffh =&gt; 66653
1gos =&gt; 68284
1hy3 =&gt; 69915
1j7e =&gt; 71546
1kgp =&gt; 73177
</pre></div>
    </div>
   </div>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="quickhashstringinthash.getsize.html">QuickHashStringIntHash::getSize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="quickhashstringinthash.loadfromstring.html">QuickHashStringIntHash::loadFromString</a></div>
 <div class="up"><a href="class.quickhashstringinthash.html">QuickHashStringIntHash</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>