コード例 #1
0
 public function testCreate()
 {
     $directory = new \ZendSearch\Lucene\Storage\Directory\Filesystem(__DIR__ . '/_source/_files');
     $stiFile = $directory->getFileObject('_1.sti');
     $stiFileData = $stiFile->readBytes($directory->fileLength('_1.sti'));
     // Load dictionary index data
     list($termDictionary, $termDictionaryInfos) = unserialize($stiFileData);
     $segmentInfo = new \ZendSearch\Lucene\Index\SegmentInfo($directory, '_1', 2);
     $tiiFile = $segmentInfo->openCompoundFile('.tii');
     $tiiFileData = $tiiFile->readBytes($segmentInfo->compoundFileLength('.tii'));
     // Load dictionary index data
     list($loadedTermDictionary, $loadedTermDictionaryInfos) = \ZendSearch\Lucene\Index\DictionaryLoader::load($tiiFileData);
     $this->assertTrue($termDictionary == $loadedTermDictionary);
     $this->assertTrue($termDictionaryInfos == $loadedTermDictionaryInfos);
 }
コード例 #2
0
ファイル: SegmentInfo.php プロジェクト: avbrugen/uace-laravel
 /**
  * Load terms dictionary index
  *
  * @throws \ZendSearch\Lucene\Exception\ExceptionInterface
  */
 private function _loadDictionaryIndex()
 {
     // Check, if index is already serialized
     if ($this->_directory->fileExists($this->_name . '.sti')) {
         // Load serialized dictionary index data
         $stiFile = $this->_directory->getFileObject($this->_name . '.sti');
         $stiFileData = $stiFile->readBytes($this->_directory->fileLength($this->_name . '.sti'));
         // Load dictionary index data
         if (($unserializedData = @unserialize($stiFileData)) !== false) {
             list($this->_termDictionary, $this->_termDictionaryInfos) = $unserializedData;
             return;
         }
     }
     // Load data from .tii file and generate .sti file
     // Prefetch dictionary index data
     $tiiFile = $this->openCompoundFile('.tii');
     $tiiFileData = $tiiFile->readBytes($this->compoundFileLength('.tii'));
     // Load dictionary index data
     list($this->_termDictionary, $this->_termDictionaryInfos) = DictionaryLoader::load($tiiFileData);
     $stiFileData = serialize(array($this->_termDictionary, $this->_termDictionaryInfos));
     $stiFile = $this->_directory->createFile($this->_name . '.sti');
     $stiFile->writeBytes($stiFileData);
 }