本文整理汇总了PHP中sphPackI64函数的典型用法代码示例。如果您正苦于以下问题:PHP sphPackI64函数的具体用法?PHP sphPackI64怎么用?PHP sphPackI64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sphPackI64函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: AddQuery
function AddQuery($query, $index = "*", $comment = "")
{
// mbstring workaround
$this->_MBPush();
// build request
$req = pack("NNNN", $this->_offset, $this->_limit, $this->_mode, $this->_ranker);
if ($this->_ranker == SPH_RANK_EXPR) {
$req .= pack("N", strlen($this->_rankexpr)) . $this->_rankexpr;
}
$req .= pack("N", $this->_sort);
// (deprecated) sort mode
$req .= pack("N", strlen($this->_sortby)) . $this->_sortby;
$req .= pack("N", strlen($query)) . $query;
// query itself
$req .= pack("N", count($this->_weights));
// weights
foreach ($this->_weights as $weight) {
$req .= pack("N", (int) $weight);
}
$req .= pack("N", strlen($index)) . $index;
// indexes
$req .= pack("N", 1);
// id64 range marker
$req .= sphPackU64($this->_min_id) . sphPackU64($this->_max_id);
// id64 range
// filters
$req .= pack("N", count($this->_filters));
foreach ($this->_filters as $filter) {
$req .= pack("N", strlen($filter["attr"])) . $filter["attr"];
$req .= pack("N", $filter["type"]);
switch ($filter["type"]) {
case SPH_FILTER_VALUES:
$req .= pack("N", count($filter["values"]));
foreach ($filter["values"] as $value) {
$req .= sphPackI64($value);
}
break;
case SPH_FILTER_RANGE:
$req .= sphPackI64($filter["min"]) . sphPackI64($filter["max"]);
break;
case SPH_FILTER_FLOATRANGE:
$req .= $this->_PackFloat($filter["min"]) . $this->_PackFloat($filter["max"]);
break;
default:
assert(0 && "internal error: unhandled filter type");
}
$req .= pack("N", $filter["exclude"]);
}
// group-by clause, max-matches count, group-sort clause, cutoff count
$req .= pack("NN", $this->_groupfunc, strlen($this->_groupby)) . $this->_groupby;
$req .= pack("N", $this->_maxmatches);
$req .= pack("N", strlen($this->_groupsort)) . $this->_groupsort;
$req .= pack("NNN", $this->_cutoff, $this->_retrycount, $this->_retrydelay);
$req .= pack("N", strlen($this->_groupdistinct)) . $this->_groupdistinct;
// anchor point
if (empty($this->_anchor)) {
$req .= pack("N", 0);
} else {
$a =& $this->_anchor;
$req .= pack("N", 1);
$req .= pack("N", strlen($a["attrlat"])) . $a["attrlat"];
$req .= pack("N", strlen($a["attrlong"])) . $a["attrlong"];
$req .= $this->_PackFloat($a["lat"]) . $this->_PackFloat($a["long"]);
}
// per-index weights
$req .= pack("N", count($this->_indexweights));
foreach ($this->_indexweights as $idx => $weight) {
$req .= pack("N", strlen($idx)) . $idx . pack("N", $weight);
}
// max query time
$req .= pack("N", $this->_maxquerytime);
// per-field weights
$req .= pack("N", count($this->_fieldweights));
foreach ($this->_fieldweights as $field => $weight) {
$req .= pack("N", strlen($field)) . $field . pack("N", $weight);
}
// comment
$req .= pack("N", strlen($comment)) . $comment;
// attribute overrides
$req .= pack("N", count($this->_overrides));
foreach ($this->_overrides as $key => $entry) {
$req .= pack("N", strlen($entry["attr"])) . $entry["attr"];
$req .= pack("NN", $entry["type"], count($entry["values"]));
foreach ($entry["values"] as $id => $val) {
assert(is_numeric($id));
assert(is_numeric($val));
$req .= sphPackU64($id);
switch ($entry["type"]) {
case SPH_ATTR_FLOAT:
$req .= $this->_PackFloat($val);
break;
case SPH_ATTR_BIGINT:
$req .= sphPackI64($val);
break;
default:
$req .= pack("N", $val);
break;
}
}
}
//.........这里部分代码省略.........
开发者ID:makefifo,项目名称:SphinxClient,代码行数:101,代码来源:SphinxClient.php
示例2: FilterOutput
function FilterOutput()
{
$req = "";
foreach ($this->_filters as $filter) {
$req .= pack("N", strlen($filter["attr"])) . $filter["attr"];
$req .= pack("N", $filter["type"]);
switch ($filter["type"]) {
case SPH_FILTER_VALUES:
$req .= pack("N", count($filter["values"]));
foreach ($filter["values"] as $value) {
$req .= sphPackI64($value);
}
break;
case SPH_FILTER_RANGE:
$req .= sphPackI64($filter["min"]) . sphPackI64($filter["max"]);
break;
case SPH_FILTER_FLOATRANGE:
$req .= $this->_PackFloat($filter["min"]) . $this->_PackFloat($filter["max"]);
break;
default:
assert(0 && "internal error: unhandled filter type");
}
$req .= pack("N", $filter["exclude"]);
}
return $req;
}
开发者ID:sulashidayat,项目名称:plumboard,代码行数:26,代码来源:sphinxapi.2.0.1.php
注:本文中的sphPackI64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论