blob: cebc822f1a1b56a25bc6d988347675c1418c532e [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_162) on Thu Oct 25 17:06:10 PDT 2018 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LongsSketch (com.yahoo.datasketches:sketches-core 0.12.1-SNAPSHOT API)</title>
<meta name="date" content="2018-10-25">
<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="LongsSketch (com.yahoo.datasketches:sketches-core 0.12.1-SNAPSHOT API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":9,"i5":9,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10};
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/LongsSketch.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><a href="../../../../com/yahoo/sketches/frequencies/ItemsSketch.Row.html" title="class in com.yahoo.sketches.frequencies"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.Row.html" title="class in com.yahoo.sketches.frequencies"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/yahoo/sketches/frequencies/LongsSketch.html" target="_top">Frames</a></li>
<li><a href="LongsSketch.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><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&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>Field&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">com.yahoo.sketches.frequencies</div>
<h2 title="Class LongsSketch" class="title">Class LongsSketch</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>com.yahoo.sketches.frequencies.LongsSketch</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="typeNameLabel">LongsSketch</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"><p>This sketch is useful for tracking approximate frequencies of <i>long</i> items with optional
associated counts (<i>long</i> item, <i>long</i> count) that are members of a multiset of
such items. The true frequency of an item is defined to be the sum of associated counts.</p>
<p>This implementation provides the following capabilities:</p>
<ul>
<li>Estimate the frequency of an item.</li>
<li>Return upper and lower bounds of any item, such that the true frequency is always
between the upper and lower bounds.</li>
<li>Return a global maximum error that holds for all items in the stream.</li>
<li>Return an array of frequent items that qualify either a NO_FALSE_POSITIVES or a
NO_FALSE_NEGATIVES error type.</li>
<li>Merge itself with another sketch object created from this class.</li>
<li>Serialize/Deserialize to/from a String or byte array.</li>
</ul>
<p><b>Space Usage</b></p>
<p>The sketch is initialized with a <i>maxMapSize</i> that specifies the maximum physical
length of the internal hash map of the form (<i>long</i> item, <i>long</i> count).
The <i>maxMapSize</i> must be a power of 2.</p>
<p>The hash map starts at a very small size (8 entries), and grows as needed up to the
specified <i>maxMapSize</i>.</p>
<p>The internal memory space usage of this sketch is 18 * <i>mapSize</i> bytes, plus a small
constant number of additional bytes. The internal memory space usage of this sketch will never
exceed 18 * <i>maxMapSize</i> bytes, plus a small constant number of additional bytes.</p>
<p><b>Maximum Capacity of the Sketch</b></p>
<p>The LOAD_FACTOR for the hash map is internally set at 75%,
which means at any time the map capacity of (item, count) pairs is <i>mapCap</i> =
0.75 * <i>mapSize</i>.
The maximum capacity of (item, count) pairs of the sketch is <i>maxMapCap</i> =
0.75 * <i>maxMapSize</i>.</p>
<p><b>Updating the sketch with (item, count) pairs</b></p>
<p>If the item is found in the hash map, the mapped count field (the "counter") is
incremented by the incoming count, otherwise, a new counter "(item, count) pair" is
created. If the number of tracked counters reaches the maximum capacity of the hash map
the sketch decrements all of the counters (by an approximately computed median), and
removes any non-positive counters.</p>
<p><b>Accuracy</b></p>
<p>If fewer than 0.75 * <i>maxMapSize</i> different items are inserted into the sketch the
estimated frequencies returned by the sketch will be exact.</p>
<p>The logic of the frequent items sketch is such that the stored counts and true counts are
never too different.
More specifically, for any <i>item</i>, the sketch can return an estimate of the
true frequency of <i>item</i>, along with upper and lower bounds on the frequency
(that hold deterministically).</p>
<p>For this implementation and for a specific active <i>item</i>, it is guaranteed that
the true frequency will be between the Upper Bound (UB) and the Lower Bound (LB) computed for
that <i>item</i>. Specifically, <i>(UB- LB) &le; W * epsilon</i>, where <i>W</i> denotes the
sum of all item counts, and <i>epsilon = 3.5/M</i>, where <i>M</i> is the <i>maxMapSize</i>.</p>
<p>This is a worst case guarantee that applies to arbitrary inputs.<sup>1</sup>
For inputs typically seen in practice <i>(UB-LB)</i> is usually much smaller.
</p>
<p><b>Background</b></p>
<p>This code implements a variant of what is commonly known as the "Misra-Gries
algorithm". Variants of it were discovered and rediscovered and redesigned several times
over the years:</p>
<ul><li>"Finding repeated elements", Misra, Gries, 1982</li>
<li>"Frequency estimation of Internet packet streams with limited space" Demaine,
Lopez-Ortiz, Munro, 2002</li>
<li>"A simple algorithm for finding frequent elements in streams and bags" Karp, Shenker,
Papadimitriou, 2003</li>
<li>"Efficient Computation of Frequent and Top-k Elements in Data Streams" Metwally,
Agrawal, Abbadi, 2006</li>
</ul>
<sup>1</sup> For speed we do employ some randomization that introduces a small probability that
our proof of the worst-case bound might not apply to a given run. However, we have ensured
that this probability is extremely small. For example, if the stream causes one table purge
(rebuild), our proof of the worst case bound applies with probability at least 1 - 1E-14.
If the stream causes 1E9 purges, our proof applies with probability at least 1 - 1E-5.</div>
<dl>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>Justin Thaler, Lee Rhodes</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.Row.html" title="class in com.yahoo.sketches.frequencies">LongsSketch.Row</a></span></code>
<div class="block">Row class that defines the return values from a getFrequentItems query.</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="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#LongsSketch-int-">LongsSketch</a></span>(int&nbsp;maxMapSize)</code>
<div class="block">Construct this sketch with the parameter maxMapSize and the default initialMapSize (8).</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>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getCurrentMapCapacity--">getCurrentMapCapacity</a></span>()</code>
<div class="block">Returns the current number of counters the sketch is configured to support.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getEstimate-long-">getEstimate</a></span>(long&nbsp;item)</code>
<div class="block">Gets the estimate of the frequency of the given item.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.Row.html" title="class in com.yahoo.sketches.frequencies">LongsSketch.Row</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getFrequentItems-com.yahoo.sketches.frequencies.ErrorType-">getFrequentItems</a></span>(<a href="../../../../com/yahoo/sketches/frequencies/ErrorType.html" title="enum in com.yahoo.sketches.frequencies">ErrorType</a>&nbsp;errorType)</code>
<div class="block">Returns an array of Rows that include frequent items, estimates, upper and lower bounds
given an ErrorCondition and the default threshold.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.Row.html" title="class in com.yahoo.sketches.frequencies">LongsSketch.Row</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getFrequentItems-long-com.yahoo.sketches.frequencies.ErrorType-">getFrequentItems</a></span>(long&nbsp;threshold,
<a href="../../../../com/yahoo/sketches/frequencies/ErrorType.html" title="enum in com.yahoo.sketches.frequencies">ErrorType</a>&nbsp;errorType)</code>
<div class="block">Returns an array of Rows that include frequent items, estimates, upper and lower bounds
given a threshold and an ErrorCondition.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static <a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getInstance-com.yahoo.memory.Memory-">getInstance</a></span>(com.yahoo.memory.Memory&nbsp;srcMem)</code>
<div class="block">Returns a sketch instance of this class from the given srcMem,
which must be a Memory representation of this sketch class.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>static <a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getInstance-java.lang.String-">getInstance</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;string)</code>
<div class="block">Returns a sketch instance of this class from the given String,
which must be a String representation of this sketch class.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getLowerBound-long-">getLowerBound</a></span>(long&nbsp;item)</code>
<div class="block">Gets the guaranteed lower bound frequency of the given item, which can never be
negative.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getMaximumError--">getMaximumError</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getMaximumMapCapacity--">getMaximumMapCapacity</a></span>()</code>
<div class="block">Returns the maximum number of counters the sketch is configured to support.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getNumActiveItems--">getNumActiveItems</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getStorageBytes--">getStorageBytes</a></span>()</code>
<div class="block">Returns the number of bytes required to store this sketch as an array of bytes.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getStreamLength--">getStreamLength</a></span>()</code>
<div class="block">Returns the sum of the frequencies (weights or counts) in the stream seen so far by the sketch</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#getUpperBound-long-">getUpperBound</a></span>(long&nbsp;item)</code>
<div class="block">Gets the guaranteed upper bound frequency of the given item.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#isEmpty--">isEmpty</a></span>()</code>
<div class="block">Returns true if this sketch is empty</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#merge-com.yahoo.sketches.frequencies.LongsSketch-">merge</a></span>(<a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a>&nbsp;other)</code>
<div class="block">This function merges the other sketch into this one.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#reset--">reset</a></span>()</code>
<div class="block">Resets this sketch to a virgin state.</div>
</td>
</tr>
<tr id="i16" 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="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#serializeToString--">serializeToString</a></span>()</code>
<div class="block">Returns a String representation of this sketch</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>byte[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#toByteArray--">toByteArray</a></span>()</code>
<div class="block">Returns a byte array representation of this sketch</div>
</td>
</tr>
<tr id="i18" 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="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#toString--">toString</a></span>()</code>
<div class="block">Returns a human readable summary of this sketch.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#update-long-">update</a></span>(long&nbsp;item)</code>
<div class="block">Update this sketch with an item and a frequency count of one.</div>
</td>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html#update-long-long-">update</a></span>(long&nbsp;item,
long&nbsp;count)</code>
<div class="block">Update this sketch with a item and a positive frequency count (or weight).</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">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="LongsSketch-int-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>LongsSketch</h4>
<pre>public&nbsp;LongsSketch(int&nbsp;maxMapSize)</pre>
<div class="block">Construct this sketch with the parameter maxMapSize and the default initialMapSize (8).</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>maxMapSize</code> - Determines the physical size of the internal hash map managed by this
sketch and must be a power of 2. The maximum capacity of this internal hash map is
0.75 times * maxMapSize. Both the ultimate accuracy and size of this sketch are a
function of maxMapSize.</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="getInstance-com.yahoo.memory.Memory-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInstance</h4>
<pre>public static&nbsp;<a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a>&nbsp;getInstance(com.yahoo.memory.Memory&nbsp;srcMem)</pre>
<div class="block">Returns a sketch instance of this class from the given srcMem,
which must be a Memory representation of this sketch class.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcMem</code> - a Memory representation of a sketch of this class.
<a href="../../../../resources/dictionary.html#mem">See Memory</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a sketch instance of this class.</dd>
</dl>
</li>
</ul>
<a name="getInstance-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInstance</h4>
<pre>public static&nbsp;<a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a>&nbsp;getInstance(<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;string)</pre>
<div class="block">Returns a sketch instance of this class from the given String,
which must be a String representation of this sketch class.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>string</code> - a String representation of a sketch of this class.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a sketch instance of this class.</dd>
</dl>
</li>
</ul>
<a name="serializeToString--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>serializeToString</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;serializeToString()</pre>
<div class="block">Returns a String representation of this sketch</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a String representation of this sketch</dd>
</dl>
</li>
</ul>
<a name="toByteArray--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toByteArray</h4>
<pre>public&nbsp;byte[]&nbsp;toByteArray()</pre>
<div class="block">Returns a byte array representation of this sketch</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a byte array representation of this sketch</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;item)</pre>
<div class="block">Update this sketch with an item and a frequency count of one.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>item</code> - for which the frequency should be increased.</dd>
</dl>
</li>
</ul>
<a name="update-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>public&nbsp;void&nbsp;update(long&nbsp;item,
long&nbsp;count)</pre>
<div class="block">Update this sketch with a item and a positive frequency count (or weight).</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>item</code> - for which the frequency should be increased. The item can be any long value
and is only used by the sketch to determine uniqueness.</dd>
<dd><code>count</code> - the amount by which the frequency of the item should be increased.
An count of zero is a no-op, and a negative count will throw an exception.</dd>
</dl>
</li>
</ul>
<a name="merge-com.yahoo.sketches.frequencies.LongsSketch-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>merge</h4>
<pre>public&nbsp;<a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a>&nbsp;merge(<a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.html" title="class in com.yahoo.sketches.frequencies">LongsSketch</a>&nbsp;other)</pre>
<div class="block">This function merges the other sketch into this one.
The other sketch may be of a different size.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>other</code> - sketch of this class</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a sketch whose estimates are within the guarantees of the
largest error tolerance of the two merged sketches.</dd>
</dl>
</li>
</ul>
<a name="getEstimate-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getEstimate</h4>
<pre>public&nbsp;long&nbsp;getEstimate(long&nbsp;item)</pre>
<div class="block">Gets the estimate of the frequency of the given item.
Note: The true frequency of a item would be the sum of the counts as a result of the
two update functions.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>item</code> - the given item</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the estimate of the frequency of the given item</dd>
</dl>
</li>
</ul>
<a name="getUpperBound-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getUpperBound</h4>
<pre>public&nbsp;long&nbsp;getUpperBound(long&nbsp;item)</pre>
<div class="block">Gets the guaranteed upper bound frequency of the given item.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>item</code> - the given item</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the guaranteed upper bound frequency of the given item. That is, a number which
is guaranteed to be no smaller than the real frequency.</dd>
</dl>
</li>
</ul>
<a name="getLowerBound-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLowerBound</h4>
<pre>public&nbsp;long&nbsp;getLowerBound(long&nbsp;item)</pre>
<div class="block">Gets the guaranteed lower bound frequency of the given item, which can never be
negative.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>item</code> - the given item.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the guaranteed lower bound frequency of the given item. That is, a number which
is guaranteed to be no larger than the real frequency.</dd>
</dl>
</li>
</ul>
<a name="getFrequentItems-long-com.yahoo.sketches.frequencies.ErrorType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getFrequentItems</h4>
<pre>public&nbsp;<a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.Row.html" title="class in com.yahoo.sketches.frequencies">LongsSketch.Row</a>[]&nbsp;getFrequentItems(long&nbsp;threshold,
<a href="../../../../com/yahoo/sketches/frequencies/ErrorType.html" title="enum in com.yahoo.sketches.frequencies">ErrorType</a>&nbsp;errorType)</pre>
<div class="block">Returns an array of Rows that include frequent items, estimates, upper and lower bounds
given a threshold and an ErrorCondition. If the threshold is lower than getMaximumError(),
then getMaximumError() will be used instead.
<p>The method first examines all active items in the sketch (items that have a counter).
<p>If <i>ErrorType = NO_FALSE_NEGATIVES</i>, this will include an item in the result
list if getUpperBound(item) &gt; threshold.
There will be no false negatives, i.e., no Type II error.
There may be items in the set with true frequencies less than the threshold
(false positives).</p>
<p>If <i>ErrorType = NO_FALSE_POSITIVES</i>, this will include an item in the result
list if getLowerBound(item) &gt; threshold.
There will be no false positives, i.e., no Type I error.
There may be items omitted from the set with true frequencies greater than the
threshold (false negatives). This is a subset of the NO_FALSE_NEGATIVES case.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>threshold</code> - to include items in the result list</dd>
<dd><code>errorType</code> - determines whether no false positives or no false negatives are
desired.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an array of frequent items</dd>
</dl>
</li>
</ul>
<a name="getFrequentItems-com.yahoo.sketches.frequencies.ErrorType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getFrequentItems</h4>
<pre>public&nbsp;<a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.Row.html" title="class in com.yahoo.sketches.frequencies">LongsSketch.Row</a>[]&nbsp;getFrequentItems(<a href="../../../../com/yahoo/sketches/frequencies/ErrorType.html" title="enum in com.yahoo.sketches.frequencies">ErrorType</a>&nbsp;errorType)</pre>
<div class="block">Returns an array of Rows that include frequent items, estimates, upper and lower bounds
given an ErrorCondition and the default threshold.
This is the same as getFrequentItems(getMaximumError(), errorType)</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>errorType</code> - determines whether no false positives or no false negatives are
desired.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an array of frequent items</dd>
</dl>
</li>
</ul>
<a name="getCurrentMapCapacity--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCurrentMapCapacity</h4>
<pre>public&nbsp;int&nbsp;getCurrentMapCapacity()</pre>
<div class="block">Returns the current number of counters the sketch is configured to support.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the current number of counters the sketch is configured to support.</dd>
</dl>
</li>
</ul>
<a name="getMaximumError--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMaximumError</h4>
<pre>public&nbsp;long&nbsp;getMaximumError()</pre>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>An upper bound on the maximum error of getEstimate(item) for any item.
This is equivalent to the maximum distance between the upper bound and the lower bound
for any item.</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 this sketch is empty</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if this sketch is empty</dd>
</dl>
</li>
</ul>
<a name="getStreamLength--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getStreamLength</h4>
<pre>public&nbsp;long&nbsp;getStreamLength()</pre>
<div class="block">Returns the sum of the frequencies (weights or counts) in the stream seen so far by the sketch</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the sum of the frequencies in the stream seen so far by the sketch</dd>
</dl>
</li>
</ul>
<a name="getMaximumMapCapacity--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMaximumMapCapacity</h4>
<pre>public&nbsp;int&nbsp;getMaximumMapCapacity()</pre>
<div class="block">Returns the maximum number of counters the sketch is configured to support.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the maximum number of counters the sketch is configured to support.</dd>
</dl>
</li>
</ul>
<a name="getNumActiveItems--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNumActiveItems</h4>
<pre>public&nbsp;int&nbsp;getNumActiveItems()</pre>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of active items in the sketch.</dd>
</dl>
</li>
</ul>
<a name="getStorageBytes--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getStorageBytes</h4>
<pre>public&nbsp;int&nbsp;getStorageBytes()</pre>
<div class="block">Returns the number of bytes required to store this sketch as an array of bytes.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of bytes required to store this sketch as an array of bytes.</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 this sketch to a virgin state.</div>
</li>
</ul>
<a name="toString--">
<!-- -->
</a>
<ul class="blockListLast">
<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">Returns a human readable summary of this sketch.</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>a human readable summary of this sketch.</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/LongsSketch.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><a href="../../../../com/yahoo/sketches/frequencies/ItemsSketch.Row.html" title="class in com.yahoo.sketches.frequencies"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../com/yahoo/sketches/frequencies/LongsSketch.Row.html" title="class in com.yahoo.sketches.frequencies"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/yahoo/sketches/frequencies/LongsSketch.html" target="_top">Frames</a></li>
<li><a href="LongsSketch.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><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&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>Field&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;2018. All rights reserved.</small></p>
</body>
</html>