本文整理汇总了PHP中bitset_union函数的典型用法代码示例。如果您正苦于以下问题:PHP bitset_union函数的具体用法?PHP bitset_union怎么用?PHP bitset_union使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bitset_union函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _calculateNonConjunctionResult
/**
* Calculate result vector for non Conjunction query
* (like '+something -another')
*
* @param Zend_Search_Lucene $reader
*/
private function _calculateNonConjunctionResult($reader)
{
if (extension_loaded('bitset')) {
$required = null;
$neither = bitset_empty();
$prohibited = bitset_empty();
foreach ($this->_terms as $termId => $term) {
$termDocs = bitset_from_array($reader->termDocs($term));
if ($this->_signs[$termId] === true) {
// required
if ($required !== null) {
$required = bitset_intersection($required, $termDocs);
} else {
$required = $termDocs;
}
} elseif ($this->_signs[$termId] === false) {
// prohibited
$prohibited = bitset_union($prohibited, $termDocs);
} else {
// neither required, nor prohibited
$neither = bitset_union($neither, $termDocs);
}
$this->_termsPositions[$termId] = $reader->termPositions($term);
}
if ($required === null) {
$required = $neither;
}
$this->_resVector = bitset_intersection($required, bitset_invert($prohibited, $reader->count()));
} else {
$required = null;
$neither = array();
$prohibited = array();
foreach ($this->_terms as $termId => $term) {
$termDocs = array_flip($reader->termDocs($term));
if ($this->_signs[$termId] === true) {
// required
if ($required !== null) {
// substitute for bitset_intersection
foreach ($required as $key => $value) {
if (!isset($termDocs[$key])) {
unset($required[$key]);
}
}
} else {
$required = $termDocs;
}
} elseif ($this->_signs[$termId] === false) {
// prohibited
// substitute for bitset_union
foreach ($termDocs as $key => $value) {
$prohibited[$key] = $value;
}
} else {
// neither required, nor prohibited
// substitute for bitset_union
foreach ($termDocs as $key => $value) {
$neither[$key] = $value;
}
}
$this->_termsPositions[$termId] = $reader->termPositions($term);
}
if ($required === null) {
$required = $neither;
}
foreach ($required as $key => $value) {
if (isset($prohibited[$key])) {
unset($required[$key]);
}
}
$this->_resVector = $required;
}
}
示例2: 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;
}
示例3: 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;
}