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

PHP Zend_Search_Lucene_Storage_File类代码示例

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

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



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

示例1: _dumpTermDictEntry

 /**
  * Dump Term Dictionary segment file entry.
  * Used to write entry to .tis or .tii files
  *
  * @param Zend_Search_Lucene_Storage_File $dicFile
  * @param Zend_Search_Lucene_Index_Term $prevTerm
  * @param Zend_Search_Lucene_Index_Term $term
  * @param Zend_Search_Lucene_Index_TermInfo $prevTermInfo
  * @param Zend_Search_Lucene_Index_TermInfo $termInfo
  */
 protected function _dumpTermDictEntry(Zend_Search_Lucene_Storage_File $dicFile, &$prevTerm, Zend_Search_Lucene_Index_Term $term, &$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo)
 {
     if (isset($prevTerm) && $prevTerm->field == $term->field) {
         $matchedBytes = 0;
         $maxBytes = min(strlen($prevTerm->text), strlen($term->text));
         while ($matchedBytes < $maxBytes && $prevTerm->text[$matchedBytes] == $term->text[$matchedBytes]) {
             $matchedBytes++;
         }
         // Calculate actual matched UTF-8 pattern
         $prefixBytes = 0;
         $prefixChars = 0;
         while ($prefixBytes < $matchedBytes) {
             $charBytes = 1;
             if ((ord($term->text[$prefixBytes]) & 0xc0) == 0xc0) {
                 $charBytes++;
                 if (ord($term->text[$prefixBytes]) & 0x20) {
                     $charBytes++;
                     if (ord($term->text[$prefixBytes]) & 0x10) {
                         $charBytes++;
                     }
                 }
             }
             if ($prefixBytes + $charBytes > $matchedBytes) {
                 // char crosses matched bytes boundary
                 // skip char
                 break;
             }
             $prefixChars++;
             $prefixBytes += $charBytes;
         }
         // Write preffix length
         $dicFile->writeVInt($prefixChars);
         // Write suffix
         $dicFile->writeString(substr($term->text, $prefixBytes));
     } else {
         // Write preffix length
         $dicFile->writeVInt(0);
         // Write suffix
         $dicFile->writeString($term->text);
     }
     // Write field number
     $dicFile->writeVInt($term->field);
     // DocFreq (the count of documents which contain the term)
     $dicFile->writeVInt($termInfo->docFreq);
     $prevTerm = $term;
     if (!isset($prevTermInfo)) {
         // Write FreqDelta
         $dicFile->writeVInt($termInfo->freqPointer);
         // Write ProxDelta
         $dicFile->writeVInt($termInfo->proxPointer);
     } else {
         // Write FreqDelta
         $dicFile->writeVInt($termInfo->freqPointer - $prevTermInfo->freqPointer);
         // Write ProxDelta
         $dicFile->writeVInt($termInfo->proxPointer - $prevTermInfo->proxPointer);
     }
     // Write SkipOffset - it's not 0 when $termInfo->docFreq > self::$skipInterval
     if ($termInfo->skipOffset != 0) {
         $dicFile->writeVInt($termInfo->skipOffset);
     }
     $prevTermInfo = $termInfo;
 }
开发者ID:alefernie,项目名称:intranet,代码行数:72,代码来源:SegmentWriter.php


示例2: _dumpTermDictEntry

 /**
  * Dump Term Dictionary segment file entry.
  * Used to write entry to .tis or .tii files
  *
  * @param Zend_Search_Lucene_Storage_File $dicFile
  * @param Zend_Search_Lucene_Index_Term $prevTerm
  * @param Zend_Search_Lucene_Index_Term $term
  * @param Zend_Search_Lucene_Index_TermInfo $prevTermInfo
  * @param Zend_Search_Lucene_Index_TermInfo $termInfo
  */
 protected function _dumpTermDictEntry(Zend_Search_Lucene_Storage_File $dicFile, &$prevTerm, Zend_Search_Lucene_Index_Term $term, &$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo)
 {
     if (isset($prevTerm) && $prevTerm->field == $term->field) {
         $prefixLength = 0;
         while ($prefixLength < strlen($prevTerm->text) && $prefixLength < strlen($term->text) && $prevTerm->text[$prefixLength] == $term->text[$prefixLength]) {
             $prefixLength++;
         }
         // Write preffix length
         $dicFile->writeVInt($prefixLength);
         // Write suffix
         $dicFile->writeString(substr($term->text, $prefixLength));
     } else {
         // Write preffix length
         $dicFile->writeVInt(0);
         // Write suffix
         $dicFile->writeString($term->text);
     }
     // Write field number
     $dicFile->writeVInt($term->field);
     // DocFreq (the count of documents which contain the term)
     $dicFile->writeVInt($termInfo->docFreq);
     $prevTerm = $term;
     if (!isset($prevTermInfo)) {
         // Write FreqDelta
         $dicFile->writeVInt($termInfo->freqPointer);
         // Write ProxDelta
         $dicFile->writeVInt($termInfo->proxPointer);
     } else {
         // Write FreqDelta
         $dicFile->writeVInt($termInfo->freqPointer - $prevTermInfo->freqPointer);
         // Write ProxDelta
         $dicFile->writeVInt($termInfo->proxPointer - $prevTermInfo->proxPointer);
     }
     // Write SkipOffset - it's not 0 when $termInfo->docFreq > self::$skipInterval
     if ($termInfo->skipOffset != 0) {
         $dicFile->writeVInt($termInfo->skipOffset);
     }
     $prevTermInfo = $termInfo;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:49,代码来源:SegmentWriter.php


示例3: releaseWriteLock

 /**
  * Free exclusive write lock on the index
  * 
  * @param Zend_Search_Lucene_Storage_Directory $defaultLockDirectory
  * @param Zend_Search_Lucene_Storage_File      $lock
  */
 public static function releaseWriteLock(Zend_Search_Lucene_Storage_Directory $defaultLockDirectory, Zend_Search_Lucene_Storage_File $lock)
 {
     $lock->unlock();
     unset($lock);
     $defaultLockDirectory->deleteFile('write.lock');
 }
开发者ID:ismaelmelus,项目名称:home,代码行数:12,代码来源:Lucene.php


示例4: _dumpTermDictEntry

 protected function _dumpTermDictEntry(Zend_Search_Lucene_Storage_File $dicFile, &$prevTerm, Zend_Search_Lucene_Index_Term $term, &$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo)
 {
     if (isset($prevTerm) && $prevTerm->field == $term->field) {
         $matchedBytes = 0;
         $maxBytes = min(strlen($prevTerm->text), strlen($term->text));
         while ($matchedBytes < $maxBytes && $prevTerm->text[$matchedBytes] == $term->text[$matchedBytes]) {
             $matchedBytes++;
         }
         $prefixBytes = 0;
         $prefixChars = 0;
         while ($prefixBytes < $matchedBytes) {
             $charBytes = 1;
             if ((ord($term->text[$prefixBytes]) & 0xc0) == 0xc0) {
                 $charBytes++;
                 if (ord($term->text[$prefixBytes]) & 0x20) {
                     $charBytes++;
                     if (ord($term->text[$prefixBytes]) & 0x10) {
                         $charBytes++;
                     }
                 }
             }
             if ($prefixBytes + $charBytes > $matchedBytes) {
                 break;
             }
             $prefixChars++;
             $prefixBytes += $charBytes;
         }
         $dicFile->writeVInt($prefixChars);
         $dicFile->writeString(substr($term->text, $prefixBytes));
     } else {
         $dicFile->writeVInt(0);
         $dicFile->writeString($term->text);
     }
     $dicFile->writeVInt($term->field);
     $dicFile->writeVInt($termInfo->docFreq);
     $prevTerm = $term;
     if (!isset($prevTermInfo)) {
         $dicFile->writeVInt($termInfo->freqPointer);
         $dicFile->writeVInt($termInfo->proxPointer);
     } else {
         $dicFile->writeVInt($termInfo->freqPointer - $prevTermInfo->freqPointer);
         $dicFile->writeVInt($termInfo->proxPointer - $prevTermInfo->proxPointer);
     }
     if ($termInfo->skipOffset != 0) {
         $dicFile->writeVInt($termInfo->skipOffset);
     }
     $prevTermInfo = $termInfo;
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:48,代码来源:Zend_Search_Lucene.php


示例5: nextTerm

    /**
     * Scans terms dictionary and returns next term
     *
     * @return Zend_Search_Lucene_Index_Term|null
     */
    public function nextTerm()
    {
        if ($this->_tisFile === null  ||  $this->_termCount == 0) {
            $this->_lastTerm          = null;
            $this->_lastTermInfo      = null;
            $this->_lastTermPositions = null;
            $this->_docMap            = null;

            // may be necessary for "empty" segment
            $this->_tisFile = null;
            $this->_frqFile = null;
            $this->_prxFile = null;

            return null;
        }

        $termPrefixLength = $this->_tisFile->readVInt();
        $termSuffix       = $this->_tisFile->readString();
        $termFieldNum     = $this->_tisFile->readVInt();
        $termValue        = Zend_Search_Lucene_Index_Term::getPrefix($this->_lastTerm->text, $termPrefixLength) . $termSuffix;

        $this->_lastTerm = new Zend_Search_Lucene_Index_Term($termValue, $this->_fields[$termFieldNum]->name);

        $docFreq     = $this->_tisFile->readVInt();
        $freqPointer = $this->_lastTermInfo->freqPointer + $this->_tisFile->readVInt();
        $proxPointer = $this->_lastTermInfo->proxPointer + $this->_tisFile->readVInt();
        if ($docFreq >= $this->_skipInterval) {
            $skipOffset = $this->_tisFile->readVInt();
        } else {
            $skipOffset = 0;
        }

        $this->_lastTermInfo = new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipOffset);


        if ($this->_termsScanMode == self::SM_FULL_INFO  ||  $this->_termsScanMode == self::SM_MERGE_INFO) {
            $this->_lastTermPositions = array();

            $this->_frqFile->seek($this->_lastTermInfo->freqPointer + $this->_frqFileOffset, SEEK_SET);
            $freqs = array();   $docId = 0;
            for( $count = 0; $count < $this->_lastTermInfo->docFreq; $count++ ) {
                $docDelta = $this->_frqFile->readVInt();
                if( $docDelta % 2 == 1 ) {
                    $docId += ($docDelta-1)/2;
                    $freqs[ $docId ] = 1;
                } else {
                    $docId += $docDelta/2;
                    $freqs[ $docId ] = $this->_frqFile->readVInt();
                }
            }

            $this->_prxFile->seek($this->_lastTermInfo->proxPointer + $this->_prxFileOffset, SEEK_SET);
            foreach ($freqs as $docId => $freq) {
                $termPosition = 0;  $positions = array();

                for ($count = 0; $count < $freq; $count++ ) {
                    $termPosition += $this->_prxFile->readVInt();
                    $positions[] = $termPosition;
                }

                if (isset($this->_docMap[$docId])) {
                    $this->_lastTermPositions[$this->_docMap[$docId]] = $positions;
                }
            }
        }

        $this->_termCount--;
        if ($this->_termCount == 0) {
            $this->_tisFile = null;
            $this->_frqFile = null;
            $this->_prxFile = null;
        }

        return $this->_lastTerm;
    }
开发者ID:realfluid,项目名称:umbaugh,代码行数:80,代码来源:SegmentInfo.php


示例6: _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();

        // 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,代码行数:25,代码来源:Lucene.php


示例7: __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


示例8: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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