Exemplo n.º 1
0
 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Move forward to next element
  * @link http://php.net/manual/en/iterator.next.php
  * @return void Any returned value is ignored.
  */
 public function next()
 {
     do {
         $this->line = $this->serializer->fgets($this->resource);
     } while ($this->line == "\n");
     if ($this->line !== FALSE) {
         $this->key++;
     }
 }
Exemplo n.º 2
0
 /**
  * Scan TSV file and return the keys, offsets and lengths of each line
  *
  * @param string $tsv
  * @param int[] $sortPositions
  * @param TsvSerializerInterface $serializer
  * @return array
  */
 private function index($tsv, $sortPositions, $serializer)
 {
     $keys = array();
     $offsets = array();
     $lengths = array();
     $resource = $this->fopen($tsv, "r");
     $offset = $this->ftell($resource);
     while (($line = $serializer->fgets($resource)) !== FALSE) {
         if ($line == "\n") {
             continue;
         }
         $values = $serializer->unserialize($line);
         $keys[] = $this->constructKey($values, $sortPositions);
         $offsets[] = $offset;
         $lengths[] = ($newOffset = $this->ftell($resource)) - $offset;
         $offset = $newOffset;
     }
     $this->close($resource);
     return array($keys, $offsets, $lengths);
 }