blob: ce4493db0c604a725da98275ece2f6b3f91a72fe [file]
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Distinct Counting &mdash; datasketches 0.1 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=e59714d7" />
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=2709fde1"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="HyperLogLog (HLL)" href="hyper_log_log.html" />
<link rel="prev" title="Apache DataSketches" href="../index.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home">
datasketches
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Distinct Counting</a><ul>
<li class="toctree-l2"><a class="reference internal" href="hyper_log_log.html">HyperLogLog (HLL)</a></li>
<li class="toctree-l2"><a class="reference internal" href="cpc.html">Compressed Probabilistic Counting (CPC)</a></li>
<li class="toctree-l2"><a class="reference internal" href="theta.html">Theta Sketch</a></li>
<li class="toctree-l2"><a class="reference internal" href="tuple.html">Tuple Sketch</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../quantiles/index.html">Quantiles Sketches</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../frequency/index.html">Frequency Sketches</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../vector/index.html">Vector Sketches</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../sampling/index.html">Random Sampling Sketches</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../helper/index.html">Helper Classes</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">datasketches</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Distinct Counting</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/distinct_counting/index.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="distinct-counting">
<h1>Distinct Counting<a class="headerlink" href="#distinct-counting" title="Link to this heading"></a></h1>
<p>Distinct counting is one of the earliest tasks to which sketches were applied. The concept is simple:
Provide an estimate of the number of unique elements in a set of data. One of the earliest solutions came
from Flajolet and Martin in 1985 with their seminal work
<a class="reference external" href="http://db.cs.berkeley.edu/cs286/papers/flajoletmartin-jcss1985.pdf">Probabilistic counting Algorithms for Data Base Applications</a>.</p>
<p>The DataSketches library offers several types of distinct counting sketches, each with different properties.</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">hll_sketch</span></code>: Hyper Log Log, a well-known sketch for distinct counting but no longer state-of-the-art.</p></li>
<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">cpc_sketch</span></code>: Provides a better accuracy-space trade-off than HLL, but with a somewhat larger footprint while in-memory.</p></li>
<li><p><a class="reference internal" href="theta.html#datasketches.theta_sketch" title="datasketches.theta_sketch"><code class="xref py py-class docutils literal notranslate"><span class="pre">theta_sketch</span></code></a>: Theta sketch, a type of k-minimum value sketch, which provide good performance with intersection and set difference operations.</p></li>
<li><p><a class="reference internal" href="tuple.html#datasketches.tuple_sketch" title="datasketches.tuple_sketch"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple_sketch</span></code></a>: Tuple sketch, which is similar to a theta sketch but supports additional data stored with each key.</p></li>
</ul>
</div></blockquote>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="hyper_log_log.html">HyperLogLog (HLL)</a></li>
<li class="toctree-l1"><a class="reference internal" href="cpc.html">Compressed Probabilistic Counting (CPC)</a></li>
<li class="toctree-l1"><a class="reference internal" href="theta.html">Theta Sketch</a></li>
<li class="toctree-l1"><a class="reference internal" href="tuple.html">Tuple Sketch</a></li>
</ul>
</div>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="../index.html" class="btn btn-neutral float-left" title="Apache DataSketches" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="hyper_log_log.html" class="btn btn-neutral float-right" title="HyperLogLog (HLL)" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>