blob: 053f17604914d2d85ea91535a668d4596cfe3725 [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>HashOperations (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="HashOperations (datasketches-java 3.1.0 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static 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/HashOperations.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="../../../org/apache/datasketches/GenericInequalitySearch.Inequality.html" title="enum in org.apache.datasketches"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../org/apache/datasketches/InequalitySearch.html" title="enum in org.apache.datasketches"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/apache/datasketches/HashOperations.html" target="_top">Frames</a></li>
<li><a href="HashOperations.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>Constr&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>Constr&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</div>
<h2 title="Class HashOperations" class="title">Class HashOperations</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.HashOperations</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="typeNameLabel">HashOperations</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">Helper class for the common hash table methods.</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 int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#STRIDE_MASK">STRIDE_MASK</a></span></code>
<div class="block">The stride mask for the Open Address, Double Hashing (OADH) hash table algorithm.</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="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>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#checkHashCorruption-long-">checkHashCorruption</a></span>(long&nbsp;hash)</code>&nbsp;</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#checkThetaCorruption-long-">checkThetaCorruption</a></span>(long&nbsp;thetaLong)</code>&nbsp;</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#continueCondition-long-long-">continueCondition</a></span>(long&nbsp;thetaLong,
long&nbsp;hash)</code>
<div class="block">Return true (continue) if hash is greater than or equal to thetaLong, or if hash == 0,
or if hash == Long.MAX_VALUE.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>static long[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#convertToHashTable-long:A-int-long-double-">convertToHashTable</a></span>(long[]&nbsp;hashArr,
int&nbsp;count,
long&nbsp;thetaLong,
double&nbsp;rebuildThreshold)</code>
<div class="block">Converts the given array to a hash table.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#count-long:A-long-">count</a></span>(long[]&nbsp;srcArr,
long&nbsp;thetaLong)</code>
<div class="block">Counts the cardinality of the given source array.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#countPart-long:A-int-long-">countPart</a></span>(long[]&nbsp;srcArr,
int&nbsp;lgArrLongs,
long&nbsp;thetaLong)</code>
<div class="block">Counts the cardinality of the first Log2 values of the given source array.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#hashArrayInsert-long:A-long:A-int-long-">hashArrayInsert</a></span>(long[]&nbsp;srcArr,
long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;thetaLong)</code>
<div class="block">Inserts the given long array into the given OADH hashTable of the target size,
ignores duplicates and counts the values inserted.</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/HashOperations.html#hashInsertOnly-long:A-int-long-">hashInsertOnly</a></span>(long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;hash)</code>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) insert scheme for on-heap.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#hashInsertOnlyMemory-org.apache.datasketches.memory.WritableMemory-int-long-int-">hashInsertOnlyMemory</a></span>(org.apache.datasketches.memory.WritableMemory&nbsp;wmem,
int&nbsp;lgArrLongs,
long&nbsp;hash,
int&nbsp;memOffsetBytes)</code>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) insert scheme for Memory.</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/HashOperations.html#hashSearch-long:A-int-long-">hashSearch</a></span>(long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;hash)</code>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) search scheme for on-heap.</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/HashOperations.html#hashSearchMemory-org.apache.datasketches.memory.Memory-int-long-int-">hashSearchMemory</a></span>(org.apache.datasketches.memory.Memory&nbsp;mem,
int&nbsp;lgArrLongs,
long&nbsp;hash,
int&nbsp;memOffsetBytes)</code>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) search scheme for Memory.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#hashSearchOrInsert-long:A-int-long-">hashSearchOrInsert</a></span>(long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;hash)</code>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) insert scheme for on-heap.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#hashSearchOrInsertMemory-org.apache.datasketches.memory.WritableMemory-int-long-int-">hashSearchOrInsertMemory</a></span>(org.apache.datasketches.memory.WritableMemory&nbsp;wmem,
int&nbsp;lgArrLongs,
long&nbsp;hash,
int&nbsp;memOffsetBytes)</code>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash insert scheme, but inserts
values directly into a Memory.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/datasketches/HashOperations.html#minLgHashTableSize-int-double-">minLgHashTableSize</a></span>(int&nbsp;count,
double&nbsp;rebuild_threshold)</code>
<div class="block">Returns the smallest log hash table size given the count of items and the rebuild threshold.</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#toString--" title="class or interface in java.lang">toString</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="STRIDE_MASK">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>STRIDE_MASK</h4>
<pre>public static final&nbsp;int STRIDE_MASK</pre>
<div class="block">The stride mask for the Open Address, Double Hashing (OADH) hash table algorithm.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#org.apache.datasketches.HashOperations.STRIDE_MASK">Constant Field Values</a></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="hashSearch-long:A-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashSearch</h4>
<pre>public static&nbsp;int&nbsp;hashSearch(long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;hash)</pre>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) search scheme for on-heap.
Returns the index if found, -1 if not found.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>hashTable</code> - The hash table to search. Its size must be a power of 2.</dd>
<dd><code>lgArrLongs</code> - The log_base2(hashTable.length).
<a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.</dd>
<dd><code>hash</code> - The hash value to search for. It must not be zero.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Current probe index if found, -1 if not found.</dd>
</dl>
</li>
</ul>
<a name="hashInsertOnly-long:A-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashInsertOnly</h4>
<pre>public static&nbsp;int&nbsp;hashInsertOnly(long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;hash)</pre>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) insert scheme for on-heap.
This method assumes that the input hash is not a duplicate.
Useful for rebuilding tables to avoid unnecessary comparisons.
Returns the index of insertion, which is always positive or zero.
Throws an exception if the table has no empty slot.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>hashTable</code> - the hash table to insert into. Its size must be a power of 2.</dd>
<dd><code>lgArrLongs</code> - The log_base2(hashTable.length).
<a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.</dd>
<dd><code>hash</code> - The hash value to be potentially inserted into an empty slot. It must not be zero.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>index of insertion. Always positive or zero.</dd>
</dl>
</li>
</ul>
<a name="hashSearchOrInsert-long:A-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashSearchOrInsert</h4>
<pre>public static&nbsp;int&nbsp;hashSearchOrInsert(long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;hash)</pre>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) insert scheme for on-heap.
Returns index &ge; 0 if found (duplicate); &lt; 0 if inserted, inserted at -(index + 1).
Throws an exception if the value is not found and table has no empty slot.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>hashTable</code> - The hash table to insert into. Its size must be a power of 2.</dd>
<dd><code>lgArrLongs</code> - The log_base2(hashTable.length).
<a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.</dd>
<dd><code>hash</code> - The hash value to be potentially inserted into an empty slot only if it is not
a duplicate of any other hash value in the table. It must not be zero.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>index &ge; 0 if found (duplicate); &lt; 0 if inserted, inserted at -(index + 1).</dd>
</dl>
</li>
</ul>
<a name="hashArrayInsert-long:A-long:A-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashArrayInsert</h4>
<pre>public static&nbsp;int&nbsp;hashArrayInsert(long[]&nbsp;srcArr,
long[]&nbsp;hashTable,
int&nbsp;lgArrLongs,
long&nbsp;thetaLong)</pre>
<div class="block">Inserts the given long array into the given OADH hashTable of the target size,
ignores duplicates and counts the values inserted.
The hash values must not be negative, zero values and values &ge; thetaLong are ignored.
The given hash table may have values, but they must have been inserted by this method or one
of the other OADH insert methods in this class.
This method performs additional checks against potentially invalid hash values or theta values.
Returns the count of values actually inserted.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcArr</code> - the source hash array to be potentially inserted</dd>
<dd><code>hashTable</code> - The hash table to insert into. Its size must be a power of 2.</dd>
<dd><code>lgArrLongs</code> - The log_base2(hashTable.length).
<a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.</dd>
<dd><code>thetaLong</code> - The theta value that all input hash values are compared against.
It must greater than zero.
<a href="../../../resources/dictionary.html#thetaLong">See Theta Long</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the count of values actually inserted</dd>
</dl>
</li>
</ul>
<a name="hashSearchMemory-org.apache.datasketches.memory.Memory-int-long-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashSearchMemory</h4>
<pre>public static&nbsp;int&nbsp;hashSearchMemory(org.apache.datasketches.memory.Memory&nbsp;mem,
int&nbsp;lgArrLongs,
long&nbsp;hash,
int&nbsp;memOffsetBytes)</pre>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) search scheme for Memory.
Returns the index if found, -1 if not found.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mem</code> - The <i>Memory</i> containing the hash table to search.
The hash table portion must be a power of 2 in size.</dd>
<dd><code>lgArrLongs</code> - The log_base2(hashTable.length).
<a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.</dd>
<dd><code>hash</code> - The hash value to search for. Must not be zero.</dd>
<dd><code>memOffsetBytes</code> - offset in the memory where the hashTable starts</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Current probe index if found, -1 if not found.</dd>
</dl>
</li>
</ul>
<a name="hashInsertOnlyMemory-org.apache.datasketches.memory.WritableMemory-int-long-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashInsertOnlyMemory</h4>
<pre>public static&nbsp;int&nbsp;hashInsertOnlyMemory(org.apache.datasketches.memory.WritableMemory&nbsp;wmem,
int&nbsp;lgArrLongs,
long&nbsp;hash,
int&nbsp;memOffsetBytes)</pre>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) insert scheme for Memory.
This method assumes that the input hash is not a duplicate.
Useful for rebuilding tables to avoid unnecessary comparisons.
Returns the index of insertion, which is always positive or zero.
Throws an exception if table has no empty slot.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>wmem</code> - The <i>WritableMemory</i> that contains the hashTable to insert into.
The size of the hashTable portion must be a power of 2.</dd>
<dd><code>lgArrLongs</code> - The log_base2(hashTable.length.
<a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.</dd>
<dd><code>hash</code> - value that must not be zero and will be inserted into the array into an empty slot.</dd>
<dd><code>memOffsetBytes</code> - offset in the <i>WritableMemory</i> where the hashTable starts</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>index of insertion. Always positive or zero.</dd>
</dl>
</li>
</ul>
<a name="hashSearchOrInsertMemory-org.apache.datasketches.memory.WritableMemory-int-long-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashSearchOrInsertMemory</h4>
<pre>public static&nbsp;int&nbsp;hashSearchOrInsertMemory(org.apache.datasketches.memory.WritableMemory&nbsp;wmem,
int&nbsp;lgArrLongs,
long&nbsp;hash,
int&nbsp;memOffsetBytes)</pre>
<div class="block">This is a classical Knuth-style Open Addressing, Double Hash insert scheme, but inserts
values directly into a Memory.
Returns index &ge; 0 if found (duplicate); &lt; 0 if inserted, inserted at -(index + 1).
Throws an exception if the value is not found and table has no empty slot.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>wmem</code> - The <i>WritableMemory</i> that contains the hashTable to insert into.</dd>
<dd><code>lgArrLongs</code> - The log_base2(hashTable.length).
<a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.</dd>
<dd><code>hash</code> - The hash value to be potentially inserted into an empty slot only if it is not
a duplicate of any other hash value in the table. It must not be zero.</dd>
<dd><code>memOffsetBytes</code> - offset in the <i>WritableMemory</i> where the hash array starts</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>index &ge; 0 if found (duplicate); &lt; 0 if inserted, inserted at -(index + 1).</dd>
</dl>
</li>
</ul>
<a name="checkThetaCorruption-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>checkThetaCorruption</h4>
<pre>public static&nbsp;void&nbsp;checkThetaCorruption(long&nbsp;thetaLong)</pre>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>thetaLong</code> - must be greater than zero otherwise throws an exception.
<a href="../../../resources/dictionary.html#thetaLong">See Theta Long</a></dd>
</dl>
</li>
</ul>
<a name="checkHashCorruption-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>checkHashCorruption</h4>
<pre>public static&nbsp;void&nbsp;checkHashCorruption(long&nbsp;hash)</pre>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>hash</code> - must be greater than -1 otherwise throws an exception.
Note a hash of zero is normally ignored, but a negative hash is never allowed.</dd>
</dl>
</li>
</ul>
<a name="continueCondition-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>continueCondition</h4>
<pre>public static&nbsp;boolean&nbsp;continueCondition(long&nbsp;thetaLong,
long&nbsp;hash)</pre>
<div class="block">Return true (continue) if hash is greater than or equal to thetaLong, or if hash == 0,
or if hash == Long.MAX_VALUE.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>thetaLong</code> - must be greater than the hash value
<a href="../../../resources/dictionary.html#thetaLong">See Theta Long</a></dd>
<dd><code>hash</code> - must be less than thetaLong and not less than or equal to zero.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true (continue) if hash is greater than or equal to thetaLong, or if hash == 0,
or if hash == Long.MAX_VALUE.</dd>
</dl>
</li>
</ul>
<a name="convertToHashTable-long:A-int-long-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>convertToHashTable</h4>
<pre>public static&nbsp;long[]&nbsp;convertToHashTable(long[]&nbsp;hashArr,
int&nbsp;count,
long&nbsp;thetaLong,
double&nbsp;rebuildThreshold)</pre>
<div class="block">Converts the given array to a hash table.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>hashArr</code> - The given array of hashes. Gaps are OK.</dd>
<dd><code>count</code> - The number of valid hashes in the array</dd>
<dd><code>thetaLong</code> - Any hashes equal to or greater than thetaLong will be ignored</dd>
<dd><code>rebuildThreshold</code> - The fill fraction for the hash table forcing a rebuild or resize.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a HashTable</dd>
</dl>
</li>
</ul>
<a name="minLgHashTableSize-int-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>minLgHashTableSize</h4>
<pre>public static&nbsp;int&nbsp;minLgHashTableSize(int&nbsp;count,
double&nbsp;rebuild_threshold)</pre>
<div class="block">Returns the smallest log hash table size given the count of items and the rebuild threshold.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>count</code> - the given count of items</dd>
<dd><code>rebuild_threshold</code> - the rebuild threshold as a fraction between zero and one.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the smallest log hash table size</dd>
</dl>
</li>
</ul>
<a name="countPart-long:A-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>countPart</h4>
<pre>public static&nbsp;int&nbsp;countPart(long[]&nbsp;srcArr,
int&nbsp;lgArrLongs,
long&nbsp;thetaLong)</pre>
<div class="block">Counts the cardinality of the first Log2 values of the given source array.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcArr</code> - the given source array</dd>
<dd><code>lgArrLongs</code> - <a href="../../../resources/dictionary.html#lgArrLongs">See lgArrLongs</a></dd>
<dd><code>thetaLong</code> - <a href="../../../resources/dictionary.html#thetaLong">See Theta Long</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the cardinality</dd>
</dl>
</li>
</ul>
<a name="count-long:A-long-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>count</h4>
<pre>public static&nbsp;int&nbsp;count(long[]&nbsp;srcArr,
long&nbsp;thetaLong)</pre>
<div class="block">Counts the cardinality of the given source array.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>srcArr</code> - the given source array</dd>
<dd><code>thetaLong</code> - <a href="../../../resources/dictionary.html#thetaLong">See Theta Long</a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the cardinality</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/HashOperations.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="../../../org/apache/datasketches/GenericInequalitySearch.Inequality.html" title="enum in org.apache.datasketches"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../org/apache/datasketches/InequalitySearch.html" title="enum in org.apache.datasketches"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/apache/datasketches/HashOperations.html" target="_top">Frames</a></li>
<li><a href="HashOperations.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>Constr&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>Constr&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>