當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Search_Lucene_Storage_File::writeVInt方法代碼示例

本文整理匯總了PHP中Zend_Search_Lucene_Storage_File::writeVInt方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Search_Lucene_Storage_File::writeVInt方法的具體用法?PHP Zend_Search_Lucene_Storage_File::writeVInt怎麽用?PHP Zend_Search_Lucene_Storage_File::writeVInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Search_Lucene_Storage_File的用法示例。


在下文中一共展示了Zend_Search_Lucene_Storage_File::writeVInt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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) {
         $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

示例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) {
         $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

示例3: _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


注:本文中的Zend_Search_Lucene_Storage_File::writeVInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。