当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Search_Lucene_Storage_Directory_Filesystem::fileExists方法代码示例

本文整理汇总了PHP中Zend_Search_Lucene_Storage_Directory_Filesystem::fileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Storage_Directory_Filesystem::fileExists方法的具体用法?PHP Zend_Search_Lucene_Storage_Directory_Filesystem::fileExists怎么用?PHP Zend_Search_Lucene_Storage_Directory_Filesystem::fileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Search_Lucene_Storage_Directory_Filesystem的用法示例。


在下文中一共展示了Zend_Search_Lucene_Storage_Directory_Filesystem::fileExists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFilesystem

 public function testFilesystem()
 {
     $tempPath = dirname(__FILE__) . '/_tempFiles/_files';
     if (is_dir($tempPath)) {
         // remove files from temporary direcytory
         $dir = opendir($tempPath);
         while (($file = readdir($dir)) !== false) {
             if (!is_dir($tempPath . '/' . $file)) {
                 @unlink($tempPath . '/' . $file);
             }
         }
         closedir($dir);
     }
     $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($tempPath);
     $this->assertTrue($directory instanceof Zend_Search_Lucene_Storage_Directory);
     $this->assertEquals(count($directory->fileList()), 0);
     $fileObject = $directory->createFile('file1');
     $this->assertTrue($fileObject instanceof Zend_Search_Lucene_Storage_File);
     unset($fileObject);
     $this->assertEquals($directory->fileLength('file1'), 0);
     $this->assertEquals(count(array_diff($directory->fileList(), array('file1'))), 0);
     $directory->deleteFile('file1');
     $this->assertEquals(count($directory->fileList()), 0);
     $this->assertFalse($directory->fileExists('file2'));
     $fileObject = $directory->createFile('file2');
     $this->assertEquals($directory->fileLength('file2'), 0);
     $fileObject->writeBytes('0123456789');
     unset($fileObject);
     $this->assertEquals($directory->fileLength('file2'), 10);
     $directory->renameFile('file2', 'file3');
     $this->assertEquals(count(array_diff($directory->fileList(), array('file3'))), 0);
     $modifiedAt1 = $directory->fileModified('file3');
     clearstatcache();
     $directory->touchFile('file3');
     $modifiedAt2 = $directory->fileModified('file3');
     sleep(1);
     clearstatcache();
     $directory->touchFile('file3');
     $modifiedAt3 = $directory->fileModified('file3');
     $this->assertTrue($modifiedAt2 >= $modifiedAt1);
     $this->assertTrue($modifiedAt3 > $modifiedAt2);
     $fileObject = $directory->getFileObject('file3');
     $this->assertEquals($fileObject->readBytes($directory->fileLength('file3')), '0123456789');
     unset($fileObject);
     $fileObject = $directory->createFile('file3');
     $this->assertEquals($fileObject->readBytes($directory->fileLength('file3')), '');
     unset($fileObject);
     $directory->deleteFile('file3');
     $this->assertEquals(count($directory->fileList()), 0);
     $directory->close();
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:51,代码来源:DirectoryTest.php

示例2: openCompoundFile

 /**
  * Opens index file stoted within compound index file
  *
  * @param string $extension
  * @param boolean $shareHandler
  * @throws Zend_Search_Lucene_Exception
  * @return Zend_Search_Lucene_Storage_File
  */
 public function openCompoundFile($extension, $shareHandler = true)
 {
     $filename = $this->_name . $extension;
     // Try to open common file first
     if ($this->_directory->fileExists($filename)) {
         return $this->_directory->getFileObject($filename, $shareHandler);
     }
     if (!isset($this->_segFiles[$filename])) {
         throw new Zend_Search_Lucene_Exception('Index compound file doesn\'t contain ' . $filename . ' file.');
     }
     $file = $this->_directory->getFileObject($this->_name . '.cfs', $shareHandler);
     $file->seek($this->_segFiles[$filename]);
     return $file;
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:22,代码来源:SegmentInfo.php

示例3: _loadDictionaryIndex

    /**
     * Load terms dictionary index
     *
     * @throws Zend_Search_Lucene_Exception
     */
    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) =
                    Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData);

        $stiFileData = serialize(array($this->_termDictionary, $this->_termDictionaryInfos));
        $stiFile = $this->_directory->createFile($this->_name . '.sti');
        $stiFile->writeBytes($stiFileData);
    }
开发者ID:realfluid,项目名称:umbaugh,代码行数:34,代码来源:SegmentInfo.php

示例4: getTermInfo

 /**
  * Scans terms dictionary and returns term info
  *
  * @param Zend_Search_Lucene_Index_Term $term
  * @return Zend_Search_Lucene_Index_TermInfo
  */
 public function getTermInfo(Zend_Search_Lucene_Index_Term $term)
 {
     $termKey = $term->key();
     if (isset($this->_termInfoCache[$termKey])) {
         $termInfo = $this->_termInfoCache[$termKey];
         // Move termInfo to the end of cache
         unset($this->_termInfoCache[$termKey]);
         $this->_termInfoCache[$termKey] = $termInfo;
         return $termInfo;
     }
     if ($this->_termDictionary === null) {
         // Check, if index is already serialized
         if ($this->_directory->fileExists($this->_name . '.sti')) {
             // Prefetch dictionary index data
             $stiFile = $this->_directory->getFileObject($this->_name . '.sti');
             $stiFileData = $stiFile->readBytes($this->_directory->fileLength($this->_name . '.sti'));
             // Load dictionary index data
             list($this->_termDictionary, $this->_termDictionaryInfos) = unserialize($stiFileData);
         } else {
             // Prefetch dictionary index data
             $tiiFile = $this->openCompoundFile('.tii');
             $tiiFileData = $tiiFile->readBytes($this->compoundFileLength('.tii'));
             // Load dictionary index data
             list($this->_termDictionary, $this->_termDictionaryInfos) = Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData);
             $stiFileData = serialize(array($this->_termDictionary, $this->_termDictionaryInfos));
             $stiFile = $this->_directory->createFile($this->_name . '.sti');
             $stiFile->writeBytes($stiFileData);
         }
     }
     $searchField = $this->getFieldNum($term->field);
     if ($searchField == -1) {
         return null;
     }
     $searchDicField = $this->_getFieldPosition($searchField);
     // search for appropriate value in dictionary
     $lowIndex = 0;
     $highIndex = count($this->_termDictionary) - 1;
     while ($highIndex >= $lowIndex) {
         // $mid = ($highIndex - $lowIndex)/2;
         $mid = $highIndex + $lowIndex >> 1;
         $midTerm = $this->_termDictionary[$mid];
         $fieldNum = $this->_getFieldPosition($midTerm[0]);
         $delta = $searchDicField - $fieldNum;
         if ($delta == 0) {
             $delta = strcmp($term->text, $midTerm[1]);
         }
         if ($delta < 0) {
             $highIndex = $mid - 1;
         } elseif ($delta > 0) {
             $lowIndex = $mid + 1;
         } else {
             // return $this->_termDictionaryInfos[$mid]; // We got it!
             $a = $this->_termDictionaryInfos[$mid];
             $termInfo = new Zend_Search_Lucene_Index_TermInfo($a[0], $a[1], $a[2], $a[3], $a[4]);
             // Put loaded termInfo into cache
             $this->_termInfoCache[$termKey] = $termInfo;
             return $termInfo;
         }
     }
     if ($highIndex == -1) {
         // Term is out of the dictionary range
         return null;
     }
     $prevPosition = $highIndex;
     $prevTerm = $this->_termDictionary[$prevPosition];
     $prevTermInfo = $this->_termDictionaryInfos[$prevPosition];
     $tisFile = $this->openCompoundFile('.tis');
     $tiVersion = $tisFile->readInt();
     if ($tiVersion != (int) 0.0) {
         throw new Zend_Search_Lucene_Exception('Wrong TermInfoFile file format');
     }
     $termCount = $tisFile->readLong();
     $indexInterval = $tisFile->readInt();
     $skipInterval = $tisFile->readInt();
     $tisFile->seek($prevTermInfo[4] - 20, SEEK_CUR);
     $termValue = $prevTerm[1];
     $termFieldNum = $prevTerm[0];
     $freqPointer = $prevTermInfo[1];
     $proxPointer = $prevTermInfo[2];
     for ($count = $prevPosition * $indexInterval + 1; $count <= $termCount && ($this->_getFieldPosition($termFieldNum) < $searchDicField || $this->_getFieldPosition($termFieldNum) == $searchDicField && strcmp($termValue, $term->text) < 0); $count++) {
         $termPrefixLength = $tisFile->readVInt();
         $termSuffix = $tisFile->readString();
         $termFieldNum = $tisFile->readVInt();
         $termValue = Zend_Search_Lucene_Index_Term::getPrefix($termValue, $termPrefixLength) . $termSuffix;
         $docFreq = $tisFile->readVInt();
         $freqPointer += $tisFile->readVInt();
         $proxPointer += $tisFile->readVInt();
         if ($docFreq >= $skipInterval) {
             $skipOffset = $tisFile->readVInt();
         } else {
             $skipOffset = 0;
         }
     }
     if ($termFieldNum == $searchField && $termValue == $term->text) {
//.........这里部分代码省略.........
开发者ID:renatosoares,项目名称:blog-zend1,代码行数:101,代码来源:SegmentInfo.php

示例5: compoundFileLength

 /**
  * Get compound file length
  *
  * @param string $extension
  * @return integer
  */
 public function compoundFileLength($extension)
 {
     $filename = $this->_name . $extension;
     // Try to get common file first
     if ($this->_directory->fileExists($filename)) {
         return $this->_directory->fileLength($filename);
     }
     if (!isset($this->_segFileSizes[$filename])) {
         throw new Zend_Search_Lucene_Exception('Index compound file doesn\'t contain ' . $filename . ' file.');
     }
     return $this->_segFileSizes[$filename];
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:SegmentInfo.php


注:本文中的Zend_Search_Lucene_Storage_Directory_Filesystem::fileExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。