blob: a60930eb7f71cc550f9467c5a7eb01f97ffbb6b1 [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>HyperLogLog (HLL) &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="Compressed Probabilistic Counting (CPC)" href="cpc.html" />
<link rel="prev" title="Distinct Counting" 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="reference internal" href="index.html">Distinct Counting</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">HyperLogLog (HLL)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#datasketches.tgt_hll_type"><code class="docutils literal notranslate"><span class="pre">tgt_hll_type</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.tgt_hll_type.HLL_4"><code class="docutils literal notranslate"><span class="pre">tgt_hll_type.HLL_4</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.tgt_hll_type.HLL_6"><code class="docutils literal notranslate"><span class="pre">tgt_hll_type.HLL_6</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.tgt_hll_type.HLL_8"><code class="docutils literal notranslate"><span class="pre">tgt_hll_type.HLL_8</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#datasketches.hll_sketch"><code class="docutils literal notranslate"><span class="pre">hll_sketch</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.deserialize"><code class="docutils literal notranslate"><span class="pre">hll_sketch.deserialize()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.get_max_updatable_serialization_bytes"><code class="docutils literal notranslate"><span class="pre">hll_sketch.get_max_updatable_serialization_bytes()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.get_rel_err"><code class="docutils literal notranslate"><span class="pre">hll_sketch.get_rel_err()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.__init__"><code class="docutils literal notranslate"><span class="pre">hll_sketch.__init__()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.get_compact_serialization_bytes"><code class="docutils literal notranslate"><span class="pre">hll_sketch.get_compact_serialization_bytes</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.get_estimate"><code class="docutils literal notranslate"><span class="pre">hll_sketch.get_estimate</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.get_lower_bound"><code class="docutils literal notranslate"><span class="pre">hll_sketch.get_lower_bound</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.get_updatable_serialization_bytes"><code class="docutils literal notranslate"><span class="pre">hll_sketch.get_updatable_serialization_bytes</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.get_upper_bound"><code class="docutils literal notranslate"><span class="pre">hll_sketch.get_upper_bound</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.is_compact"><code class="docutils literal notranslate"><span class="pre">hll_sketch.is_compact</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.is_empty"><code class="docutils literal notranslate"><span class="pre">hll_sketch.is_empty</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.lg_config_k"><code class="docutils literal notranslate"><span class="pre">hll_sketch.lg_config_k</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.reset"><code class="docutils literal notranslate"><span class="pre">hll_sketch.reset</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.serialize_compact"><code class="docutils literal notranslate"><span class="pre">hll_sketch.serialize_compact</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.serialize_updatable"><code class="docutils literal notranslate"><span class="pre">hll_sketch.serialize_updatable</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.tgt_type"><code class="docutils literal notranslate"><span class="pre">hll_sketch.tgt_type</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.to_string"><code class="docutils literal notranslate"><span class="pre">hll_sketch.to_string</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_sketch.update"><code class="docutils literal notranslate"><span class="pre">hll_sketch.update</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#datasketches.hll_union"><code class="docutils literal notranslate"><span class="pre">hll_union</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.get_rel_err"><code class="docutils literal notranslate"><span class="pre">hll_union.get_rel_err()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.__init__"><code class="docutils literal notranslate"><span class="pre">hll_union.__init__()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.get_estimate"><code class="docutils literal notranslate"><span class="pre">hll_union.get_estimate</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.get_lower_bound"><code class="docutils literal notranslate"><span class="pre">hll_union.get_lower_bound</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.get_result"><code class="docutils literal notranslate"><span class="pre">hll_union.get_result</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.get_upper_bound"><code class="docutils literal notranslate"><span class="pre">hll_union.get_upper_bound</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.is_empty"><code class="docutils literal notranslate"><span class="pre">hll_union.is_empty</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.lg_config_k"><code class="docutils literal notranslate"><span class="pre">hll_union.lg_config_k</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.reset"><code class="docutils literal notranslate"><span class="pre">hll_union.reset</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#datasketches.hll_union.update"><code class="docutils literal notranslate"><span class="pre">hll_union.update</span></code></a></li>
</ul>
</li>
</ul>
</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"><a href="index.html">Distinct Counting</a></li>
<li class="breadcrumb-item active">HyperLogLog (HLL)</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/distinct_counting/hyper_log_log.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="hyperloglog-hll">
<h1>HyperLogLog (HLL)<a class="headerlink" href="#hyperloglog-hll" title="Link to this heading"></a></h1>
<p>This is a high performance implementation of Phillipe Flajolet’s HLL sketch but with significantly improved error behavior.</p>
<p>If the ONLY use case for sketching is counting uniques and merging, the HLL sketch is a reasonable choice, although the highest performing in terms of accuracy for storage space consumed is CPC (Compressed Probabilistic Counting). For large enough counts, this HLL version (with HLL_4) can be 2 to 16 times smaller than the Theta sketch family for the same accuracy.</p>
<p>This implementation offers three different types of HLL sketch, each with different trade-offs with accuracy, space and performance.
These types are specified with the target_hll_type parameter.</p>
<p>In terms of accuracy, all three types, for the same lg_config_k, have the same error distribution as a function of <code class="docutils literal notranslate"><span class="pre">n</span></code>, the number of unique values fed to the sketch.
The configuration parameter <code class="docutils literal notranslate"><span class="pre">lg_config_k</span></code> is the log-base-2 of <code class="docutils literal notranslate"><span class="pre">k</span></code>, where <code class="docutils literal notranslate"><span class="pre">k</span></code> is the number of buckets or slots for the sketch.</p>
<p>During warmup, when the sketch has only received a small number of unique items (up to about 10% of <code class="docutils literal notranslate"><span class="pre">k</span></code>), this implementation leverages a new class of estimator algorithms with significantly better accuracy.</p>
<dl class="py class">
<dt class="sig sig-object py" id="datasketches.tgt_hll_type">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">tgt_hll_type</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">values</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#datasketches.tgt_hll_type" title="Link to this definition"></a></dt>
<dd><p>Target HLL flavor</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.tgt_hll_type.HLL_4">
<span class="sig-name descname"><span class="pre">HLL_4</span></span><em class="property"><span class="w"> </span><span class="pre">:</span> <span class="pre">4</span> <span class="pre">bits</span> <span class="pre">per</span> <span class="pre">entry</span></em><a class="headerlink" href="#datasketches.tgt_hll_type.HLL_4" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.tgt_hll_type.HLL_6">
<span class="sig-name descname"><span class="pre">HLL_6</span></span><em class="property"><span class="w"> </span><span class="pre">:</span> <span class="pre">6</span> <span class="pre">bits</span> <span class="pre">per</span> <span class="pre">entry</span></em><a class="headerlink" href="#datasketches.tgt_hll_type.HLL_6" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.tgt_hll_type.HLL_8">
<span class="sig-name descname"><span class="pre">HLL_8</span></span><em class="property"><span class="w"> </span><span class="pre">:</span> <span class="pre">8</span> <span class="pre">bits</span> <span class="pre">per</span> <span class="pre">entry</span></em><a class="headerlink" href="#datasketches.tgt_hll_type.HLL_8" title="Link to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="datasketches.hll_sketch">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">hll_sketch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#datasketches.hll_sketch" title="Link to this definition"></a></dt>
<dd><p class="rubric">Static Methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="datasketches.hll_sketch.deserialize">
<span class="sig-name descname"><span class="pre">deserialize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">bytes</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bytes</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#datasketches.hll_sketch" title="_datasketches.hll_sketch"><span class="pre">_datasketches.hll_sketch</span></a></span></span><a class="headerlink" href="#datasketches.hll_sketch.deserialize" title="Link to this definition"></a></dt>
<dd><p>Reads a bytes object and returns the corresponding hll_sketch</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="datasketches.hll_sketch.get_max_updatable_serialization_bytes">
<span class="sig-name descname"><span class="pre">get_max_updatable_serialization_bytes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lg_k</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tgt_type</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.tgt_hll_type" title="_datasketches.tgt_hll_type"><span class="pre">_datasketches.tgt_hll_type</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">int</span></span></span><a class="headerlink" href="#datasketches.hll_sketch.get_max_updatable_serialization_bytes" title="Link to this definition"></a></dt>
<dd><p>Provides a likely upper bound on serialization size for the given parameters</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="datasketches.hll_sketch.get_rel_err">
<span class="sig-name descname"><span class="pre">get_rel_err</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">upper_bound</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unioned</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lg_k</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_std_devs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="headerlink" href="#datasketches.hll_sketch.get_rel_err" title="Link to this definition"></a></dt>
<dd><p>Returns the a priori relative error bound for the given parameters</p>
</dd></dl>
<p class="rubric">Non-static Methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="datasketches.hll_sketch.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lg_k</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tgt_type</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#datasketches.tgt_hll_type" title="_datasketches.tgt_hll_type"><span class="pre">_datasketches.tgt_hll_type</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">tgt_hll_type.HLL_8</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">start_max_size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#datasketches.hll_sketch.__init__" title="Link to this definition"></a></dt>
<dd><p>Constructs a new HLL sketch</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>lg_config_k</strong> (<em>int</em>) – A full sketch can hold 2^lg_config_k rows. Must be between 7 and 21, inclusive,</p></li>
<li><p><strong>tgt_type</strong> (<a class="reference internal" href="#datasketches.tgt_hll_type" title="_datasketches.tgt_hll_type"><em>tgt_hll_type</em></a>) – The HLL mode to use, if/when the sketch reaches estimation mode</p></li>
<li><p><strong>start_full_size</strong> (<em>bool</em>) – Indicates whether to start in HLL mode, keeping memory use constant (if HLL_6 or HLL_8) at the cost of much higher initial memory use. Default (and recommended) is False.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.get_compact_serialization_bytes">
<span class="sig-name descname"><span class="pre">get_compact_serialization_bytes</span></span><a class="headerlink" href="#datasketches.hll_sketch.get_compact_serialization_bytes" title="Link to this definition"></a></dt>
<dd><p>Returns the size of the serialized sketch when compressing the exception table if HLL_4</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.get_estimate">
<span class="sig-name descname"><span class="pre">get_estimate</span></span><a class="headerlink" href="#datasketches.hll_sketch.get_estimate" title="Link to this definition"></a></dt>
<dd><p>Estimate of the distinct count of the input stream</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.get_lower_bound">
<span class="sig-name descname"><span class="pre">get_lower_bound</span></span><a class="headerlink" href="#datasketches.hll_sketch.get_lower_bound" title="Link to this definition"></a></dt>
<dd><p>Returns the approximate lower error bound given the specified number of standard deviations in {1, 2, 3}</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.get_updatable_serialization_bytes">
<span class="sig-name descname"><span class="pre">get_updatable_serialization_bytes</span></span><a class="headerlink" href="#datasketches.hll_sketch.get_updatable_serialization_bytes" title="Link to this definition"></a></dt>
<dd><p>Returns the size of the serialized sketch</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.get_upper_bound">
<span class="sig-name descname"><span class="pre">get_upper_bound</span></span><a class="headerlink" href="#datasketches.hll_sketch.get_upper_bound" title="Link to this definition"></a></dt>
<dd><p>Returns the approximate upper error bound given the specified number of standard deviations in {1, 2, 3}</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.is_compact">
<span class="sig-name descname"><span class="pre">is_compact</span></span><a class="headerlink" href="#datasketches.hll_sketch.is_compact" title="Link to this definition"></a></dt>
<dd><p>True if the sketch is compact, otherwise False</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.is_empty">
<span class="sig-name descname"><span class="pre">is_empty</span></span><a class="headerlink" href="#datasketches.hll_sketch.is_empty" title="Link to this definition"></a></dt>
<dd><p>True if the sketch is empty, otherwise False</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="datasketches.hll_sketch.lg_config_k">
<em class="property"><span class="k"><span class="pre">property</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">lg_config_k</span></span><a class="headerlink" href="#datasketches.hll_sketch.lg_config_k" title="Link to this definition"></a></dt>
<dd><p>Configured lg_k value for the sketch</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.reset">
<span class="sig-name descname"><span class="pre">reset</span></span><a class="headerlink" href="#datasketches.hll_sketch.reset" title="Link to this definition"></a></dt>
<dd><p>Resets the sketch to the empty state in coupon collection mode</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.serialize_compact">
<span class="sig-name descname"><span class="pre">serialize_compact</span></span><a class="headerlink" href="#datasketches.hll_sketch.serialize_compact" title="Link to this definition"></a></dt>
<dd><p>Serializes the sketch into a bytes object, compressing the exception table if HLL_4</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.serialize_updatable">
<span class="sig-name descname"><span class="pre">serialize_updatable</span></span><a class="headerlink" href="#datasketches.hll_sketch.serialize_updatable" title="Link to this definition"></a></dt>
<dd><p>Serializes the sketch into a bytes object</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="datasketches.hll_sketch.tgt_type">
<em class="property"><span class="k"><span class="pre">property</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">tgt_type</span></span><a class="headerlink" href="#datasketches.hll_sketch.tgt_type" title="Link to this definition"></a></dt>
<dd><p>The HLL type (4, 6, or 8) when in estimation mode</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.to_string">
<span class="sig-name descname"><span class="pre">to_string</span></span><a class="headerlink" href="#datasketches.hll_sketch.to_string" title="Link to this definition"></a></dt>
<dd><p>Produces a string summary of the sketch</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_sketch.update">
<span class="sig-name descname"><span class="pre">update</span></span><a class="headerlink" href="#datasketches.hll_sketch.update" title="Link to this definition"></a></dt>
<dd><p>Overloaded function.</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">update(self,</span> <span class="pre">datum:</span> <span class="pre">int)</span> <span class="pre">-&gt;</span> <span class="pre">None</span></code></p></li>
</ol>
<p>Updates the sketch with the given integral value</p>
<ol class="arabic simple" start="2">
<li><p><code class="docutils literal notranslate"><span class="pre">update(self,</span> <span class="pre">datum:</span> <span class="pre">float)</span> <span class="pre">-&gt;</span> <span class="pre">None</span></code></p></li>
</ol>
<p>Updates the sketch with the given floating point value</p>
<ol class="arabic simple" start="3">
<li><p><code class="docutils literal notranslate"><span class="pre">update(self,</span> <span class="pre">datum:</span> <span class="pre">str)</span> <span class="pre">-&gt;</span> <span class="pre">None</span></code></p></li>
</ol>
<p>Updates the sketch with the given string value</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="datasketches.hll_union">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">hll_union</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#datasketches.hll_union" title="Link to this definition"></a></dt>
<dd><p class="rubric">Static Methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="datasketches.hll_union.get_rel_err">
<span class="sig-name descname"><span class="pre">get_rel_err</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">upper_bound</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unioned</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lg_k</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_std_devs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">float</span></span></span><a class="headerlink" href="#datasketches.hll_union.get_rel_err" title="Link to this definition"></a></dt>
<dd><p>Returns the a priori relative error bound for the given parameters</p>
</dd></dl>
<p class="rubric">Non-static Methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="datasketches.hll_union.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lg_max_k</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#datasketches.hll_union.__init__" title="Link to this definition"></a></dt>
<dd><p>Construct an hll_union object if the given size.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>lg_max_k</strong> (<em>int</em>) – The maximum size, in log2, of k. Must be between 7 and 21, inclusive.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_union.get_estimate">
<span class="sig-name descname"><span class="pre">get_estimate</span></span><a class="headerlink" href="#datasketches.hll_union.get_estimate" title="Link to this definition"></a></dt>
<dd><p>Estimate of the distinct count of the input stream</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_union.get_lower_bound">
<span class="sig-name descname"><span class="pre">get_lower_bound</span></span><a class="headerlink" href="#datasketches.hll_union.get_lower_bound" title="Link to this definition"></a></dt>
<dd><p>Returns the approximate lower error bound given the specified number of standard deviations in {1, 2, 3}</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_union.get_result">
<span class="sig-name descname"><span class="pre">get_result</span></span><a class="headerlink" href="#datasketches.hll_union.get_result" title="Link to this definition"></a></dt>
<dd><p>Returns a sketch of the target type representing the current union state</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_union.get_upper_bound">
<span class="sig-name descname"><span class="pre">get_upper_bound</span></span><a class="headerlink" href="#datasketches.hll_union.get_upper_bound" title="Link to this definition"></a></dt>
<dd><p>Returns the approximate upper error bound given the specified number of standard deviations in {1, 2, 3}</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_union.is_empty">
<span class="sig-name descname"><span class="pre">is_empty</span></span><a class="headerlink" href="#datasketches.hll_union.is_empty" title="Link to this definition"></a></dt>
<dd><p>True if the union is empty, otherwise False</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="datasketches.hll_union.lg_config_k">
<em class="property"><span class="k"><span class="pre">property</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">lg_config_k</span></span><a class="headerlink" href="#datasketches.hll_union.lg_config_k" title="Link to this definition"></a></dt>
<dd><p>Configured lg_k value for the union</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_union.reset">
<span class="sig-name descname"><span class="pre">reset</span></span><a class="headerlink" href="#datasketches.hll_union.reset" title="Link to this definition"></a></dt>
<dd><p>Resets the union to the empty state</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="datasketches.hll_union.update">
<span class="sig-name descname"><span class="pre">update</span></span><a class="headerlink" href="#datasketches.hll_union.update" title="Link to this definition"></a></dt>
<dd><p>Overloaded function.</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">update(self,</span> <span class="pre">sketch:</span> <span class="pre">_datasketches.hll_sketch)</span> <span class="pre">-&gt;</span> <span class="pre">None</span></code></p></li>
</ol>
<p>Updates the union with the given HLL sketch</p>
<ol class="arabic simple" start="2">
<li><p><code class="docutils literal notranslate"><span class="pre">update(self,</span> <span class="pre">datum:</span> <span class="pre">int)</span> <span class="pre">-&gt;</span> <span class="pre">None</span></code></p></li>
</ol>
<p>Updates the union with the given integral value</p>
<ol class="arabic simple" start="3">
<li><p><code class="docutils literal notranslate"><span class="pre">update(self,</span> <span class="pre">datum:</span> <span class="pre">float)</span> <span class="pre">-&gt;</span> <span class="pre">None</span></code></p></li>
</ol>
<p>Updates the union with the given floating point value</p>
<ol class="arabic simple" start="4">
<li><p><code class="docutils literal notranslate"><span class="pre">update(self,</span> <span class="pre">datum:</span> <span class="pre">str)</span> <span class="pre">-&gt;</span> <span class="pre">None</span></code></p></li>
</ol>
<p>Updates the union with the given string value</p>
</dd></dl>
</dd></dl>
</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="Distinct Counting" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="cpc.html" class="btn btn-neutral float-right" title="Compressed Probabilistic Counting (CPC)" 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>