| <!DOCTYPE HTML> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc --> |
| <title>HashOperations (datasketches-java 4.0.0 API)</title> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.min.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../jquery-ui.overrides.css" title="Style"> |
| <script type="text/javascript" src="../../../../script.js"></script> |
| <script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script> |
| <script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script> |
| <!--[if IE]> |
| <script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script> |
| <![endif]--> |
| <script type="text/javascript" src="../../../../jquery/jquery-3.6.0.min.js"></script> |
| <script type="text/javascript" src="../../../../jquery/jquery-ui.min.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="HashOperations (datasketches-java 4.0.0 API)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var data = {"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"; |
| var pathtoroot = "../../../../"; |
| var useModuleDirectories = true; |
| loadScripts(document, 'script');</script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <header role="banner"> |
| <nav role="navigation"> |
| <div class="fixedNav"> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a id="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a id="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../index.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/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" id="allclasses_navbar_top"> |
| <li><a href="../../../../allclasses.html">All Classes</a></li> |
| </ul> |
| <ul class="navListSearch"> |
| <li><label for="search">SEARCH:</label> |
| <input type="text" id="search" value="search" disabled="disabled"> |
| <input type="reset" id="reset" value="reset" disabled="disabled"> |
| </li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li><a href="#field.summary">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field.detail">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a id="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| </div> |
| <div class="navPadding"> </div> |
| <script type="text/javascript"><!-- |
| $('.navPadding').css('padding-top', $('.fixedNav').css("height")); |
| //--> |
| </script> |
| </nav> |
| </header> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <main role="main"> |
| <div class="header"> |
| <div class="subTitle"><span class="packageLabelInType">Package</span> <a href="package-summary.html">org.apache.datasketches.thetacommon</a></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" class="externalLink">java.lang.Object</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.datasketches.thetacommon.HashOperations</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <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" class="externalLink">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 =========== --> |
| <section> |
| <ul class="blockList"> |
| <li class="blockList"><a id="field.summary"> |
| <!-- --> |
| </a> |
| <h3>Field Summary</h3> |
| <table class="memberSummary"> |
| <caption><span>Fields</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colSecond" scope="col">Field</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>static int</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#STRIDE_MASK">STRIDE_MASK</a></span></code></th> |
| <td class="colLast"> |
| <div class="block">The stride mask for the Open Address, Double Hashing (OADH) hash table algorithm.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| </section> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <section> |
| <ul class="blockList"> |
| <li class="blockList"><a id="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="memberSummary"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colSecond" scope="col">Method</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#checkHashCorruption(long)">checkHashCorruption</a></span>​(long hash)</code></th> |
| <td class="colLast"> </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#checkThetaCorruption(long)">checkThetaCorruption</a></span>​(long thetaLong)</code></th> |
| <td class="colLast"> </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>static boolean</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#continueCondition(long,long)">continueCondition</a></span>​(long thetaLong, |
| long hash)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#convertToHashTable(long%5B%5D,int,long,double)">convertToHashTable</a></span>​(long[] hashArr, |
| int count, |
| long thetaLong, |
| double rebuildThreshold)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#count(long%5B%5D,long)">count</a></span>​(long[] srcArr, |
| long thetaLong)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#countPart(long%5B%5D,int,long)">countPart</a></span>​(long[] srcArr, |
| int lgArrLongs, |
| long thetaLong)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashArrayInsert(long%5B%5D,long%5B%5D,int,long)">hashArrayInsert</a></span>​(long[] srcArr, |
| long[] hashTable, |
| int lgArrLongs, |
| long thetaLong)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashInsertOnly(long%5B%5D,int,long)">hashInsertOnly</a></span>​(long[] hashTable, |
| int lgArrLongs, |
| long hash)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashInsertOnlyMemory(org.apache.datasketches.memory.WritableMemory,int,long,int)">hashInsertOnlyMemory</a></span>​(org.apache.datasketches.memory.WritableMemory wmem, |
| int lgArrLongs, |
| long hash, |
| int memOffsetBytes)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashSearch(long%5B%5D,int,long)">hashSearch</a></span>​(long[] hashTable, |
| int lgArrLongs, |
| long hash)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashSearchMemory(org.apache.datasketches.memory.Memory,int,long,int)">hashSearchMemory</a></span>​(org.apache.datasketches.memory.Memory mem, |
| int lgArrLongs, |
| long hash, |
| int memOffsetBytes)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashSearchOrInsert(long%5B%5D,int,long)">hashSearchOrInsert</a></span>​(long[] hashTable, |
| int lgArrLongs, |
| long hash)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashSearchOrInsertMemory(org.apache.datasketches.memory.WritableMemory,int,long,int)">hashSearchOrInsertMemory</a></span>​(org.apache.datasketches.memory.WritableMemory wmem, |
| int lgArrLongs, |
| long hash, |
| int memOffsetBytes)</code></th> |
| <td class="colLast"> |
| <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> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#minLgHashTableSize(int,double)">minLgHashTableSize</a></span>​(int count, |
| double rebuild_threshold)</code></th> |
| <td class="colLast"> |
| <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 id="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a></h3> |
| <code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang" class="externalLink">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang" class="externalLink">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang" class="externalLink">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang" class="externalLink">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang" class="externalLink">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang" class="externalLink">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang" class="externalLink">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang" class="externalLink">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" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait(long,int)" title="class or interface in java.lang" class="externalLink">wait</a></code></li> |
| </ul> |
| </li> |
| </ul> |
| </section> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ FIELD DETAIL =========== --> |
| <section> |
| <ul class="blockList"> |
| <li class="blockList"><a id="field.detail"> |
| <!-- --> |
| </a> |
| <h3>Field Detail</h3> |
| <a id="STRIDE_MASK"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>STRIDE_MASK</h4> |
| <pre>public static final 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.thetacommon.HashOperations.STRIDE_MASK">Constant Field Values</a></dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </section> |
| <!-- ============ METHOD DETAIL ========== --> |
| <section> |
| <ul class="blockList"> |
| <li class="blockList"><a id="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a id="hashSearch(long[],int,long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashSearch</h4> |
| <pre class="methodSignature">public static int hashSearch​(long[] hashTable, |
| int lgArrLongs, |
| long 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 id="hashInsertOnly(long[],int,long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashInsertOnly</h4> |
| <pre class="methodSignature">public static int hashInsertOnly​(long[] hashTable, |
| int lgArrLongs, |
| long 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 id="hashSearchOrInsert(long[],int,long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashSearchOrInsert</h4> |
| <pre class="methodSignature">public static int hashSearchOrInsert​(long[] hashTable, |
| int lgArrLongs, |
| long hash)</pre> |
| <div class="block">This is a classical Knuth-style Open Addressing, Double Hash (OADH) insert scheme for on-heap. |
| Returns index ≥ 0 if found (duplicate); < 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 ≥ 0 if found (duplicate); < 0 if inserted, inserted at -(index + 1).</dd> |
| </dl> |
| </li> |
| </ul> |
| <a id="hashArrayInsert(long[],long[],int,long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashArrayInsert</h4> |
| <pre class="methodSignature">public static int hashArrayInsert​(long[] srcArr, |
| long[] hashTable, |
| int lgArrLongs, |
| long 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 ≥ 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 id="hashSearchMemory(org.apache.datasketches.memory.Memory,int,long,int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashSearchMemory</h4> |
| <pre class="methodSignature">public static int hashSearchMemory​(org.apache.datasketches.memory.Memory mem, |
| int lgArrLongs, |
| long hash, |
| int 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 id="hashInsertOnlyMemory(org.apache.datasketches.memory.WritableMemory,int,long,int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashInsertOnlyMemory</h4> |
| <pre class="methodSignature">public static int hashInsertOnlyMemory​(org.apache.datasketches.memory.WritableMemory wmem, |
| int lgArrLongs, |
| long hash, |
| int 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 id="hashSearchOrInsertMemory(org.apache.datasketches.memory.WritableMemory,int,long,int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashSearchOrInsertMemory</h4> |
| <pre class="methodSignature">public static int hashSearchOrInsertMemory​(org.apache.datasketches.memory.WritableMemory wmem, |
| int lgArrLongs, |
| long hash, |
| int 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 ≥ 0 if found (duplicate); < 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 ≥ 0 if found (duplicate); < 0 if inserted, inserted at -(index + 1).</dd> |
| </dl> |
| </li> |
| </ul> |
| <a id="checkThetaCorruption(long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>checkThetaCorruption</h4> |
| <pre class="methodSignature">public static void checkThetaCorruption​(long 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 id="checkHashCorruption(long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>checkHashCorruption</h4> |
| <pre class="methodSignature">public static void checkHashCorruption​(long 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 id="continueCondition(long,long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>continueCondition</h4> |
| <pre class="methodSignature">public static boolean continueCondition​(long thetaLong, |
| long 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 id="convertToHashTable(long[],int,long,double)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>convertToHashTable</h4> |
| <pre class="methodSignature">public static long[] convertToHashTable​(long[] hashArr, |
| int count, |
| long thetaLong, |
| double 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 id="minLgHashTableSize(int,double)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>minLgHashTableSize</h4> |
| <pre class="methodSignature">public static int minLgHashTableSize​(int count, |
| double 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 id="countPart(long[],int,long)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>countPart</h4> |
| <pre class="methodSignature">public static int countPart​(long[] srcArr, |
| int lgArrLongs, |
| long 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 id="count(long[],long)"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>count</h4> |
| <pre class="methodSignature">public static int count​(long[] srcArr, |
| long 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> |
| </section> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </main> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <footer role="contentinfo"> |
| <nav role="navigation"> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a id="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a id="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../index.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/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" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../allclasses.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li><a href="#field.summary">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field.detail">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a id="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </nav> |
| <p class="legalCopy"><small>Copyright © 2015–2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> |
| </footer> |
| </body> |
| </html> |