blob: 74df56700b7d4892d4c36d071306ce0819d4040c [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>HllSketch (datasketches-java 4.0.0 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.min.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../jquery-ui.overrides.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../jquery/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-ui.min.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="HllSketch (datasketches-java 4.0.0 API)";
}
}
catch(err) {
}
//-->
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":9,"i8":9,"i9":9,"i10":9,"i11":10,"i12":10,"i13":10,"i14":9,"i15":9,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":10,"i24":10,"i25":10,"i26":10,"i27":9,"i28":9,"i29":10,"i30":10,"i31":10,"i32":10,"i33":10,"i34":10,"i35":10,"i36":10,"i37":10,"i38":9,"i39":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/HllSketch.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.apache.datasketches.hll</a></div>
<h2 title="Class HllSketch" class="title">Class HllSketch</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.datasketches.hll.HllSketch</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<pre>public class <span class="typeNameLabel">HllSketch</span>
extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a></pre>
<div class="block">The HllSketch is actually a collection of compact implementations of Phillipe Flajolet’s HyperLogLog (HLL)
sketch but with significantly improved error behavior and excellent speed performance.
<p>If the use case for sketching is primarily counting uniques and merging, the HLL sketch is the 2nd highest
performing in terms of accuracy for storage space consumed in the DataSketches library
(the new CPC sketch developed by Kevin J. Lang now beats HLL in terms of accuracy / space).
For large counts, HLL sketches can be 2 to 8 times smaller for the same accuracy than the DataSketches Theta
Sketches when serialized, but the Theta sketches can do set intersections and differences while HLL and CPC cannot.
The CPC sketch and HLL share similar use cases, but the CPC sketch is about 30 to 40% smaller than the HLL sketch
when serialized and larger than the HLL when active in memory. Choose your weapons!</p>
<p>A new HLL sketch is created with a simple constructor:</p>
<pre><code>
int lgK = 12; //This is log-base2 of k, so k = 4096. lgK can be from 4 to 21
HllSketch sketch = new HllSketch(lgK); //TgtHllType.HLL_4 is the default
//OR
HllSketch sketch = new HllSketch(lgK, TgtHllType.HLL_6);
//OR
HllSketch sketch = new HllSketch(lgK, TgtHllType.HLL_8);
</code></pre>
<p>All three different sketch types are targets in that the sketches start out in a warm-up mode that is small in
size and gradually grows as needed until the full HLL array is allocated. The HLL_4, HLL_6 and HLL_8 represent
different levels of compression of the final HLL array where the 4, 6 and 8 refer to the number of bits each
bucket of the HLL array is compressed down to.
The HLL_4 is the most compressed but generally slower than the other two, especially during union operations.</p>
<p>All three types share the same API. Updating the HllSketch is very simple:</p>
<pre><code>
long n = 1000000;
for (int i = 0; i &lt; n; i++) {
sketch.update(i);
}
</code></pre>
<p>Each of the presented integers above are first hashed into 128-bit hash values that are used by the sketch
HLL algorithm, so the above loop is essentially equivalent to using a random number generator initialized with a
seed so that the sequence is deterministic and random.</p>
<p>Obtaining the cardinality results from the sketch is also simple:</p>
<pre><code>
double estimate = sketch.getEstimate();
double estUB = sketch.getUpperBound(1.0); //the upper bound at 1 standard deviation.
double estLB = sketch.getLowerBound(1.0); //the lower bound at 1 standard deviation.
//OR
System.out.println(sketch.toString()); //will output a summary of the sketch.
</code></pre>
<p>Which produces a console output something like this:</p>
<pre><code>
### HLL SKETCH SUMMARY:
Log Config K : 12
Hll Target : HLL_4
Current Mode : HLL
LB : 977348.7024560181
Estimate : 990116.6007366662
UB : 1003222.5095308956
OutOfOrder Flag: false
CurMin : 5
NumAtCurMin : 1
HipAccum : 990116.6007366662
</code></pre></div>
<dl>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>Lee Rhodes, Kevin Lang</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<section>
<ul class="blockList">
<li class="blockList"><a id="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Field</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#DEFAULT_HLL_TYPE">DEFAULT_HLL_TYPE</a></span></code></th>
<td class="colLast">
<div class="block">The default HLL-TYPE is HLL_4</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#DEFAULT_LG_K">DEFAULT_LG_K</a></span></code></th>
<td class="colLast">
<div class="block">The default Log_base2 of K</div>
</td>
</tr>
</table>
</li>
</ul>
</section>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<section>
<ul class="blockList">
<li class="blockList"><a id="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">HllSketch</a></span>()</code></th>
<td class="colLast">
<div class="block">Constructs a new on-heap sketch with the default lgConfigK and tgtHllType.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(int)">HllSketch</a></span>&#8203;(int&nbsp;lgConfigK)</code></th>
<td class="colLast">
<div class="block">Constructs a new on-heap sketch with the default tgtHllType.</div>
</td>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(int,org.apache.datasketches.hll.TgtHllType)">HllSketch</a></span>&#8203;(int&nbsp;lgConfigK,
<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</code></th>
<td class="colLast">
<div class="block">Constructs a new on-heap sketch with the type of HLL sketch to configure.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(int,org.apache.datasketches.hll.TgtHllType,org.apache.datasketches.memory.WritableMemory)">HllSketch</a></span>&#8203;(int&nbsp;lgConfigK,
<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType,
org.apache.datasketches.memory.WritableMemory&nbsp;dstMem)</code></th>
<td class="colLast">
<div class="block">Constructs a new sketch with the type of HLL sketch to configure and the given
WritableMemory as the destination for the sketch.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>
<!-- ========== METHOD SUMMARY =========== -->
<section>
<ul class="blockList">
<li class="blockList"><a id="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code><a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#copy()">copy</a></span>()</code></th>
<td class="colLast">
<div class="block">Return a copy of this sketch onto the Java heap.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code><a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#copyAs(org.apache.datasketches.hll.TgtHllType)">copyAs</a></span>&#8203;(<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</code></th>
<td class="colLast">
<div class="block">Return a deep copy of this sketch onto the Java heap with the specified TgtHllType.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getCompactSerializationBytes()">getCompactSerializationBytes</a></span>()</code></th>
<td class="colLast">
<div class="block">Gets the size in bytes of the current sketch when serialized using
<i>toCompactByteArray()</i>.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getCompositeEstimate()">getCompositeEstimate</a></span>()</code></th>
<td class="colLast">
<div class="block">This is less accurate than the <i>getEstimate()</i> method and is automatically used
when the sketch has gone through union operations where the more accurate HIP estimator
cannot be used.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getEstimate()">getEstimate</a></span>()</code></th>
<td class="colLast">
<div class="block">Return the cardinality estimate</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getLgConfigK()">getLgConfigK</a></span>()</code></th>
<td class="colLast">
<div class="block">Gets the <i>lgConfigK</i>.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getLowerBound(int)">getLowerBound</a></span>&#8203;(int&nbsp;numStdDev)</code></th>
<td class="colLast">
<div class="block">Gets the approximate lower error bound given the specified number of Standard Deviations.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getMaxUpdatableSerializationBytes(int,org.apache.datasketches.hll.TgtHllType)">getMaxUpdatableSerializationBytes</a></span>&#8203;(int&nbsp;lgConfigK,
<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</code></th>
<td class="colLast">
<div class="block">Returns the maximum size in bytes that this sketch can grow to given lgConfigK.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>static double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getRelErr(boolean,boolean,int,int)">getRelErr</a></span>&#8203;(boolean&nbsp;upperBound,
boolean&nbsp;oooFlag,
int&nbsp;lgConfigK,
int&nbsp;numStdDev)</code></th>
<td class="colLast">
<div class="block">Gets the current (approximate) Relative Error (RE) asymptotic values given several
parameters.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getSerializationVersion()">getSerializationVersion</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the current serialization version.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>static int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getSerializationVersion(org.apache.datasketches.memory.Memory)">getSerializationVersion</a></span>&#8203;(org.apache.datasketches.memory.Memory&nbsp;mem)</code></th>
<td class="colLast">
<div class="block">Returns the current serialization version of the given Memory.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code><a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getTgtHllType()">getTgtHllType</a></span>()</code></th>
<td class="colLast">
<div class="block">Gets the <a href="TgtHllType.html" title="enum in org.apache.datasketches.hll"><code>TgtHllType</code></a></div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getUpdatableSerializationBytes()">getUpdatableSerializationBytes</a></span>()</code></th>
<td class="colLast">
<div class="block">Gets the size in bytes of the current sketch when serialized using
<i>toUpdatableByteArray()</i>.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getUpperBound(int)">getUpperBound</a></span>&#8203;(int&nbsp;numStdDev)</code></th>
<td class="colLast">
<div class="block">Gets the approximate upper error bound given the specified number of Standard Deviations.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>static <a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#heapify(byte%5B%5D)">heapify</a></span>&#8203;(byte[]&nbsp;byteArray)</code></th>
<td class="colLast">
<div class="block">Heapify the given byte array, which must be a valid HllSketch image and may have data.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>static <a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#heapify(org.apache.datasketches.memory.Memory)">heapify</a></span>&#8203;(org.apache.datasketches.memory.Memory&nbsp;srcMem)</code></th>
<td class="colLast">
<div class="block">Heapify the given Memory, which must be a valid HllSketch image and may have data.</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isCompact()">isCompact</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns true if the backing memory of this sketch is in compact form.</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isEmpty()">isEmpty</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns true if empty</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isEstimationMode()">isEstimationMode</a></span>()</code></th>
<td class="colLast">
<div class="block">This HLL family of sketches and operators is always estimating, even for very small values.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isMemory()">isMemory</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns true if this sketch was created using Memory.</div>
</td>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isOffHeap()">isOffHeap</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns true if the backing memory for this sketch is off-heap.</div>
</td>
</tr>
<tr id="i21" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isSameResource(org.apache.datasketches.memory.Memory)">isSameResource</a></span>&#8203;(org.apache.datasketches.memory.Memory&nbsp;mem)</code></th>
<td class="colLast">
<div class="block">Returns true if the given Memory refers to the same underlying resource as this sketch.</div>
</td>
</tr>
<tr id="i22" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#reset()">reset</a></span>()</code></th>
<td class="colLast">
<div class="block">Resets to empty, but does not change the configured values of lgConfigK and tgtHllType.</div>
</td>
</tr>
<tr id="i23" class="rowColor">
<td class="colFirst"><code>byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toCompactByteArray()">toCompactByteArray</a></span>()</code></th>
<td class="colLast">
<div class="block">Serializes this sketch as a byte array in compact form.</div>
</td>
</tr>
<tr id="i24" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toString()">toString</a></span>()</code></th>
<td class="colLast">
<div class="block">Human readable summary as a string.</div>
</td>
</tr>
<tr id="i25" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toString(boolean,boolean,boolean)">toString</a></span>&#8203;(boolean&nbsp;summary,
boolean&nbsp;detail,
boolean&nbsp;auxDetail)</code></th>
<td class="colLast">
<div class="block">Human readable summary with optional detail.</div>
</td>
</tr>
<tr id="i26" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toString(boolean,boolean,boolean,boolean)">toString</a></span>&#8203;(boolean&nbsp;summary,
boolean&nbsp;detail,
boolean&nbsp;auxDetail,
boolean&nbsp;all)</code></th>
<td class="colLast">
<div class="block">Human readable summary with optional detail</div>
</td>
</tr>
<tr id="i27" class="rowColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toString(byte%5B%5D)">toString</a></span>&#8203;(byte[]&nbsp;byteArr)</code></th>
<td class="colLast">
<div class="block">Returns a human readable string of the preamble of a byte array image of an HllSketch.</div>
</td>
</tr>
<tr id="i28" class="altColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toString(org.apache.datasketches.memory.Memory)">toString</a></span>&#8203;(org.apache.datasketches.memory.Memory&nbsp;mem)</code></th>
<td class="colLast">
<div class="block">Returns a human readable string of the preamble of a Memory image of an HllSketch.</div>
</td>
</tr>
<tr id="i29" class="rowColor">
<td class="colFirst"><code>byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toUpdatableByteArray()">toUpdatableByteArray</a></span>()</code></th>
<td class="colLast">
<div class="block">Serializes this sketch as a byte array in an updatable form.</div>
</td>
</tr>
<tr id="i30" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(byte%5B%5D)">update</a></span>&#8203;(byte[]&nbsp;data)</code></th>
<td class="colLast">
<div class="block">Present the given byte array as a potential unique item.</div>
</td>
</tr>
<tr id="i31" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(char%5B%5D)">update</a></span>&#8203;(char[]&nbsp;data)</code></th>
<td class="colLast">
<div class="block">Present the given char array as a potential unique item.</div>
</td>
</tr>
<tr id="i32" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(double)">update</a></span>&#8203;(double&nbsp;datum)</code></th>
<td class="colLast">
<div class="block">Present the given double (or float) datum as a potential unique item.</div>
</td>
</tr>
<tr id="i33" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(int%5B%5D)">update</a></span>&#8203;(int[]&nbsp;data)</code></th>
<td class="colLast">
<div class="block">Present the given integer array as a potential unique item.</div>
</td>
</tr>
<tr id="i34" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(long)">update</a></span>&#8203;(long&nbsp;datum)</code></th>
<td class="colLast">
<div class="block">Present the given long as a potential unique item.</div>
</td>
</tr>
<tr id="i35" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(long%5B%5D)">update</a></span>&#8203;(long[]&nbsp;data)</code></th>
<td class="colLast">
<div class="block">Present the given long array as a potential unique item.</div>
</td>
</tr>
<tr id="i36" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(java.lang.String)">update</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;datum)</code></th>
<td class="colLast">
<div class="block">Present the given String as a potential unique item.</div>
</td>
</tr>
<tr id="i37" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(java.nio.ByteBuffer)">update</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html?is-external=true" title="class or interface in java.nio" class="externalLink">ByteBuffer</a>&nbsp;data)</code></th>
<td class="colLast">
<div class="block">Present the given byte buffer as a potential unique item.</div>
</td>
</tr>
<tr id="i38" class="altColor">
<td class="colFirst"><code>static <a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#wrap(org.apache.datasketches.memory.Memory)">wrap</a></span>&#8203;(org.apache.datasketches.memory.Memory&nbsp;srcMem)</code></th>
<td class="colLast">
<div class="block">Wraps the given read-only Memory that must be a image of a valid sketch,
which may be in compact or updatable form, and should have data.</div>
</td>
</tr>
<tr id="i39" class="rowColor">
<td class="colFirst"><code>static <a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#writableWrap(org.apache.datasketches.memory.WritableMemory)">writableWrap</a></span>&#8203;(org.apache.datasketches.memory.WritableMemory&nbsp;srcWmem)</code></th>
<td class="colLast">
<div class="block">Wraps the given WritableMemory, which must be a image of a valid updatable sketch,
and may have data.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang" class="externalLink">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang" class="externalLink">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang" class="externalLink">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang" class="externalLink">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang" class="externalLink">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang" class="externalLink">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang" class="externalLink">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait(long,int)" title="class or interface in java.lang" class="externalLink">wait</a></code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<section>
<ul class="blockList">
<li class="blockList"><a id="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a id="DEFAULT_LG_K">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>DEFAULT_LG_K</h4>
<pre>public static final&nbsp;int DEFAULT_LG_K</pre>
<div class="block">The default Log_base2 of K</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../constant-values.html#org.apache.datasketches.hll.HllSketch.DEFAULT_LG_K">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a id="DEFAULT_HLL_TYPE">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>DEFAULT_HLL_TYPE</h4>
<pre>public static final&nbsp;<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a> DEFAULT_HLL_TYPE</pre>
<div class="block">The default HLL-TYPE is HLL_4</div>
</li>
</ul>
</li>
</ul>
</section>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<section>
<ul class="blockList">
<li class="blockList"><a id="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a id="&lt;init&gt;()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>HllSketch</h4>
<pre>public&nbsp;HllSketch()</pre>
<div class="block">Constructs a new on-heap sketch with the default lgConfigK and tgtHllType.</div>
</li>
</ul>
<a id="&lt;init&gt;(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>HllSketch</h4>
<pre>public&nbsp;HllSketch&#8203;(int&nbsp;lgConfigK)</pre>
<div class="block">Constructs a new on-heap sketch with the default tgtHllType.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>lgConfigK</code> - The Log2 of K for the target HLL sketch. This value must be
between 4 and 21 inclusively.</dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;(int,org.apache.datasketches.hll.TgtHllType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>HllSketch</h4>
<pre>public&nbsp;HllSketch&#8203;(int&nbsp;lgConfigK,
<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</pre>
<div class="block">Constructs a new on-heap sketch with the type of HLL sketch to configure.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>lgConfigK</code> - The Log2 of K for the target HLL sketch. This value must be
between 4 and 21 inclusively.</dd>
<dd><code>tgtHllType</code> - the desired HLL type.</dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;(int,org.apache.datasketches.hll.TgtHllType,org.apache.datasketches.memory.WritableMemory)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>HllSketch</h4>
<pre>public&nbsp;HllSketch&#8203;(int&nbsp;lgConfigK,
<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType,
org.apache.datasketches.memory.WritableMemory&nbsp;dstMem)</pre>
<div class="block">Constructs a new sketch with the type of HLL sketch to configure and the given
WritableMemory as the destination for the sketch. This WritableMemory is usually configured
for off-heap memory. What remains on the java heap is a thin wrapper object that reads and
writes to the given WritableMemory.
<p>The given <i>dstMem</i> is checked for the required capacity as determined by
<a href="#getMaxUpdatableSerializationBytes(int,org.apache.datasketches.hll.TgtHllType)"><code>getMaxUpdatableSerializationBytes(int, TgtHllType)</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>lgConfigK</code> - The Log2 of K for the target HLL sketch. This value must be
between 4 and 21 inclusively.</dd>
<dd><code>tgtHllType</code> - the desired HLL type.</dd>
<dd><code>dstMem</code> - the destination memory for the sketch.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
<!-- ============ METHOD DETAIL ========== -->
<section>
<ul class="blockList">
<li class="blockList"><a id="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a id="heapify(byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>heapify</h4>
<pre class="methodSignature">public static final&nbsp;<a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;heapify&#8203;(byte[]&nbsp;byteArray)</pre>
<div class="block">Heapify the given byte array, which must be a valid HllSketch image and may have data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>byteArray</code> - the given byte array. This byteArray is not modified and is not retained
by the on-heap sketch.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an HllSketch on the java heap.</dd>
</dl>
</li>
</ul>
<a id="heapify(org.apache.datasketches.memory.Memory)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>heapify</h4>
<pre class="methodSignature">public static final&nbsp;<a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;heapify&#8203;(org.apache.datasketches.memory.Memory&nbsp;srcMem)</pre>
<div class="block">Heapify the given Memory, which must be a valid HllSketch image and may have data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcMem</code> - the given Memory, which is read-only.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an HllSketch on the java heap.</dd>
</dl>
</li>
</ul>
<a id="writableWrap(org.apache.datasketches.memory.WritableMemory)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>writableWrap</h4>
<pre class="methodSignature">public static final&nbsp;<a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;writableWrap&#8203;(org.apache.datasketches.memory.WritableMemory&nbsp;srcWmem)</pre>
<div class="block">Wraps the given WritableMemory, which must be a image of a valid updatable sketch,
and may have data. What remains on the java heap is a
thin wrapper object that reads and writes to the given WritableMemory, which, depending on
how the user configures the WritableMemory, may actually reside on the Java heap or off-heap.
<p>The given <i>dstMem</i> is checked for the required capacity as determined by
<a href="#getMaxUpdatableSerializationBytes(int,org.apache.datasketches.hll.TgtHllType)"><code>getMaxUpdatableSerializationBytes(int, TgtHllType)</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcWmem</code> - an writable image of a valid source sketch with data.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an HllSketch where the sketch data is in the given dstMem.</dd>
</dl>
</li>
</ul>
<a id="wrap(org.apache.datasketches.memory.Memory)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>wrap</h4>
<pre class="methodSignature">public static final&nbsp;<a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;wrap&#8203;(org.apache.datasketches.memory.Memory&nbsp;srcMem)</pre>
<div class="block">Wraps the given read-only Memory that must be a image of a valid sketch,
which may be in compact or updatable form, and should have data. Any attempt to update the
given source Memory will throw an exception.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcMem</code> - a read-only image of a valid source sketch.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an HllSketch, where the read-only data of the sketch is in the given srcMem.</dd>
</dl>
</li>
</ul>
<a id="copy()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>copy</h4>
<pre class="methodSignature">public&nbsp;<a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;copy()</pre>
<div class="block">Return a copy of this sketch onto the Java heap.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a copy of this sketch onto the Java heap.</dd>
</dl>
</li>
</ul>
<a id="copyAs(org.apache.datasketches.hll.TgtHllType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>copyAs</h4>
<pre class="methodSignature">public&nbsp;<a href="HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;copyAs&#8203;(<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</pre>
<div class="block">Return a deep copy of this sketch onto the Java heap with the specified TgtHllType.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>tgtHllType</code> - the TgtHllType enum</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a deep copy of this sketch with the specified TgtHllType.</dd>
</dl>
</li>
</ul>
<a id="getCompositeEstimate()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCompositeEstimate</h4>
<pre class="methodSignature">public&nbsp;double&nbsp;getCompositeEstimate()</pre>
<div class="block">This is less accurate than the <i>getEstimate()</i> method and is automatically used
when the sketch has gone through union operations where the more accurate HIP estimator
cannot be used.
This is made public only for error characterization software that exists in separate
packages and is not intended for normal use.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the composite estimate</dd>
</dl>
</li>
</ul>
<a id="getEstimate()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getEstimate</h4>
<pre class="methodSignature">public&nbsp;double&nbsp;getEstimate()</pre>
<div class="block">Return the cardinality estimate</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the cardinality estimate</dd>
</dl>
</li>
</ul>
<a id="getLgConfigK()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLgConfigK</h4>
<pre class="methodSignature">public&nbsp;int&nbsp;getLgConfigK()</pre>
<div class="block">Gets the <i>lgConfigK</i>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <i>lgConfigK</i>.</dd>
</dl>
</li>
</ul>
<a id="getCompactSerializationBytes()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCompactSerializationBytes</h4>
<pre class="methodSignature">public&nbsp;int&nbsp;getCompactSerializationBytes()</pre>
<div class="block">Gets the size in bytes of the current sketch when serialized using
<i>toCompactByteArray()</i>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the size in bytes of the current sketch when serialized using
<i>toCompactByteArray()</i>.</dd>
</dl>
</li>
</ul>
<a id="getLowerBound(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLowerBound</h4>
<pre class="methodSignature">public&nbsp;double&nbsp;getLowerBound&#8203;(int&nbsp;numStdDev)</pre>
<div class="block">Gets the approximate lower error bound given the specified number of Standard Deviations.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>numStdDev</code> - This must be an integer between 1 and 3, inclusive.
<a href="../../../../resources/dictionary.html#numStdDev">See Number of Standard Deviations</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the lower bound.</dd>
</dl>
</li>
</ul>
<a id="getMaxUpdatableSerializationBytes(int,org.apache.datasketches.hll.TgtHllType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMaxUpdatableSerializationBytes</h4>
<pre class="methodSignature">public static final&nbsp;int&nbsp;getMaxUpdatableSerializationBytes&#8203;(int&nbsp;lgConfigK,
<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</pre>
<div class="block">Returns the maximum size in bytes that this sketch can grow to given lgConfigK.
However, for the HLL_4 sketch type, this value can be exceeded in extremely rare cases.
If exceeded, it will be larger by only a few percent.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>lgConfigK</code> - The Log2 of K for the target HLL sketch. This value must be
between 4 and 21 inclusively.</dd>
<dd><code>tgtHllType</code> - the desired Hll type</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the maximum size in bytes that this sketch can grow to.</dd>
</dl>
</li>
</ul>
<a id="getTgtHllType()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getTgtHllType</h4>
<pre class="methodSignature">public&nbsp;<a href="TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;getTgtHllType()</pre>
<div class="block">Gets the <a href="TgtHllType.html" title="enum in org.apache.datasketches.hll"><code>TgtHllType</code></a></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the TgtHllType enum value</dd>
</dl>
</li>
</ul>
<a id="getUpdatableSerializationBytes()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUpdatableSerializationBytes</h4>
<pre class="methodSignature">public&nbsp;int&nbsp;getUpdatableSerializationBytes()</pre>
<div class="block">Gets the size in bytes of the current sketch when serialized using
<i>toUpdatableByteArray()</i>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the size in bytes of the current sketch when serialized using
<i>toUpdatableByteArray()</i>.</dd>
</dl>
</li>
</ul>
<a id="getUpperBound(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUpperBound</h4>
<pre class="methodSignature">public&nbsp;double&nbsp;getUpperBound&#8203;(int&nbsp;numStdDev)</pre>
<div class="block">Gets the approximate upper error bound given the specified number of Standard Deviations.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>numStdDev</code> - This must be an integer between 1 and 3, inclusive.
<a href="../../../../resources/dictionary.html#numStdDev">Number of Standard Deviations</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the upper bound.</dd>
</dl>
</li>
</ul>
<a id="isCompact()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isCompact</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isCompact()</pre>
<div class="block">Returns true if the backing memory of this sketch is in compact form.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the backing memory of this sketch is in compact form.</dd>
</dl>
</li>
</ul>
<a id="isEmpty()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isEmpty</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isEmpty()</pre>
<div class="block">Returns true if empty</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if empty</dd>
</dl>
</li>
</ul>
<a id="isMemory()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isMemory</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isMemory()</pre>
<div class="block">Returns true if this sketch was created using Memory.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if this sketch was created using Memory.</dd>
</dl>
</li>
</ul>
<a id="isOffHeap()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isOffHeap</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isOffHeap()</pre>
<div class="block">Returns true if the backing memory for this sketch is off-heap.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the backing memory for this sketch is off-heap.</dd>
</dl>
</li>
</ul>
<a id="isSameResource(org.apache.datasketches.memory.Memory)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isSameResource</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isSameResource&#8203;(org.apache.datasketches.memory.Memory&nbsp;mem)</pre>
<div class="block">Returns true if the given Memory refers to the same underlying resource as this sketch.
The capacities must be the same. If <i>this</i> is a region,
the region offset must also be the same.
<p>This is only relevant for HLL_4 sketches that have been configured for off-heap
using WritableMemory or Memory. For on-heap sketches or unions this will return false.
<p>It is rare, but possible, the the off-heap memory that has been allocated to an HLL_4
sketch may not be large enough. If this should happen, the sketch makes a request for more
memory from the owner of the resource and then moves itself to this new location. This all
happens transparently to the user. This method provides a means for the user to
inquire of the sketch if it has, in fact, moved itself.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mem</code> - the given Memory</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the given Memory refers to the same underlying resource as this sketch or
union.</dd>
</dl>
</li>
</ul>
<a id="reset()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reset</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;reset()</pre>
<div class="block">Resets to empty, but does not change the configured values of lgConfigK and tgtHllType.</div>
</li>
</ul>
<a id="toCompactByteArray()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toCompactByteArray</h4>
<pre class="methodSignature">public&nbsp;byte[]&nbsp;toCompactByteArray()</pre>
<div class="block">Serializes this sketch as a byte array in compact form. The compact form is smaller in size
than the updatable form and read-only. It can be used in union operations as follows:
<pre><code>
Union union; HllSketch sk, sk2;
int lgK = 12;
sk = new HllSketch(lgK, TgtHllType.HLL_4); //can be 4, 6, or 8
for (int i = 0; i &lt; (2 &lt;&lt; lgK); i++) { sk.update(i); }
byte[] arr = HllSketch.toCompactByteArray();
//...
union = Union.heapify(arr); //initializes the union using data from the array.
//OR, if used in an off-heap environment:
union = Union.heapify(Memory.wrap(arr)); //same as above, except from Memory object.
//To recover an updatable heap sketch:
sk2 = HllSketch.heapify(arr);
//OR, if used in an off-heap environment:
sk2 = HllSketch.heapify(Memory.wrap(arr));
</code></pre>
<p>The sketch "wrapping" operation skips actual deserialization thus is quite fast. However,
any attempt to update the derived HllSketch will result in a Read-only exception.</p>
<p>Note that in some cases, based on the state of the sketch, the compact form is
indistiguishable from the updatable form. In these cases the updatable form is returned
and the compact flag bit will not be set.</p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>this sketch as a compact byte array.</dd>
</dl>
</li>
</ul>
<a id="toUpdatableByteArray()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toUpdatableByteArray</h4>
<pre class="methodSignature">public&nbsp;byte[]&nbsp;toUpdatableByteArray()</pre>
<div class="block">Serializes this sketch as a byte array in an updatable form. The updatable form is larger than
the compact form. The use of this form is primarily in environments that support updating
sketches in off-heap memory. If the sketch is constructed using HLL_8, sketch updating and
union updating operations can actually occur in WritableMemory, which can be off-heap:
<pre><code>
Union union; HllSketch sk;
int lgK = 12;
sk = new HllSketch(lgK, TgtHllType.HLL_8) //must be 8
for (int i = 0; i &lt; (2 &lt;&lt; lgK); i++) { sk.update(i); }
byte[] arr = sk.toUpdatableByteArray();
WritableMemory wmem = WritableMemory.wrap(arr);
//...
union = Union.writableWrap(wmem); //no deserialization!
</code></pre></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>this sketch as an updatable byte array.</dd>
</dl>
</li>
</ul>
<a id="toString(boolean,boolean,boolean,boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre class="methodSignature">public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;toString&#8203;(boolean&nbsp;summary,
boolean&nbsp;detail,
boolean&nbsp;auxDetail,
boolean&nbsp;all)</pre>
<div class="block">Human readable summary with optional detail</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>summary</code> - if true, output the sketch summary</dd>
<dd><code>detail</code> - if true, output the internal data array</dd>
<dd><code>auxDetail</code> - if true, output the internal Aux array, if it exists.</dd>
<dd><code>all</code> - if true, outputs all entries including empty ones</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>human readable string with optional detail.</dd>
</dl>
</li>
</ul>
<a id="toString(byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre class="methodSignature">public static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;toString&#8203;(byte[]&nbsp;byteArr)</pre>
<div class="block">Returns a human readable string of the preamble of a byte array image of an HllSketch.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>byteArr</code> - the given byte array</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a human readable string of the preamble of a byte array image of an HllSketch.</dd>
</dl>
</li>
</ul>
<a id="toString(org.apache.datasketches.memory.Memory)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre class="methodSignature">public static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;toString&#8203;(org.apache.datasketches.memory.Memory&nbsp;mem)</pre>
<div class="block">Returns a human readable string of the preamble of a Memory image of an HllSketch.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mem</code> - the given Memory object</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a human readable string of the preamble of a Memory image of an HllSketch.</dd>
</dl>
</li>
</ul>
<a id="getSerializationVersion()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSerializationVersion</h4>
<pre class="methodSignature">public static final&nbsp;int&nbsp;getSerializationVersion()</pre>
<div class="block">Returns the current serialization version.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the current serialization version.</dd>
</dl>
</li>
</ul>
<a id="getSerializationVersion(org.apache.datasketches.memory.Memory)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSerializationVersion</h4>
<pre class="methodSignature">public static final&nbsp;int&nbsp;getSerializationVersion&#8203;(org.apache.datasketches.memory.Memory&nbsp;mem)</pre>
<div class="block">Returns the current serialization version of the given Memory.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mem</code> - the given Memory containing a serialized HllSketch image.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the current serialization version.</dd>
</dl>
</li>
</ul>
<a id="getRelErr(boolean,boolean,int,int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getRelErr</h4>
<pre class="methodSignature">public static&nbsp;double&nbsp;getRelErr&#8203;(boolean&nbsp;upperBound,
boolean&nbsp;oooFlag,
int&nbsp;lgConfigK,
int&nbsp;numStdDev)</pre>
<div class="block">Gets the current (approximate) Relative Error (RE) asymptotic values given several
parameters. This is used primarily for testing.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>upperBound</code> - return the RE for the Upper Bound, otherwise for the Lower Bound.</dd>
<dd><code>oooFlag</code> - set true if the sketch is the result of a non qualifying union operation.</dd>
<dd><code>lgConfigK</code> - the configured value for the sketch.</dd>
<dd><code>numStdDev</code> - the given number of Standard Deviations. This must be an integer between
1 and 3, inclusive.
<a href="../../../../resources/dictionary.html#numStdDev">Number of Standard Deviations</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the current (approximate) RelativeError</dd>
</dl>
</li>
</ul>
<a id="isEstimationMode()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isEstimationMode</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;isEstimationMode()</pre>
<div class="block">This HLL family of sketches and operators is always estimating, even for very small values.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true</dd>
</dl>
</li>
</ul>
<a id="toString()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre class="methodSignature">public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;toString()</pre>
<div class="block">Human readable summary as a string.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang" class="externalLink">toString</a></code>&nbsp;in class&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Human readable summary as a string.</dd>
</dl>
</li>
</ul>
<a id="toString(boolean,boolean,boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre class="methodSignature">public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;toString&#8203;(boolean&nbsp;summary,
boolean&nbsp;detail,
boolean&nbsp;auxDetail)</pre>
<div class="block">Human readable summary with optional detail. Does not list empty entries.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>summary</code> - if true, output the sketch summary</dd>
<dd><code>detail</code> - if true, output the internal data array</dd>
<dd><code>auxDetail</code> - if true, output the internal Aux array, if it exists.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>human readable string with optional detail.</dd>
</dl>
</li>
</ul>
<a id="update(long)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(long&nbsp;datum)</pre>
<div class="block">Present the given long as a potential unique item.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>datum</code> - The given long datum.</dd>
</dl>
</li>
</ul>
<a id="update(double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(double&nbsp;datum)</pre>
<div class="block">Present the given double (or float) datum as a potential unique item.
The double will be converted to a long using Double.doubleToLongBits(datum),
which normalizes all NaN values to a single NaN representation.
Plus and minus zero will be normalized to plus zero.
The special floating-point values NaN and +/- Infinity are treated as distinct.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>datum</code> - The given double datum.</dd>
</dl>
</li>
</ul>
<a id="update(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;datum)</pre>
<div class="block">Present the given String as a potential unique item.
The string is converted to a byte array using UTF8 encoding.
If the string is null or empty no update attempt is made and the method returns.
<p>Note: About 2X faster performance can be obtained by first converting the String to a
char[] and updating the sketch with that. This bypasses the complexity of the Java UTF_8
encoding. This, of course, will not produce the same internal hash values as updating directly
with a String. So be consistent! Unioning two sketches, one fed with strings and the other
fed with char[] will be meaningless.
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>datum</code> - The given String.</dd>
</dl>
</li>
</ul>
<a id="update(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html?is-external=true" title="class or interface in java.nio" class="externalLink">ByteBuffer</a>&nbsp;data)</pre>
<div class="block">Present the given byte buffer as a potential unique item.
Bytes are read from the current position of the buffer until its limit.
If the byte buffer is null or has no bytes remaining, no update attempt is made and the method returns.
<p>This method will not modify the position, mark, limit, or byte order of the buffer.</p>
<p>Little-endian order is preferred, but not required. This method may perform better if the provided byte
buffer is in little-endian order.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - The given byte buffer.</dd>
</dl>
</li>
</ul>
<a id="update(byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(byte[]&nbsp;data)</pre>
<div class="block">Present the given byte array as a potential unique item.
If the byte array is null or empty no update attempt is made and the method returns.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - The given byte array.</dd>
</dl>
</li>
</ul>
<a id="update(char[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(char[]&nbsp;data)</pre>
<div class="block">Present the given char array as a potential unique item.
If the char array is null or empty no update attempt is made and the method returns.
<p>Note: this will not produce the same output hash values as the <i>update(String)</i>
method but will be a little faster as it avoids the complexity of the UTF8 encoding.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - The given char array.</dd>
</dl>
</li>
</ul>
<a id="update(int[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(int[]&nbsp;data)</pre>
<div class="block">Present the given integer array as a potential unique item.
If the integer array is null or empty no update attempt is made and the method returns.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - The given int array.</dd>
</dl>
</li>
</ul>
<a id="update(long[])">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>update</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;update&#8203;(long[]&nbsp;data)</pre>
<div class="block">Present the given long array as a potential unique item.
If the long array is null or empty no update attempt is made and the method returns.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - The given long array.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/HllSketch.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small>Copyright &#169; 2015&#x2013;2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</footer>
</body>
</html>