本文整理汇总了PHP中Zend_Search_Lucene_Storage_Directory类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Storage_Directory类的具体用法?PHP Zend_Search_Lucene_Storage_Directory怎么用?PHP Zend_Search_Lucene_Storage_Directory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Search_Lucene_Storage_Directory类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getActualGeneration
public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory)
{
require_once 'Zend/Search/Lucene/Exception.php';
try {
for ($count = 0; $count < self::GENERATION_RETRIEVE_COUNT; $count++) {
// Try to get generation file
$genFile = $directory->getFileObject('segments.gen', false);
$format = $genFile->readInt();
if ($format != (int) 0xfffffffe) {
throw new Zend_Search_Lucene_Exception('Wrong segments.gen file format');
}
$gen1 = $genFile->readLong();
$gen2 = $genFile->readLong();
if ($gen1 == $gen2) {
return $gen1;
}
usleep(self::GENERATION_RETRIEVE_PAUSE * 1000);
}
// All passes are failed
throw new Zend_Search_Lucene_Exception('Index is under processing now');
} catch (Zend_Search_Lucene_Exception $e) {
if (strpos($e->getMessage(), 'is not readable') !== false) {
try {
// Try to open old style segments file
$segmentsFile = $directory->getFileObject('segments', false);
// It's pre-2.1 index
return 0;
} catch (Zend_Search_Lucene_Exception $e) {
if (strpos($e->getMessage(), 'is not readable') !== false) {
return -1;
} else {
throw $e;
}
}
} else {
throw $e;
}
}
return -1;
}
开发者ID:hackingman,项目名称:TubeX,代码行数:40,代码来源:Lucene.php
示例2: createIndex
public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
{
if ($generation == 0) {
// Create index in pre-2.1 mode
foreach ($directory->fileList() as $file) {
if ($file == 'deletable' || $file == 'segments' || isset(self::$_indexExtensions[substr($file, strlen($file) - 4)]) || preg_match('/\\.f\\d+$/i', $file)) {
$directory->deleteFile($file);
}
}
$segmentsFile = $directory->createFile('segments');
$segmentsFile->writeInt((int) 0xffffffff);
// write version (is initialized by current time
// $segmentsFile->writeLong((int)microtime(true));
$version = microtime(true);
$segmentsFile->writeInt((int) ($version / ((double) 0xffffffff + 1)));
$segmentsFile->writeInt((int) ($version & 0xffffffff));
// write name counter
$segmentsFile->writeInt($nameCount);
// write segment counter
$segmentsFile->writeInt(0);
$deletableFile = $directory->createFile('deletable');
// write counter
$deletableFile->writeInt(0);
} else {
$genFile = $directory->createFile('segments.gen');
$genFile->writeInt((int) 0xfffffffe);
// Write generation two times
$genFile->writeLong($generation);
$genFile->writeLong($generation);
$segmentsFile = $directory->createFile(Zend_Search_Lucene::getSegmentFileName($generation));
$segmentsFile->writeInt((int) 0xfffffffd);
// write version (is initialized by current time
// $segmentsFile->writeLong((int)microtime(true));
$version = microtime(true);
$segmentsFile->writeInt((int) ($version / ((double) 0xffffffff + 1)));
$segmentsFile->writeInt((int) ($version & 0xffffffff));
// write name counter
$segmentsFile->writeInt($nameCount);
// write segment counter
$segmentsFile->writeInt(0);
}
}
开发者ID:hackingman,项目名称:TubeX,代码行数:42,代码来源:Writer.php
示例3: releaseOptimizationLock
/**
* Release exclusive optimization lock
*
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
*/
public static function releaseOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
$lock = $lockDirectory->getFileObject(self::OPTIMIZATION_LOCK_FILE);
$lock->unlock();
}
开发者ID:nfouka,项目名称:jobbet_sf2.5,代码行数:10,代码来源:LockManager.php
示例4: releaseOptimizationLock
/**
* Release exclusive optimization lock
*
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
*/
public static function releaseOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
$lockDirectory->deleteFile(self::OPTIMIZATION_LOCK_FILE);
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:9,代码来源:SoftLockManager.php
示例5: getActualGeneration
public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory)
{
try {
for ($count = 0; $count < self::GENERATION_RETRIEVE_COUNT; $count++) {
$genFile = $directory->getFileObject('segments.gen', false);
$format = $genFile->readInt();
if ($format != (int) 0xfffffffe) {
throw new Zend_Search_Lucene_Exception('Wrong segments.gen file format');
}
$gen1 = $genFile->readLong();
$gen2 = $genFile->readLong();
if ($gen1 == $gen2) {
return $gen1;
}
usleep(self::GENERATION_RETRIEVE_PAUSE * 1000);
}
throw new Zend_Search_Lucene_Exception('Index is under processing now');
} catch (Zend_Search_Lucene_Exception $e) {
if (strpos($e->getMessage(), 'is not readable') !== false) {
try {
$segmentsFile = $directory->getFileObject('segments', false);
return 0;
} catch (Zend_Search_Lucene_Exception $e) {
if (strpos($e->getMessage(), 'is not readable') !== false) {
return -1;
} else {
throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
}
}
} else {
throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
}
}
return -1;
}
开发者ID:Blu2z,项目名称:implsk,代码行数:35,代码来源:Zend_Search_Lucene.php
示例6: __destruct
/**
* Object destructor
*/
public function __destruct()
{
$this->commit();
if ($this->_closeDirOnExit) {
$this->_directory->close();
}
}
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:10,代码来源:Lucene.php
示例7: _generateCFS
/**
* Generate compound index file
*/
protected function _generateCFS()
{
$cfsFile = $this->_directory->createFile($this->_name . '.cfs');
$cfsFile->writeVInt(count($this->_files));
$dataOffsetPointers = array();
foreach ($this->_files as $fileName) {
$dataOffsetPointers[$fileName] = $cfsFile->tell();
$cfsFile->writeLong(0);
// write dummy data
$cfsFile->writeString($fileName);
}
foreach ($this->_files as $fileName) {
// Get actual data offset
$dataOffset = $cfsFile->tell();
// Seek to the data offset pointer
$cfsFile->seek($dataOffsetPointers[$fileName]);
// Write actual data offset value
$cfsFile->writeLong($dataOffset);
// Seek back to the end of file
$cfsFile->seek($dataOffset);
$dataFile = $this->_directory->getFileObject($fileName);
$byteCount = $this->_directory->fileLength($fileName);
while ($byteCount > 0) {
$data = $dataFile->readBytes(min($byteCount, 131072));
$byteCount -= strlen($data);
$cfsFile->writeBytes($data);
}
$this->_directory->deleteFile($fileName);
}
}
开发者ID:5haman,项目名称:knowledgetree,代码行数:33,代码来源:SegmentWriter.php
示例8: __destruct
/**
* Object destructor
*/
public function __destruct()
{
$this->commit();
// Free shared lock
$this->_lock->unlock();
if ($this->_closeDirOnExit) {
$this->_directory->close();
}
}
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:12,代码来源:Lucene.php
示例9: close
/**
* Close current index and free resources
*
* @internal
*/
public function close()
{
$this->commit();
// Free shared lock
$this->_lock->unlock();
if ($this->_closeDirOnExit) {
$this->_directory->close();
}
$this->_directory = null;
$this->_writer = null;
$this->_segmentInfos = null;
}
开发者ID:josephholsten,项目名称:swaplady,代码行数:17,代码来源:Lucene.php
示例10: _close
/**
* Close current index and free resources
*/
private function _close()
{
if ($this->_closed) {
// index is already closed and resources are cleaned up
return;
}
$this->commit();
if ($this->_closeDirOnExit) {
$this->_directory->close();
}
$this->_directory = null;
$this->_writer = null;
$this->_segmentInfos = null;
$this->_closed = true;
}
开发者ID:ismaelmelus,项目名称:home,代码行数:18,代码来源:Lucene.php
示例11: _updateSegments
/**
* Update segments file by adding current segment to a list
* @todo !!!!!Finish the implementation
*
* @throws Zend_Search_Lucene_Exception
*/
private function _updateSegments()
{
$segmentsFile = $this->_directory->getFileObject('segments');
$newSegmentFile = $this->_directory->createFile('segments.new');
$newSegmentFile->writeInt((int) 0xffffffff);
$newSegmentFile->writeLong($this->_version);
$newSegmentFile->writeInt($this->_segmentNameCounter);
$newSegmentFile->writeInt($this->_segments + count($this->_newSegments));
$segmentsFile->seek(20);
$newSegmentFile->writeBytes($segmentsFile->readBytes($this->_directory->fileLength('segments') - 20));
foreach ($this->_newSegments as $segmentName => $segmentInfo) {
$newSegmentFile->writeString($segmentName);
$newSegmentFile->writeInt($segmentInfo->count());
}
$this->_directory->renameFile('segments.new', 'segments');
}
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:22,代码来源:Writer.php
示例12: _newSegmentName
/**
* Get name for new segment
*
* @return string
*/
private function _newSegmentName()
{
Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
$generation = Zend_Search_Lucene::getActualGeneration($this->_directory);
$segmentsFile = $this->_directory->getFileObject(Zend_Search_Lucene::getSegmentFileName($generation), false);
$segmentsFile->seek(12);
// 12 = 4 (int, file format marker) + 8 (long, index version)
$segmentNameCounter = $segmentsFile->readInt();
$segmentsFile->seek(12);
// 12 = 4 (int, file format marker) + 8 (long, index version)
$segmentsFile->writeInt($segmentNameCounter + 1);
// Flash output to guarantee that wrong value will not be loaded between unlock and
// return (which calls $segmentsFile destructor)
$segmentsFile->flush();
Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
return '_' . base_convert($segmentNameCounter, 10, 36);
}
开发者ID:Sywooch,项目名称:forums,代码行数:22,代码来源:Writer.php
示例13: _close
/**
* Close current index and free resources
*/
private function _close()
{
if ($this->_closed) {
// index is already closed and resources are cleaned up
return;
}
$this->commit();
// Release "under processing" flag
Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);
if ($this->_closeDirOnExit) {
$this->_directory->close();
}
$this->_directory = null;
$this->_writer = null;
$this->_segmentInfos = null;
$this->_closed = true;
}
开发者ID:gauravstomar,项目名称:Pepool,代码行数:20,代码来源:Lucene.php
示例14: close
/**
* Close current index and free resources
*
* @internal
*/
public function close()
{
if ($this->_closed) {
// index is already closed and resources are cleaned up
return;
}
$this->commit();
// Free shared lock
$this->_lock->unlock();
if ($this->_closeDirOnExit) {
$this->_directory->close();
}
$this->_directory = null;
$this->_writer = null;
$this->_segmentInfos = null;
$this->_closed = true;
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:22,代码来源:Lucene.php
示例15: _newSegmentName
/**
* Get name for new segment
*
* @return string
*/
private function _newSegmentName()
{
// Do not share file handler to get file updates from other sessions.
$segmentsFile = $this->_directory->getFileObject('segments', false);
// Get exclusive segments file lock
// We have guarantee, that we will not intersect with _updateSegments() call
// of other process, because it needs exclusive index lock and waits
// until all other searchers won't stop
if (!$segmentsFile->lock(LOCK_EX)) {
throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock');
}
$segmentsFile->seek(12);
// 12 = 4 (int, file format marker) + 8 (long, index version)
$segmentNameCounter = $segmentsFile->readInt();
$segmentsFile->seek(12);
// 12 = 4 (int, file format marker) + 8 (long, index version)
$segmentsFile->writeInt($segmentNameCounter + 1);
// Flash output to guarantee that wrong value will not be loaded between unlock and
// return (which calls $segmentsFile destructor)
$segmentsFile->flush();
$segmentsFile->unlock();
return '_' . base_convert($segmentNameCounter, 10, 36);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:28,代码来源:Writer.php
示例16: _newSegmentName
/**
* Get name for new segment
*
* @return string
*/
private function _newSegmentName()
{
$segmentsFile = $this->_directory->getFileObject('segments');
$segmentsFile->seek(12);
// 12 = 4 (int, file format marker) + 8 (long, index version)
$segmentNameCounter = $segmentsFile->readInt();
$segmentsFile->seek(12);
// 12 = 4 (int, file format marker) + 8 (long, index version)
$segmentsFile->writeInt($segmentNameCounter + 1);
return '_' . base_convert($segmentNameCounter, 10, 36);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:16,代码来源:Writer.php
注:本文中的Zend_Search_Lucene_Storage_Directory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论