當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Index::getParser方法代碼示例

本文整理匯總了PHP中Index::getParser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Index::getParser方法的具體用法?PHP Index::getParser怎麽用?PHP Index::getParser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Index的用法示例。


在下文中一共展示了Index::getParser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getData

 /**
  * Returns the data
  *
  * @return String
  */
 public function getData()
 {
     if (is_null($this->data)) {
         $this->data = $this->index->getParser()->getData($this->getOffset());
     }
     return $this->data;
 }
開發者ID:malkusch,項目名稱:php-index,代碼行數:12,代碼來源:Result.php

示例2: readKeys

 /**
  * Returns keys from a offset
  * 
  * The read range will be increased until at least one key will be found
  * or the end of file was reached.
  *
  * @param int $offset
  * @param int $direction
  * @return array
  * @throws IOIndexException
  */
 public function readKeys($offset, $direction, $hints = Parser::HINT_NONE)
 {
     // If reading backwards, shift the offset left
     $shiftedOffset = $direction == self::DIRECTION_BACKWARD ? $offset - $this->getReadLength() : $offset;
     //TODO shift to a blocksize chunk
     // Don't shift too far
     if ($shiftedOffset < 0) {
         $shiftedOffset = 0;
     }
     // Read data
     \fseek($this->index->getFile()->getFilePointer(), $shiftedOffset);
     $data = \fread($this->index->getFile()->getFilePointer(), $this->getReadLength());
     if ($data === false) {
         if (\feof($this->index->getFile()->getFilePointer())) {
             return array();
         } else {
             throw new IOIndexException("Could not read file");
         }
     }
     // Parse the read data
     $keys = $this->index->getParser()->parseKeys($data, $shiftedOffset, $hints);
     // Read more data if no keys were found
     if (empty($keys)) {
         // Only increase if there exists more data
         if ($direction == self::DIRECTION_BACKWARD && $shiftedOffset == 0) {
             return array();
         } elseif ($direction == self::DIRECTION_FORWARD && $shiftedOffset + $this->getReadLength() >= $this->index->getFile()->getFileSize()) {
             return array();
         }
         $this->increaseReadLength();
         return $this->readKeys($offset, $direction);
     }
     return $keys;
 }
開發者ID:malkusch,項目名稱:php-index,代碼行數:45,代碼來源:KeyReader.php


注:本文中的Index::getParser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。