本文整理汇总了PHP中sphUnpackI64函数的典型用法代码示例。如果您正苦于以下问题:PHP sphUnpackI64函数的具体用法?PHP sphUnpackI64怎么用?PHP sphUnpackI64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sphUnpackI64函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: RunQueries
//.........这里部分代码省略.........
$p += 4;
$attr = substr($response, $p, $len);
$p += $len;
list(, $type) = unpack("N*", substr($response, $p, 4));
$p += 4;
$attrs[$attr] = $type;
}
$result["attrs"] = $attrs;
// read match count
list(, $count) = unpack("N*", substr($response, $p, 4));
$p += 4;
list(, $id64) = unpack("N*", substr($response, $p, 4));
$p += 4;
// read matches
$idx = -1;
while ($count-- > 0 && $p < $max) {
// index into result array
$idx++;
// parse document id and weight
if ($id64) {
$doc = sphUnpackU64(substr($response, $p, 8));
$p += 8;
list(, $weight) = unpack("N*", substr($response, $p, 4));
$p += 4;
} else {
list($doc, $weight) = array_values(unpack("N*N*", substr($response, $p, 8)));
$p += 8;
if (PHP_INT_SIZE >= 8) {
// x64 route, workaround broken unpack() in 5.2.2+
if ($doc < 0) {
$doc += 1 << 32;
}
} else {
// x32 route, workaround php signed/unsigned braindamage
$doc = sprintf("%u", $doc);
}
}
$weight = sprintf("%u", $weight);
// create match entry
if ($this->_arrayresult) {
$result["matches"][$idx] = array("id" => $doc, "weight" => $weight);
} else {
$result["matches"][$doc]["weight"] = $weight;
}
// parse and create attributes
$attrvals = array();
foreach ($attrs as $attr => $type) {
// handle 64bit ints
if ($type == SPH_ATTR_BIGINT) {
$attrvals[$attr] = sphUnpackI64(substr($response, $p, 8));
$p += 8;
continue;
}
// handle floats
if ($type == SPH_ATTR_FLOAT) {
list(, $uval) = unpack("N*", substr($response, $p, 4));
$p += 4;
list(, $fval) = unpack("f*", pack("L", $uval));
$attrvals[$attr] = $fval;
continue;
}
// handle everything else as unsigned ints
list(, $val) = unpack("N*", substr($response, $p, 4));
$p += 4;
if ($type & SPH_ATTR_MULTI) {
$attrvals[$attr] = array();
$nvalues = $val;
while ($nvalues-- > 0 && $p < $max) {
list(, $val) = unpack("N*", substr($response, $p, 4));
$p += 4;
$attrvals[$attr][] = sprintf("%u", $val);
}
} else {
$attrvals[$attr] = sprintf("%u", $val);
}
}
if ($this->_arrayresult) {
$result["matches"][$idx]["attrs"] = $attrvals;
} else {
$result["matches"][$doc]["attrs"] = $attrvals;
}
}
list($total, $total_found, $msecs, $words) = array_values(unpack("N*N*N*N*", substr($response, $p, 16)));
$result["total"] = sprintf("%u", $total);
$result["total_found"] = sprintf("%u", $total_found);
$result["time"] = sprintf("%.3f", $msecs / 1000);
$p += 16;
while ($words-- > 0 && $p < $max) {
list(, $len) = unpack("N*", substr($response, $p, 4));
$p += 4;
$word = substr($response, $p, $len);
$p += $len;
list($docs, $hits) = array_values(unpack("N*N*", substr($response, $p, 8)));
$p += 8;
$result["words"][$word] = array("docs" => sprintf("%u", $docs), "hits" => sprintf("%u", $hits));
}
}
$this->_MBPop();
return $results;
}
开发者ID:virutmath,项目名称:suckhoe,代码行数:101,代码来源:sphinxapi.php
示例2: _ParseSearchResponse
function _ParseSearchResponse($response, $nreqs)
{
$p = 0;
// current position
$max = strlen($response);
// max position for checks, to protect against broken responses
$results = array();
for ($ires = 0; $ires < $nreqs && $p < $max; $ires++) {
$results[] = array();
$result =& $results[$ires];
$result["error"] = "";
$result["warning"] = "";
// extract status
list(, $status) = unpack("N*", substr($response, $p, 4));
$p += 4;
$result["status"] = $status;
if ($status != SEARCHD_OK) {
list(, $len) = unpack("N*", substr($response, $p, 4));
$p += 4;
$message = substr($response, $p, $len);
$p += $len;
if ($status == SEARCHD_WARNING) {
$result["warning"] = $message;
} else {
$result["error"] = $message;
continue;
}
}
// read schema
$fields = array();
$attrs = array();
list(, $nfields) = unpack("N*", substr($response, $p, 4));
$p += 4;
while ($nfields-- > 0 && $p < $max) {
list(, $len) = unpack("N*", substr($response, $p, 4));
$p += 4;
$fields[] = substr($response, $p, $len);
$p += $len;
}
$result["fields"] = $fields;
list(, $nattrs) = unpack("N*", substr($response, $p, 4));
$p += 4;
while ($nattrs-- > 0 && $p < $max) {
list(, $len) = unpack("N*", substr($response, $p, 4));
$p += 4;
$attr = substr($response, $p, $len);
$p += $len;
list(, $type) = unpack("N*", substr($response, $p, 4));
$p += 4;
$attrs[$attr] = $type;
}
$result["attrs"] = $attrs;
// read match count
list(, $count) = unpack("N*", substr($response, $p, 4));
$p += 4;
list(, $id64) = unpack("N*", substr($response, $p, 4));
$p += 4;
// read matches
$idx = -1;
while ($count-- > 0 && $p < $max) {
// index into result array
$idx++;
// parse document id and weight
if ($id64) {
$doc = sphUnpackU64(substr($response, $p, 8));
$p += 8;
list(, $weight) = unpack("N*", substr($response, $p, 4));
$p += 4;
} else {
list($doc, $weight) = array_values(unpack("N*N*", substr($response, $p, 8)));
$p += 8;
$doc = sphFixUint($doc);
}
$weight = sprintf("%u", $weight);
// create match entry
if ($this->_arrayresult) {
$result["matches"][$idx] = array("id" => $doc, "weight" => $weight);
} else {
$result["matches"][$doc]["weight"] = $weight;
}
// parse and create attributes
$attrvals = array();
foreach ($attrs as $attr => $type) {
// handle 64bit ints
if ($type == SPH_ATTR_BIGINT) {
$attrvals[$attr] = sphUnpackI64(substr($response, $p, 8));
$p += 8;
continue;
}
// handle floats
if ($type == SPH_ATTR_FLOAT) {
list(, $uval) = unpack("N*", substr($response, $p, 4));
$p += 4;
list(, $fval) = unpack("f*", pack("L", $uval));
$attrvals[$attr] = $fval;
continue;
}
// handle everything else as unsigned ints
list(, $val) = unpack("N*", substr($response, $p, 4));
$p += 4;
//.........这里部分代码省略.........
开发者ID:makefifo,项目名称:SphinxClient,代码行数:101,代码来源:SphinxClient.php
示例3: _ParseSearchResponse
public function _ParseSearchResponse($response, $nreqs)
{
$p = 0;
// current position
$max = strlen($response);
// max position for checks, to protect against broken responses
$results = array();
for ($ires = 0; $ires < $nreqs && $p < $max; ++$ires) {
$results[] = array();
$result =& $results[$ires];
$result['error'] = '';
$result['warning'] = '';
// extract status
list(, $status) = unpack('N*', substr($response, $p, 4));
$p += 4;
$result['status'] = $status;
if ($status != SEARCHD_OK) {
list(, $len) = unpack('N*', substr($response, $p, 4));
$p += 4;
$message = substr($response, $p, $len);
$p += $len;
if ($status == SEARCHD_WARNING) {
$result['warning'] = $message;
} else {
$result['error'] = $message;
continue;
}
}
// read schema
$fields = array();
$attrs = array();
list(, $nfields) = unpack('N*', substr($response, $p, 4));
$p += 4;
while ($nfields-- > 0 && $p < $max) {
list(, $len) = unpack('N*', substr($response, $p, 4));
$p += 4;
$fields[] = substr($response, $p, $len);
$p += $len;
}
$result['fields'] = $fields;
list(, $nattrs) = unpack('N*', substr($response, $p, 4));
$p += 4;
while ($nattrs-- > 0 && $p < $max) {
list(, $len) = unpack('N*', substr($response, $p, 4));
$p += 4;
$attr = substr($response, $p, $len);
$p += $len;
list(, $type) = unpack('N*', substr($response, $p, 4));
$p += 4;
$attrs[$attr] = $type;
}
$result['attrs'] = $attrs;
// read match count
list(, $count) = unpack('N*', substr($response, $p, 4));
$p += 4;
list(, $id64) = unpack('N*', substr($response, $p, 4));
$p += 4;
// read matches
$idx = -1;
while ($count-- > 0 && $p < $max) {
// index into result array
++$idx;
// parse document id and weight
if ($id64) {
$doc = sphUnpackU64(substr($response, $p, 8));
$p += 8;
list(, $weight) = unpack('N*', substr($response, $p, 4));
$p += 4;
} else {
list($doc, $weight) = array_values(unpack('N*N*', substr($response, $p, 8)));
$p += 8;
if (PHP_INT_SIZE >= 8) {
// x64 route, workaround broken unpack() in 5.2.2+
if ($doc < 0) {
$doc += 1 << 32;
}
} else {
// x32 route, workaround php signed/unsigned braindamage
$doc = sprintf('%u', $doc);
}
}
$weight = sprintf('%u', $weight);
// create match entry
if ($this->_arrayresult) {
$result['matches'][$idx] = array('id' => $doc, 'weight' => $weight);
} else {
$result['matches'][$doc]['weight'] = $weight;
}
// parse and create attributes
$attrvals = array();
foreach ($attrs as $attr => $type) {
// handle 64bit ints
if ($type == SPH_ATTR_BIGINT) {
$attrvals[$attr] = sphUnpackI64(substr($response, $p, 8));
$p += 8;
continue;
}
// handle floats
if ($type == SPH_ATTR_FLOAT) {
list(, $uval) = unpack('N*', substr($response, $p, 4));
//.........这里部分代码省略.........
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:101,代码来源:sphinxapi.php
注:本文中的sphUnpackI64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论