blob: 30c5df49faf7712ff4c07906a5d1105cf27a6600 [file] [log] [blame]
<!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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>MADlib: sketch.sql_in File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script><script src="../mathjax/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">MADlib
&#160;<span id="projectnumber">1.0</span> <span style="font-size:10pt; font-style:italic"><a href="../latest/./sketch_8sql__in.html"> A newer version is available</a></span>
</div>
<div id="projectbrief">User Documentation</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li>
<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><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('sketch_8sql__in.html','');});
</script>
<div id="doc-content">
<!-- 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>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Groups</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">sketch.sql_in File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>SQL functions for sketch-based approximations of descriptive statistics.
<a href="#details">More...</a></p>
<p><a href="sketch_8sql__in_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a5a7e077028d5e0441552a77db3586db1"><td class="memItemLeft" align="right" valign="top">aggregate int8&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#a5a7e077028d5e0441552a77db3586db1">fmsketch_dcount</a> (anyelement column)</td></tr>
<tr class="memdesc:a5a7e077028d5e0441552a77db3586db1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Flajolet-Martin's distinct count estimation. <a href="#a5a7e077028d5e0441552a77db3586db1">More...</a><br/></td></tr>
<tr class="separator:a5a7e077028d5e0441552a77db3586db1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a323b932332f2db302469f14dc5fae369"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a323b932332f2db302469f14dc5fae369"></a>
aggregate text&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#a323b932332f2db302469f14dc5fae369">cmsketch</a> (int8 column)</td></tr>
<tr class="memdesc:a323b932332f2db302469f14dc5fae369"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>cmsketch</code> is a UDA that can be run on columns of type int8, or any column that can be cast to an int8. It produces a base64 string representing a CountMin sketch: a large array of counters that is intended to be passed into a UDF like <code>cmsketch_width_histogram</code> described below. <br/></td></tr>
<tr class="separator:a323b932332f2db302469f14dc5fae369"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3498d2c778d1289154f61d34e84c609e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3498d2c778d1289154f61d34e84c609e"></a>
int8&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#a3498d2c778d1289154f61d34e84c609e">cmsketch_count</a> (text sketches64, int8 val)</td></tr>
<tr class="memdesc:a3498d2c778d1289154f61d34e84c609e"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>cmsketch_count</code> is a scalar UDF to compute the approximate number of occurences of a value in a column summarized by a cmsketch. Takes the results of the <code>cmsketch</code> aggregate as its first argument, and the desired value as the second. <br/></td></tr>
<tr class="separator:a3498d2c778d1289154f61d34e84c609e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeff9e36cfb3338c4e405d4ac77d3968c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeff9e36cfb3338c4e405d4ac77d3968c"></a>
int8&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#aeff9e36cfb3338c4e405d4ac77d3968c">cmsketch_rangecount</a> (text sketches64, int8 bot, int8 top)</td></tr>
<tr class="memdesc:aeff9e36cfb3338c4e405d4ac77d3968c"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>cmsketch_rangecount</code> is a scalar UDF to approximate the number of occurrences of values in the range <code>[lo,hi]</code> inclusive, given a cmsketch of a column. Takes the results of the <code>cmsketch</code> aggregate as its first argument, and the desired range boundaries as the second and third. <br/></td></tr>
<tr class="separator:aeff9e36cfb3338c4e405d4ac77d3968c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2f2ab2fe3244515f5f73d49690e73b39"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2f2ab2fe3244515f5f73d49690e73b39"></a>
int8&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#a2f2ab2fe3244515f5f73d49690e73b39">cmsketch_centile</a> (text sketches64, int8 centile, int8 cnt)</td></tr>
<tr class="memdesc:a2f2ab2fe3244515f5f73d49690e73b39"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>cmsketch_centile</code> is a scalar UDF to compute a centile value from a cmsketch. Takes the results of the <code>cmsketch</code> aggregate as its first argument, a number between 1 and 99 as the desired centile in the second, and the count of the column as the third. Produces a value from the sketched column that is approximately at the centile's position in sorted order. <br/></td></tr>
<tr class="separator:a2f2ab2fe3244515f5f73d49690e73b39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0ef6428fa7ba4b7f7b1f633e6f8003ea"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0ef6428fa7ba4b7f7b1f633e6f8003ea"></a>
int8&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#a0ef6428fa7ba4b7f7b1f633e6f8003ea">cmsketch_median</a> (text sketches64, int8 cnt)</td></tr>
<tr class="memdesc:a0ef6428fa7ba4b7f7b1f633e6f8003ea"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>cmsketch_median</code> is a scalar UDF to compute a median value from a cmsketch. Takes the results of the <code>cmsketch</code> aggregate as its first argument, and the count as the second. Produces a value from the sketched column that is approximately at the halfway position in sorted order. <br/></td></tr>
<tr class="separator:a0ef6428fa7ba4b7f7b1f633e6f8003ea"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8482f62849adf40a2c7df78c23ea33a4"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8482f62849adf40a2c7df78c23ea33a4"></a>
text&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#a8482f62849adf40a2c7df78c23ea33a4">cmsketch_width_histogram</a> (text sketches64, int8 themin, int8 themax, int4 nbuckets)</td></tr>
<tr class="memdesc:a8482f62849adf40a2c7df78c23ea33a4"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>cmsketch_width_histogram</code> is a scalar UDF that takes three aggregates of a column &ndash; cmsketch, min and max&ndash; as well as a number of buckets, and produces an n-bucket histogram for the column where each bucket has approximately the same width. The output is a text string containing triples {lo, hi, count} representing the buckets; counts are approximate. <br/></td></tr>
<tr class="separator:a8482f62849adf40a2c7df78c23ea33a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9e6d30f20b724b96249cc4a0f67a279e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9e6d30f20b724b96249cc4a0f67a279e"></a>
text&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#a9e6d30f20b724b96249cc4a0f67a279e">cmsketch_depth_histogram</a> (text sketches64, int4 nbuckets)</td></tr>
<tr class="memdesc:a9e6d30f20b724b96249cc4a0f67a279e"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>cmsketch_depth_histogram</code> is a UDA that takes a cmsketch and a number of buckets n, and produces an n-bucket histogram for the column where each bucket has approximately the same count. The output is a text string containing triples {lo, hi, count} representing the buckets; counts are approximate. Note that an equi-depth histogram is equivalent to a spanning set of equi-spaced centiles. <br/></td></tr>
<tr class="separator:a9e6d30f20b724b96249cc4a0f67a279e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab915f092b747e3a955cbb699afc9c70c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab915f092b747e3a955cbb699afc9c70c"></a>
aggregate text[][]&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#ab915f092b747e3a955cbb699afc9c70c">mfvsketch_top_histogram</a> (anyelement column, int4 number_of_buckets)</td></tr>
<tr class="memdesc:ab915f092b747e3a955cbb699afc9c70c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Produces an n-bucket histogram for a column where each bucket counts one of the most frequent values in the column. The output is an array of doubles {value, count} in descending order of frequency; counts are approximated via CountMin sketches. Ties are handled arbitrarily. <br/></td></tr>
<tr class="separator:ab915f092b747e3a955cbb699afc9c70c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac5923758586e5203e80895526d3e561f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac5923758586e5203e80895526d3e561f"></a>
aggregate text[][]&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sketch_8sql__in.html#ac5923758586e5203e80895526d3e561f">mfvsketch_quick_histogram</a> (anyelement column, int4 number_of_buckets)</td></tr>
<tr class="memdesc:ac5923758586e5203e80895526d3e561f"><td class="mdescLeft">&#160;</td><td class="mdescRight">On Postgres it works the same way as <a class="el" href="sketch_8sql__in.html#ab915f092b747e3a955cbb699afc9c70c">mfvsketch_top_histogram</a> but, in Greenplum it does parallel aggregation to provide a "quick and dirty" answer. <br/></td></tr>
<tr class="separator:ac5923758586e5203e80895526d3e561f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><dl class="section date"><dt>Date</dt><dd>April 2011</dd></dl>
<dl class="section see"><dt>See Also</dt><dd>For a brief introduction to sketches, see the module description <a class="el" href="group__grp__sketches.html">Sketch-based Estimators</a> </dd></dl>
<p>Definition in file <a class="el" href="sketch_8sql__in_source.html">sketch.sql_in</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a5a7e077028d5e0441552a77db3586db1"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">aggregate int8 fmsketch_dcount </td>
<td>(</td>
<td class="paramtype">anyelement&#160;</td>
<td class="paramname"><em>column</em>)</td><td></td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">column</td><td>name </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="sketch_8sql__in_source.html#l00313">313</a> of file <a class="el" href="sketch_8sql__in_source.html">sketch.sql_in</a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_704eb8350b43e1ca74c0f90ed1ba450e.html">methods</a></li><li class="navelem"><a class="el" href="dir_b0d8a62e5a4314de84ce58e7cd249850.html">sketch</a></li><li class="navelem"><a class="el" href="dir_60056874394c01e6c892c7492b3fbe27.html">src</a></li><li class="navelem"><a class="el" href="dir_c2d3987992538edb8f634d5f4e0fae80.html">pg_gp</a></li><li class="navelem"><a class="el" href="sketch_8sql__in.html">sketch.sql_in</a></li>
<li class="footer">Generated on Tue Sep 10 2013 15:48:04 for MADlib by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.4 </li>
</ul>
</div>
</body>
</html>