blob: ba7c9cb078c413a6fd84897cf7153681cabc4aa6 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_302) on Wed Jan 26 15:15:50 PST 2022 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>HllSketch (datasketches-java 3.1.0 API)</title>
<meta name="date" content="2022-01-26">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="HllSketch (datasketches-java 3.1.0 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":9,"i8":10,"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";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.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">
<li>Prev&nbsp;Class</li>
<li><a href="../../../../org/apache/datasketches/hll/IntMemoryPairIterator.html" title="class in org.apache.datasketches.hll"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/datasketches/hll/HllSketch.html" target="_top">Frames</a></li>
<li><a href="HllSketch.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></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>
</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 name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.datasketches.hll</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">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>
<br>
<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">Object</a></pre>
<div class="block">This is a high performance implementation of Phillipe Flajolet&#8217;s HLL sketch but with
significantly improved error behavior. If the ONLY use case for sketching is counting
uniques and merging, the HLL sketch 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>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
<a href="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll"><code>TgtHllType</code></a> parameter.
<p>In terms of accuracy, all three types, for the same <i>lgConfigK</i>, have the same error
distribution as a function of <i>n</i>, the number of unique values fed to the sketch.
The configuration parameter <i>lgConfigK</i> is the log-base-2 of <i>K</i>,
where <i>K</i> is the number of buckets or slots for the sketch.
<p>During warmup, when the sketch has only received a small number of unique items
(up to about 10% of <i>K</i>), this implementation leverages a new class of estimator
algorithms with significantly better accuracy.
<p>This sketch also offers the capability of operating off-heap. Given a WritableMemory object
created by the user, the sketch will perform all of its updates and internal phase transitions
in that object, which can actually reside either on-heap or off-heap based on how it is
configured. In large systems that must update and merge many millions of sketches, having the
sketch operate off-heap avoids the serialization and deserialization costs of moving sketches
to and from off-heap memory-mapped files, for example, and eliminates big garbage collection
delays.</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 =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#DEFAULT_HLL_TYPE">DEFAULT_HLL_TYPE</a></span></code>
<div class="block">The default HLL-TYPE is HLL_4</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#DEFAULT_LG_K">DEFAULT_LG_K</a></span></code>
<div class="block">The default Log_base2 of K</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#HllSketch--">HllSketch</a></span>()</code>
<div class="block">Constructs a new on-heap sketch with the default lgConfigK and tgtHllType.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#HllSketch-int-">HllSketch</a></span>(int&nbsp;lgConfigK)</code>
<div class="block">Constructs a new on-heap sketch with the default tgtHllType.</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#HllSketch-int-org.apache.datasketches.hll.TgtHllType-">HllSketch</a></span>(int&nbsp;lgConfigK,
<a href="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</code>
<div class="block">Constructs a new on-heap sketch with the type of HLL sketch to configure.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#HllSketch-int-org.apache.datasketches.hll.TgtHllType-org.apache.datasketches.memory.WritableMemory-">HllSketch</a></span>(int&nbsp;lgConfigK,
<a href="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType,
org.apache.datasketches.memory.WritableMemory&nbsp;dstMem)</code>
<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>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<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="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code><a href="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#copy--">copy</a></span>()</code>
<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="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#copyAs-org.apache.datasketches.hll.TgtHllType-">copyAs</a></span>(<a href="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getCompactSerializationBytes--">getCompactSerializationBytes</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getCompositeEstimate--">getCompositeEstimate</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getEstimate--">getEstimate</a></span>()</code>
<div class="block">Return the cardinality estimate</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getLgConfigK--">getLgConfigK</a></span>()</code>
<div class="block">Gets the <i>lgConfigK</i>.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getLowerBound-int-">getLowerBound</a></span>(int&nbsp;numStdDev)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getMaxUpdatableSerializationBytes-int-org.apache.datasketches.hll.TgtHllType-">getMaxUpdatableSerializationBytes</a></span>(int&nbsp;lgConfigK,
<a href="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;tgtHllType)</code>
<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>double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getRelErr-boolean-boolean-int-int-">getRelErr</a></span>(boolean&nbsp;upperBound,
boolean&nbsp;unioned,
int&nbsp;lgConfigK,
int&nbsp;numStdDev)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getSerializationVersion--">getSerializationVersion</a></span>()</code>
<div class="block">Returns the current serialization version.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getSerializationVersion-org.apache.datasketches.memory.Memory-">getSerializationVersion</a></span>(org.apache.datasketches.memory.Memory&nbsp;mem)</code>
<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="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getTgtHllType--">getTgtHllType</a></span>()</code>
<div class="block">Gets the <a href="../../../../org/apache/datasketches/hll/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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getUpdatableSerializationBytes--">getUpdatableSerializationBytes</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#getUpperBound-int-">getUpperBound</a></span>(int&nbsp;numStdDev)</code>
<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="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#heapify-byte:A-">heapify</a></span>(byte[]&nbsp;byteArray)</code>
<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="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#heapify-org.apache.datasketches.memory.Memory-">heapify</a></span>(org.apache.datasketches.memory.Memory&nbsp;srcMem)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#isCompact--">isCompact</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#isEmpty--">isEmpty</a></span>()</code>
<div class="block">Returns true if empty</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#isEstimationMode--">isEstimationMode</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#isMemory--">isMemory</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#isOffHeap--">isOffHeap</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#isSameResource-org.apache.datasketches.memory.Memory-">isSameResource</a></span>(org.apache.datasketches.memory.Memory&nbsp;mem)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#reset--">reset</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#toCompactByteArray--">toCompactByteArray</a></span>()</code>
<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">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#toString--">toString</a></span>()</code>
<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">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#toString-boolean-boolean-boolean-">toString</a></span>(boolean&nbsp;summary,
boolean&nbsp;detail,
boolean&nbsp;auxDetail)</code>
<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">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#toString-boolean-boolean-boolean-boolean-">toString</a></span>(boolean&nbsp;summary,
boolean&nbsp;detail,
boolean&nbsp;auxDetail,
boolean&nbsp;all)</code>
<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">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#toString-byte:A-">toString</a></span>(byte[]&nbsp;byteArr)</code>
<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">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#toString-org.apache.datasketches.memory.Memory-">toString</a></span>(org.apache.datasketches.memory.Memory&nbsp;mem)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#toUpdatableByteArray--">toUpdatableByteArray</a></span>()</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-byte:A-">update</a></span>(byte[]&nbsp;data)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-java.nio.ByteBuffer-">update</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html?is-external=true" title="class or interface in java.nio">ByteBuffer</a>&nbsp;data)</code>
<div class="block">Present the given byte buffer as a potential unique item.</div>
</td>
</tr>
<tr id="i32" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-char:A-">update</a></span>(char[]&nbsp;data)</code>
<div class="block">Present the given char array as a potential unique item.</div>
</td>
</tr>
<tr id="i33" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-double-">update</a></span>(double&nbsp;datum)</code>
<div class="block">Present the given double (or float) datum as a potential unique item.</div>
</td>
</tr>
<tr id="i34" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-int:A-">update</a></span>(int[]&nbsp;data)</code>
<div class="block">Present the given integer array as a potential unique item.</div>
</td>
</tr>
<tr id="i35" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-long-">update</a></span>(long&nbsp;datum)</code>
<div class="block">Present the given long as a potential unique item.</div>
</td>
</tr>
<tr id="i36" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-long:A-">update</a></span>(long[]&nbsp;data)</code>
<div class="block">Present the given long array as a potential unique item.</div>
</td>
</tr>
<tr id="i37" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#update-java.lang.String-">update</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;datum)</code>
<div class="block">Present the given String as a potential unique item.</div>
</td>
</tr>
<tr id="i38" class="altColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#wrap-org.apache.datasketches.memory.Memory-">wrap</a></span>(org.apache.datasketches.memory.Memory&nbsp;srcMem)</code>
<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="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/datasketches/hll/HllSketch.html#writableWrap-org.apache.datasketches.memory.WritableMemory-">writableWrap</a></span>(org.apache.datasketches.memory.WritableMemory&nbsp;srcWmem)</code>
<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 name="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">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">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">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">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">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">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">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">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">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">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">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="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 name="DEFAULT_HLL_TYPE">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>DEFAULT_HLL_TYPE</h4>
<pre>public static final&nbsp;<a href="../../../../org/apache/datasketches/hll/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>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="HllSketch--">
<!-- -->
</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 name="HllSketch-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>HllSketch</h4>
<pre>public&nbsp;HllSketch(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 name="HllSketch-int-org.apache.datasketches.hll.TgtHllType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>HllSketch</h4>
<pre>public&nbsp;HllSketch(int&nbsp;lgConfigK,
<a href="../../../../org/apache/datasketches/hll/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 name="HllSketch-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(int&nbsp;lgConfigK,
<a href="../../../../org/apache/datasketches/hll/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="../../../../org/apache/datasketches/hll/HllSketch.html#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>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="heapify-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>heapify</h4>
<pre>public static final&nbsp;<a href="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;heapify(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 name="heapify-org.apache.datasketches.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>heapify</h4>
<pre>public static final&nbsp;<a href="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;heapify(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 name="writableWrap-org.apache.datasketches.memory.WritableMemory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>writableWrap</h4>
<pre>public static final&nbsp;<a href="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;writableWrap(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="../../../../org/apache/datasketches/hll/HllSketch.html#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 name="wrap-org.apache.datasketches.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>wrap</h4>
<pre>public static final&nbsp;<a href="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;wrap(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 name="copy--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>copy</h4>
<pre>public&nbsp;<a href="../../../../org/apache/datasketches/hll/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 name="copyAs-org.apache.datasketches.hll.TgtHllType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>copyAs</h4>
<pre>public&nbsp;<a href="../../../../org/apache/datasketches/hll/HllSketch.html" title="class in org.apache.datasketches.hll">HllSketch</a>&nbsp;copyAs(<a href="../../../../org/apache/datasketches/hll/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 name="getCompositeEstimate--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCompositeEstimate</h4>
<pre>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 name="getEstimate--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getEstimate</h4>
<pre>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 name="getLgConfigK--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLgConfigK</h4>
<pre>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 name="getCompactSerializationBytes--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCompactSerializationBytes</h4>
<pre>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 name="getLowerBound-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLowerBound</h4>
<pre>public&nbsp;double&nbsp;getLowerBound(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 name="getMaxUpdatableSerializationBytes-int-org.apache.datasketches.hll.TgtHllType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMaxUpdatableSerializationBytes</h4>
<pre>public static final&nbsp;int&nbsp;getMaxUpdatableSerializationBytes(int&nbsp;lgConfigK,
<a href="../../../../org/apache/datasketches/hll/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 name="getTgtHllType--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getTgtHllType</h4>
<pre>public&nbsp;<a href="../../../../org/apache/datasketches/hll/TgtHllType.html" title="enum in org.apache.datasketches.hll">TgtHllType</a>&nbsp;getTgtHllType()</pre>
<div class="block">Gets the <a href="../../../../org/apache/datasketches/hll/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 name="getUpdatableSerializationBytes--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUpdatableSerializationBytes</h4>
<pre>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 name="getUpperBound-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUpperBound</h4>
<pre>public&nbsp;double&nbsp;getUpperBound(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 name="isCompact--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isCompact</h4>
<pre>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 name="isEmpty--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isEmpty</h4>
<pre>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 name="isMemory--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isMemory</h4>
<pre>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 name="isOffHeap--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isOffHeap</h4>
<pre>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 name="isSameResource-org.apache.datasketches.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isSameResource</h4>
<pre>public&nbsp;boolean&nbsp;isSameResource(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 name="reset--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reset</h4>
<pre>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 name="toCompactByteArray--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toCompactByteArray</h4>
<pre>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 name="toUpdatableByteArray--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toUpdatableByteArray</h4>
<pre>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 name="toString-boolean-boolean-boolean-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>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">String</a>&nbsp;toString(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 name="toString-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>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">String</a>&nbsp;toString(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 name="toString-org.apache.datasketches.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>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">String</a>&nbsp;toString(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 name="getSerializationVersion--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSerializationVersion</h4>
<pre>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 name="getSerializationVersion-org.apache.datasketches.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSerializationVersion</h4>
<pre>public static final&nbsp;int&nbsp;getSerializationVersion(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 name="getRelErr-boolean-boolean-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getRelErr</h4>
<pre>public&nbsp;double&nbsp;getRelErr(boolean&nbsp;upperBound,
boolean&nbsp;unioned,
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>unioned</code> - set true if the sketch is the result of a 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 name="isEstimationMode--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isEstimationMode</h4>
<pre>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 name="toString--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>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">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">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">Object</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Human readable summary as a string.</dd>
</dl>
</li>
</ul>
<a name="toString-boolean-boolean-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>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">String</a>&nbsp;toString(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 name="update-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(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 name="update-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(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 name="update-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">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 name="update-java.nio.ByteBuffer-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(<a href="https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html?is-external=true" title="class or interface in java.nio">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 name="update-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(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 name="update-char:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(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 name="update-int:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(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 name="update-long:A-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(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>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.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">
<li>Prev&nbsp;Class</li>
<li><a href="../../../../org/apache/datasketches/hll/IntMemoryPairIterator.html" title="class in org.apache.datasketches.hll"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/datasketches/hll/HllSketch.html" target="_top">Frames</a></li>
<li><a href="HllSketch.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.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>
</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 name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2015&#x2013;2020 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>