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

PHP bitset_to_array函数代码示例

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

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



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

示例1: writeChanges

    /**
     * Write changes if it's necessary.
     *
     * This method must be invoked only from the Writer _updateSegments() method,
     * so index Write lock has to be already obtained.
     *
     * @internal
     * @throws Zend_Search_Lucene_Exceptions
     */
    public function writeChanges()
    {
        // Get new generation number
        $latestDelGen = $this->_detectLatestDelGen();

        if (!$this->_deletedDirty) {
        	// There was no deletions by current process

            if ($latestDelGen == $this->_delGen) {
            	// Delete file hasn't been updated by any concurrent process
            	return;
            } else if ($latestDelGen > $this->_delGen) {
            	// Delete file has been updated by some concurrent process
            	// Reload deletions file
            	$this->_delGen  = $latestDelGen;
            	$this->_deleted = $this->_loadDelFile();

            	return;
            } else {
            	require_once 'Zend/Search/Lucene/Exception.php';
            	throw new Zend_Search_Lucene_Exception('Delete file processing workflow is corrupted for the segment \'' . $this->_name . '\'.');
            }
        }

        if ($latestDelGen > $this->_delGen) {
        	// Merge current deletions with latest deletions file
        	$this->_delGen = $latestDelGen;

        	$latestDelete = $this->_loadDelFile();

        	if (extension_loaded('bitset')) {
        		$this->_deleted = bitset_union($this->_deleted, $latestDelete);
        	} else {
        		$this->_deleted += $latestDelete;
        	}
        }

        if (extension_loaded('bitset')) {
            $delBytes = $this->_deleted;
            $bitCount = count(bitset_to_array($delBytes));
        } else {
            $byteCount = floor($this->_docCount/8)+1;
            $delBytes = str_repeat(chr(0), $byteCount);
            for ($count = 0; $count < $byteCount; $count++) {
                $byte = 0;
                for ($bit = 0; $bit < 8; $bit++) {
                    if (isset($this->_deleted[$count*8 + $bit])) {
                        $byte |= (1<<$bit);
                    }
                }
                $delBytes[$count] = chr($byte);
            }
            $bitCount = count($this->_deleted);
        }

        if ($this->_delGen == -1) {
            // Set delete file generation number to 1
            $this->_delGen = 1;
        } else {
            // Increase delete file generation number by 1
            $this->_delGen++;
        }

        $delFile = $this->_directory->createFile($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del');
        $delFile->writeInt($this->_docCount);
        $delFile->writeInt($bitCount);
        $delFile->writeBytes($delBytes);

        $this->_deletedDirty = false;
    }
开发者ID:realfluid,项目名称:umbaugh,代码行数:79,代码来源:SegmentInfo.php


示例2: writeChanges

 /**
  * Write changes if it's necessary.
  */
 public function writeChanges()
 {
     if (!$this->_deletedDirty) {
         return;
     }
     if (extension_loaded('bitset')) {
         $delBytes = $this->_deleted;
         $bitCount = count(bitset_to_array($delBytes));
     } else {
         $byteCount = floor($this->_docCount / 8) + 1;
         $delBytes = str_repeat(chr(0), $byteCount);
         for ($count = 0; $count < $byteCount; $count++) {
             $byte = 0;
             for ($bit = 0; $bit < 8; $bit++) {
                 if (isset($this->_deleted[$count * 8 + $bit])) {
                     $byte |= 1 << $bit;
                 }
             }
             $delBytes[$count] = chr($byte);
         }
         $bitCount = count($this->_deleted);
     }
     $delFile = $this->_directory->createFile($this->_name . '.del');
     $delFile->writeInt($this->_docCount);
     $delFile->writeInt($bitCount);
     $delFile->writeBytes($delBytes);
     $this->_deletedDirty = false;
 }
开发者ID:renatosoares,项目名称:blog-zend1,代码行数:31,代码来源:SegmentInfo.php


示例3: writeChanges

 /**
  * Write changes if it's necessary.
  */
 public function writeChanges()
 {
     if (!$this->_deletedDirty) {
         return;
     }
     if (extension_loaded('bitset')) {
         $delBytes = $this->_deleted;
         $bitCount = count(bitset_to_array($delBytes));
     } else {
         $byteCount = floor($this->_docCount / 8) + 1;
         $delBytes = str_repeat(chr(0), $byteCount);
         for ($count = 0; $count < $byteCount; $count++) {
             $byte = 0;
             for ($bit = 0; $bit < 8; $bit++) {
                 if (isset($this->_deleted[$count * 8 + $bit])) {
                     $byte |= 1 << $bit;
                 }
             }
             $delBytes[$count] = chr($byte);
         }
         $bitCount = count($this->_deleted);
     }
     // Get new generation number
     $lock = Zend_Search_Lucene::obtainWriteLock($this->_directory);
     $delFileList = array();
     foreach ($this->_directory->fileList() as $file) {
         if ($file == $this->_name . '.del') {
             // Matches <segment_name>.del file name
             $delFileList[] = 0;
         } else {
             if (preg_match('/^' . $this->_name . '_([a-zA-Z0-9]+)\\.del$/i', $file, $matches)) {
                 // Matches <segment_name>_NNN.del file names
                 $delFileList[] = (int) $matches[1];
             }
         }
     }
     if (count($delFileList) == 0) {
         // There is no deletions file for current segment in the directory
         // Set detetions file generation number to 1
         $this->_delGen = 1;
     } else {
         // There are some deletions files for current segment in the directory
         // Set detetions file generation number to the highest + 1
         $this->_delGen = max($delFileList) + 1;
     }
     $delFile = $this->_directory->createFile($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del');
     Zend_Search_Lucene::releaseWriteLock($this->_directory, $lock);
     $delFile->writeInt($this->_docCount);
     $delFile->writeInt($bitCount);
     $delFile->writeBytes($delBytes);
     $this->_deletedDirty = false;
 }
开发者ID:ismaelmelus,项目名称:home,代码行数:55,代码来源:SegmentInfo.php


示例4: writeChanges

 /**
  * Write changes if it's necessary.
  *
  * This method must be invoked only from the Writer _updateSegments() method,
  * so index Write lock has to be already obtained.
  *
  * @internal
  */
 public function writeChanges()
 {
     if (!$this->_deletedDirty) {
         return;
     }
     if (extension_loaded('bitset')) {
         $delBytes = $this->_deleted;
         $bitCount = count(bitset_to_array($delBytes));
     } else {
         $byteCount = floor($this->_docCount / 8) + 1;
         $delBytes = str_repeat(chr(0), $byteCount);
         for ($count = 0; $count < $byteCount; $count++) {
             $byte = 0;
             for ($bit = 0; $bit < 8; $bit++) {
                 if (isset($this->_deleted[$count * 8 + $bit])) {
                     $byte |= 1 << $bit;
                 }
             }
             $delBytes[$count] = chr($byte);
         }
         $bitCount = count($this->_deleted);
     }
     // Get new generation number
     $this->_detectLatestDelGen();
     if ($this->_delGen == -1) {
         // Set delete file generation number to 1
         $this->_delGen = 1;
     } else {
         // Increase delete file generation number by 1
         $this->_delGen++;
     }
     $delFile = $this->_directory->createFile($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del');
     $delFile->writeInt($this->_docCount);
     $delFile->writeInt($bitCount);
     $delFile->writeBytes($delBytes);
     $this->_deletedDirty = false;
 }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:45,代码来源:SegmentInfo.php


示例5: writeChanges

 public function writeChanges()
 {
     $latestDelGen = $this->_detectLatestDelGen();
     if (!$this->_deletedDirty) {
         if ($latestDelGen == $this->_delGen) {
             return;
         } else {
             if ($latestDelGen > $this->_delGen) {
                 $this->_delGen = $latestDelGen;
                 $this->_deleted = $this->_loadDelFile();
                 return;
             } else {
                 throw new Zend_Search_Lucene_Exception('Delete file processing workflow is corrupted for the segment \'' . $this->_name . '\'.');
             }
         }
     }
     if ($latestDelGen > $this->_delGen) {
         $this->_delGen = $latestDelGen;
         $latestDelete = $this->_loadDelFile();
         if (extension_loaded('bitset')) {
             $this->_deleted = bitset_union($this->_deleted, $latestDelete);
         } else {
             $this->_deleted += $latestDelete;
         }
     }
     if (extension_loaded('bitset')) {
         $delBytes = $this->_deleted;
         $bitCount = count(bitset_to_array($delBytes));
     } else {
         $byteCount = floor($this->_docCount / 8) + 1;
         $delBytes = str_repeat(chr(0), $byteCount);
         for ($count = 0; $count < $byteCount; $count++) {
             $byte = 0;
             for ($bit = 0; $bit < 8; $bit++) {
                 if (isset($this->_deleted[$count * 8 + $bit])) {
                     $byte |= 1 << $bit;
                 }
             }
             $delBytes[$count] = chr($byte);
         }
         $bitCount = count($this->_deleted);
     }
     if ($this->_delGen == -1) {
         $this->_delGen = 1;
     } else {
         $this->_delGen++;
     }
     $delFile = $this->_directory->createFile($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del');
     $delFile->writeInt($this->_docCount);
     $delFile->writeInt($bitCount);
     $delFile->writeBytes($delBytes);
     $this->_deletedDirty = false;
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:53,代码来源:Zend_Search_Lucene.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP bitset_union函数代码示例发布时间:2022-05-24
下一篇:
PHP bitset_in函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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