Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 684f89b6cd
Fetching contributors…

Cannot retrieve contributors at this time

661 lines (601 sloc) 33.045 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cassandra PHP Client Library: CassandraUtil Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<script type="text/javascript">
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}
function toggleVisibility(linkObj) {
var base = linkObj.getAttribute('id');
var summary = document.getElementById(base + '-summary');
var content = document.getElementById(base + '-content');
var trigger = document.getElementById(base + '-trigger');
if ( hasClass(linkObj,'closed') ) {
summary.style.display = 'none';
content.style.display = 'block';
trigger.src = 'open.png';
removeClass(linkObj,'closed');
addClass(linkObj,'opened');
} else if ( hasClass(linkObj,'opened') ) {
summary.style.display = 'block';
content.style.display = 'none';
trigger.src = 'closed.png';
removeClass(linkObj,'opened');
addClass(linkObj,'closed');
}
return false;
}
</script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Cassandra PHP Client Library</div>
<div id="projectbrief">Cassandra PHP-based client library for managing and querying your Cassandra cluster.</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
<li><a href="classes.html"><span>Data&#160;Structure&#160;Index</span></a></li>
<li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Data&#160;Fields</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> </div>
<div class="headertitle">
<h1>CassandraUtil Class Reference</h1> </div>
</div>
<div class="contents">
<!-- doxytag: class="CassandraUtil" --><table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#ad5c94f8a7e99e7240385cf471c2b4ae8">getTimestamp</a> ()</td></tr>
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#a0c6545c1306d917051a53598a0f23ee6">extractType</a> ($definition)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#aa70ff00c6c785127c87a46c966999e66">pack</a> ($value, $type)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#a92f49d16f99991a04a3f798ee91f7d0b">packLong</a> ($value)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#aa5b20568dcda475aba51dc1ac6bdfcb1">packInteger</a> ($value)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#a5e6486c8b5438bf565f13789f0403053">packString</a> ($string, $length)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#a0e4efa10d6999de6fbbc2efa3f24a089">unpack</a> ($value, $type)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#a8753dea96e94a3c84d8e5aada1418dbb">unpackLong</a> ($data)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#ab0dcf37a5de9d22e665ca291a3afd4a2">unpackInteger</a> ($value)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCassandraUtil.html#ab49d399bb60d2e0094de49b77cd00dbe">unpackString</a> ($value, $length)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Utility class for the <a class="el" href="classCassandra.html">Cassandra</a> library, providing some common operations like packing data to correct type.</p>
<p>Includes quite a lot of code from PHPCassa project. </p>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l02888">2888</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a0c6545c1306d917051a53598a0f23ee6"></a><!-- doxytag: member="CassandraUtil::extractType" ref="a0c6545c1306d917051a53598a0f23ee6" args="($definition)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::extractType </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>definition</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Extracts the data type name from given definition.</p>
<p>The parsed names match the constancts Cassandra::TYPE_...</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">string</td><td class="paramname">$definition</td><td>Definition to parse </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>string Valid data type name </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l02898">2898</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
<span class="keywordflow">if</span> ($definition === null or $definition == <span class="stringliteral">&#39;&#39;</span>) {
<span class="keywordflow">return</span> <a class="code" href="classCassandra.html#ab75de9aa0588c7665f1c9d8cf8d4e8ff">Cassandra::TYPE_BYTES</a>;
}
$index = strrpos($definition, <span class="charliteral">&#39;.&#39;</span>);
<span class="keywordflow">if</span> ($index === <span class="keyword">false</span>) {
<span class="keywordflow">return</span> <a class="code" href="classCassandra.html#ab75de9aa0588c7665f1c9d8cf8d4e8ff">Cassandra::TYPE_BYTES</a>;
}
<span class="keywordflow">return</span> substr($definition, $index + 1);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ad5c94f8a7e99e7240385cf471c2b4ae8"></a><!-- doxytag: member="CassandraUtil::getTimestamp" ref="ad5c94f8a7e99e7240385cf471c2b4ae8" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">CassandraUtil::getTimestamp </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns current timestamp that can be used in insert/update opearations.</p>
<p>By Zach Buller (<a href="mailto:zachbuller@gmail.com">zachbuller@gmail.com</a>)</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>integer Unpacked data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l03156">3156</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
$microtime = microtime();
settype($microtime, <span class="stringliteral">&#39;string&#39;</span>);
$timeTokens = explode(<span class="stringliteral">&quot; &quot;</span>, $microtime);
$subSeconds = preg_replace(<span class="stringliteral">&#39;/0./&#39;</span>, <span class="stringliteral">&#39;&#39;</span>, $timeTokens[0], 1);
<span class="keywordflow">return</span> ($timeTokens[1].$subSeconds) / 100;
}
</pre></div>
</div>
</div>
<a class="anchor" id="aa70ff00c6c785127c87a46c966999e66"></a><!-- doxytag: member="CassandraUtil::pack" ref="aa70ff00c6c785127c87a46c966999e66" args="($value, $type)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::pack </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>type</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Packs given value to given type.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">mixed</td><td class="paramname">$value</td><td>Value to pack </td></tr>
<tr><td class="paramtype">string</td><td class="paramname">$type</td><td>Type name to pack to </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>mixed Data packed to requested type </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l02919">2919</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
<span class="keywordflow">switch</span> ($type) {
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#acf64f8105c4bfe0c95f868437299442f">Cassandra::TYPE_LONG</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#a92f49d16f99991a04a3f798ee91f7d0b">self::packLong</a>($value);
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#a4160c654a18aead3a642fd1f3f2415e9">Cassandra::TYPE_INTEGER</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#aa5b20568dcda475aba51dc1ac6bdfcb1">self::packInteger</a>($value);
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#acc917786b5bbbdd6eb4783856bd5580c">Cassandra::TYPE_ASCII</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#a5e6486c8b5438bf565f13789f0403053">self::packString</a>($value, strlen($value));
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#ac03a89bd430178d9bce987eba8001b82">Cassandra::TYPE_UTF8</a>:
<span class="keywordflow">if</span> (mb_detect_encoding($value, <span class="stringliteral">&#39;UTF-8&#39;</span>) != <span class="stringliteral">&#39;UTF-8&#39;</span>) {
$value = utf8_encode($value);
}
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#a5e6486c8b5438bf565f13789f0403053">self::packString</a>($value, strlen($value));
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#a42861ad94788ba940228767a79f1c4c7">Cassandra::TYPE_TIME_UUID</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#a5e6486c8b5438bf565f13789f0403053">self::packString</a>($value, 16);
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#a2af16bdea44f4e16ba5c5baa5380b9f0">Cassandra::TYPE_LEXICAL_UUID</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#a5e6486c8b5438bf565f13789f0403053">self::packString</a>($value, 16);
<span class="keywordflow">default</span>:
<span class="keywordflow">return</span> $value;
}
}
</pre></div>
</div>
</div>
<a class="anchor" id="aa5b20568dcda475aba51dc1ac6bdfcb1"></a><!-- doxytag: member="CassandraUtil::packInteger" ref="aa5b20568dcda475aba51dc1ac6bdfcb1" args="($value)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::packInteger </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>value</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Packs data to integer type.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">mixed</td><td class="paramname">$value</td><td>Value to pack </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>integer Packed data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l02997">2997</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#aa70ff00c6c785127c87a46c966999e66">pack</a>(<span class="charliteral">&#39;N&#39;</span>, $value);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a92f49d16f99991a04a3f798ee91f7d0b"></a><!-- doxytag: member="CassandraUtil::packLong" ref="a92f49d16f99991a04a3f798ee91f7d0b" args="($value)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::packLong </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>value</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Packs data to long type.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">mixed</td><td class="paramname">$value</td><td>Value to pack </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>integer Packed data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l02954">2954</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
<span class="comment">// If we are on a 32bit architecture we have to explicitly deal with</span>
<span class="comment">// 64-bit twos-complement arithmetic since PHP wants to treat all ints</span>
<span class="comment">// as signed and any int over 2^31 - 1 as a float</span>
<span class="keywordflow">if</span> (PHP_INT_SIZE == 4) {
$neg = $value &lt; 0;
<span class="keywordflow">if</span> ($neg) {
$value *= - 1;
}
$hi = (int) ($value / 4294967296);
$lo = (int) $value;
<span class="keywordflow">if</span> ($neg) {
$hi = ~$hi;
$lo = ~$lo;
<span class="keywordflow">if</span> (($lo &amp; (<span class="keywordtype">int</span>)0xffffffff) == (<span class="keywordtype">int</span>)0xffffffff) {
$lo = 0;
$hi++;
} <span class="keywordflow">else</span> {
$lo++;
}
}
$data = <a class="code" href="classCassandraUtil.html#aa70ff00c6c785127c87a46c966999e66">pack</a>(<span class="stringliteral">&#39;N2&#39;</span>, $hi, $lo);
} <span class="keywordflow">else</span> {
$hi = $value &gt;&gt; 32;
$lo = $value &amp; 0xFFFFFFFF;
$data = <a class="code" href="classCassandraUtil.html#aa70ff00c6c785127c87a46c966999e66">pack</a>(<span class="stringliteral">&#39;N2&#39;</span>, $hi, $lo);
}
<span class="keywordflow">return</span> $data;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a5e6486c8b5438bf565f13789f0403053"></a><!-- doxytag: member="CassandraUtil::packString" ref="a5e6486c8b5438bf565f13789f0403053" args="($string, $length)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::packString </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>string</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Packs data to string type.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">mixed</td><td class="paramname">$value</td><td>Value to pack </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>string Packed data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l03007">3007</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
$result = <span class="stringliteral">&#39;&#39;</span>;
<span class="keywordflow">for</span>($i = 0; $i &lt; $length; $i++) {
$result .= <a class="code" href="classCassandraUtil.html#aa70ff00c6c785127c87a46c966999e66">pack</a>(<span class="charliteral">&#39;c&#39;</span>, ord(substr($string, $i, 1)));
}
<span class="keywordflow">return</span> $result;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a0e4efa10d6999de6fbbc2efa3f24a089"></a><!-- doxytag: member="CassandraUtil::unpack" ref="a0e4efa10d6999de6fbbc2efa3f24a089" args="($value, $type)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::unpack </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>type</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Unpacks packed data from given type to something PHP understands.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">string</td><td class="paramname">$value</td><td>Value to unpack </td></tr>
<tr><td class="paramtype">string</td><td class="paramname">$type</td><td>Current type of the data </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>mixed Unpacked data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l03024">3024</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
<span class="keywordflow">switch</span> ($type) {
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#acf64f8105c4bfe0c95f868437299442f">Cassandra::TYPE_LONG</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#a8753dea96e94a3c84d8e5aada1418dbb">self::unpackLong</a>($value);
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#a4160c654a18aead3a642fd1f3f2415e9">Cassandra::TYPE_INTEGER</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#ab0dcf37a5de9d22e665ca291a3afd4a2">self::unpackInteger</a>($value);
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#acc917786b5bbbdd6eb4783856bd5580c">Cassandra::TYPE_ASCII</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#ab49d399bb60d2e0094de49b77cd00dbe">self::unpackString</a>($value, strlen($value));
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#ac03a89bd430178d9bce987eba8001b82">Cassandra::TYPE_UTF8</a>:
<span class="keywordflow">return</span> <a class="code" href="classCassandraUtil.html#ab49d399bb60d2e0094de49b77cd00dbe">self::unpackString</a>($value, strlen($value));
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#a42861ad94788ba940228767a79f1c4c7">Cassandra::TYPE_TIME_UUID</a>:
<span class="keywordflow">return</span> $value;
<span class="keywordflow">case</span> <a class="code" href="classCassandra.html#a2af16bdea44f4e16ba5c5baa5380b9f0">Cassandra::TYPE_LEXICAL_UUID</a>:
<span class="keywordflow">return</span> $value;
<span class="keywordflow">default</span>:
<span class="keywordflow">return</span> $value;
}
}
</pre></div>
</div>
</div>
<a class="anchor" id="ab0dcf37a5de9d22e665ca291a3afd4a2"></a><!-- doxytag: member="CassandraUtil::unpackInteger" ref="ab0dcf37a5de9d22e665ca291a3afd4a2" args="($value)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::unpackInteger </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>value</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Unpacks integer data type.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">mixed</td><td class="paramname">$data</td><td>Data to unpack </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>integer Unpacked data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l03124">3124</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
$unpacked = <a class="code" href="classCassandraUtil.html#a0e4efa10d6999de6fbbc2efa3f24a089">unpack</a>(<span class="charliteral">&#39;N&#39;</span>, $value);
<span class="keywordflow">return</span> array_pop($unpacked);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a8753dea96e94a3c84d8e5aada1418dbb"></a><!-- doxytag: member="CassandraUtil::unpackLong" ref="a8753dea96e94a3c84d8e5aada1418dbb" args="($data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::unpackLong </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>data</em></td><td>)</td>
<td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Unpacks long data type.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">mixed</td><td class="paramname">$data</td><td>Data to unpack </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>integer Unpacked data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l03055">3055</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
$arr = <a class="code" href="classCassandraUtil.html#a0e4efa10d6999de6fbbc2efa3f24a089">unpack</a>(<span class="stringliteral">&#39;N2&#39;</span>, $data);
<span class="comment">// If we are on a 32bit architecture we have to explicitly deal with</span>
<span class="comment">// 64-bit twos-complement arithmetic since PHP wants to treat all ints</span>
<span class="comment">// as signed and any int over 2^31 - 1 as a float</span>
<span class="keywordflow">if</span> (PHP_INT_SIZE == 4) {
$hi = $arr[1];
$lo = $arr[2];
$isNeg = $hi &lt; 0;
<span class="comment">// Check for a negative</span>
<span class="keywordflow">if</span> ($isNeg) {
$hi = ~$hi &amp; (int)0xffffffff;
$lo = ~$lo &amp; (int)0xffffffff;
<span class="keywordflow">if</span> ($lo == (<span class="keywordtype">int</span>)0xffffffff) {
$hi++;
$lo = 0;
} <span class="keywordflow">else</span> {
$lo++;
}
}
<span class="comment">// Force 32bit words in excess of 2G to pe positive - we deal wigh</span>
<span class="comment">// sign explicitly below</span>
<span class="keywordflow">if</span> ($hi &amp; (<span class="keywordtype">int</span>)0x80000000) {
$hi &amp;= (int)0x7fffffff;
$hi += 0x80000000;
}
<span class="keywordflow">if</span> ($lo &amp; (<span class="keywordtype">int</span>)0x80000000) {
$lo &amp;= (int)0x7fffffff;
$lo += 0x80000000;
}
$value = $hi * 4294967296 + $lo;
<span class="keywordflow">if</span> ($isNeg) {
$value = 0 - $value;
}
} <span class="keywordflow">else</span> {
<span class="comment">// Upcast negatives in LSB bit</span>
<span class="keywordflow">if</span> ($arr[2] &amp; 0x80000000)
$arr[2] = $arr[2] &amp; 0xffffffff;
<span class="comment">// Check for a negative</span>
<span class="keywordflow">if</span> ($arr[1] &amp; 0x80000000) {
$arr[1] = $arr[1] &amp; 0xffffffff;
$arr[1] = $arr[1] ^ 0xffffffff;
$arr[2] = $arr[2] ^ 0xffffffff;
$value = 0 - $arr[1] * 4294967296 - $arr[2] - 1;
} <span class="keywordflow">else</span> {
$value = $arr[1] * 4294967296 + $arr[2];
}
}
<span class="keywordflow">return</span> $value;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ab49d399bb60d2e0094de49b77cd00dbe"></a><!-- doxytag: member="CassandraUtil::unpackString" ref="ab49d399bb60d2e0094de49b77cd00dbe" args="($value, $length)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">static CassandraUtil::unpackString </td>
<td>(</td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">$&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Unpacks string data type.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramtype">mixed</td><td class="paramname">$data</td><td>Data to unpack </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>string Unpacked data </dd></dl>
<p>Definition at line <a class="el" href="Cassandra_8php_source.html#l03136">3136</a> of file <a class="el" href="Cassandra_8php_source.html">Cassandra.php</a>.</p>
<div class="fragment"><pre class="fragment"> {
$unpacked = <a class="code" href="classCassandraUtil.html#a0e4efa10d6999de6fbbc2efa3f24a089">unpack</a>(<span class="charliteral">&#39;c&#39;</span>.$length.<span class="stringliteral">&#39;chars&#39;</span>, $value);
$out = <span class="stringliteral">&#39;&#39;</span>;
<span class="keywordflow">foreach</span>($unpacked as $element) {
<span class="keywordflow">if</span>($element &gt; 0) {
$out .= chr($element);
}
}
<span class="keywordflow">return</span> $out;
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="Cassandra_8php_source.html">Cassandra.php</a></li>
</ul>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 4 2011 14:36:00 for Cassandra PHP Client Library by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.