• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Search_Lucene_Index_Writer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 public function __construct($directory = null, $create = false)
 {
     if ($directory === null) {
         require_once 'Zend/Search/Lucene/Exception.php';
         throw new Zend_Search_Exception('No index directory specified');
     }
     if ($directory instanceof Zend_Search_Lucene_Storage_Directory_Filesystem) {
         $this->_directory = $directory;
         $this->_closeDirOnExit = false;
     } else {
         $this->_directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($directory);
         $this->_closeDirOnExit = true;
     }
     $this->_segmentInfos = array();
     // Mark index as "under processing" to prevent other processes from premature index cleaning
     Zend_Search_Lucene_LockManager::obtainReadLock($this->_directory);
     $this->_generation = self::getActualGeneration($this->_directory);
     if ($create) {
         require_once 'Zend/Search/Lucene/Exception.php';
         try {
             Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
         } catch (Zend_Search_Lucene_Exception $e) {
             Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);
             if (strpos($e->getMessage(), 'Can\'t obtain exclusive index lock') === false) {
                 throw $e;
             } else {
                 throw new Zend_Search_Lucene_Exception('Can\'t create index. It\'s under processing now');
             }
         }
         if ($this->_generation == -1) {
             // Directory doesn't contain existing index, start from 1
             $this->_generation = 1;
             $nameCounter = 0;
         } else {
             // Directory contains existing index
             $segmentsFile = $this->_directory->getFileObject(self::getSegmentFileName($this->_generation));
             $segmentsFile->seek(12);
             // 12 = 4 (int, file format marker) + 8 (long, index version)
             $nameCounter = $segmentsFile->readInt();
             $this->_generation++;
         }
         Zend_Search_Lucene_Index_Writer::createIndex($this->_directory, $this->_generation, $nameCounter);
         Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
     }
     if ($this->_generation == -1) {
         require_once 'Zend/Search/Lucene/Exception.php';
         throw new Zend_Search_Lucene_Exception('Index doesn\'t exists in the specified directory.');
     } else {
         if ($this->_generation == 0) {
             $this->_readPre21SegmentsFile();
         } else {
             $this->_readSegmentsFile();
         }
     }
 }
开发者ID:hackingman,项目名称:TubeX,代码行数:55,代码来源:Lucene.php


示例2: __construct

 public function __construct($directory = null, $create = false)
 {
     if ($directory === null) {
         throw new Zend_Search_Exception('No index directory specified');
     }
     if (is_string($directory)) {
         $this->_directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($directory);
         $this->_closeDirOnExit = true;
     } else {
         $this->_directory = $directory;
         $this->_closeDirOnExit = false;
     }
     $this->_segmentInfos = array();
     Zend_Search_Lucene_LockManager::obtainReadLock($this->_directory);
     $this->_generation = self::getActualGeneration($this->_directory);
     if ($create) {
         try {
             Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
         } catch (Zend_Search_Lucene_Exception $e) {
             Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);
             if (strpos($e->getMessage(), 'Can\'t obtain exclusive index lock') === false) {
                 throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
             } else {
                 throw new Zend_Search_Lucene_Exception('Can\'t create index. It\'s under processing now', 0, $e);
             }
         }
         if ($this->_generation == -1) {
             $this->_generation = 1;
             $nameCounter = 0;
         } else {
             $segmentsFile = $this->_directory->getFileObject(self::getSegmentFileName($this->_generation));
             $segmentsFile->seek(12);
             $nameCounter = $segmentsFile->readInt();
             $this->_generation++;
         }
         Zend_Search_Lucene_Index_Writer::createIndex($this->_directory, $this->_generation, $nameCounter);
         Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
     }
     if ($this->_generation == -1) {
         throw new Zend_Search_Lucene_Exception('Index doesn\'t exists in the specified directory.');
     } else {
         if ($this->_generation == 0) {
             $this->_readPre21SegmentsFile();
         } else {
             $this->_readSegmentsFile();
         }
     }
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:48,代码来源:Zend_Search_Lucene.php


示例3: commit

 /**
  * Commit changes resulting from delete() or undeleteAll() operations.
  *
  * @todo undeleteAll processing.
  */
 public function commit()
 {
     if ($this->_hasChanges) {
         foreach ($this->_segmentInfos as $segInfo) {
             $segInfo->writeChanges();
         }
         $this->_hasChanges = false;
     }
     if ($this->_writer !== null) {
         $this->_writer->commit();
         $this->_updateDocCount();
     }
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:18,代码来源:Lucene.php


示例4: commit

 /**
  * Commit changes resulting from delete() or undeleteAll() operations.
  *
  * @todo delete() and undeleteAll processing.
  */
 public function commit()
 {
     if ($this->_writer !== null) {
         foreach ($this->_writer->commit() as $segmentName => $segmentInfo) {
             if ($segmentInfo !== null) {
                 $this->_segmentInfos[] = $segmentInfo;
                 $this->_docCount += $segmentInfo->count();
             } else {
                 foreach ($this->_segmentInfos as $segId => $segInfo) {
                     if ($segInfo->getName() == $segmentName) {
                         unset($this->_segmentInfos[$segId]);
                     }
                 }
             }
         }
     }
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:22,代码来源:Lucene.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Search_Lucene_Interface类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Search_Lucene_Index_TermsPriorityQueue类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap