File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed
fastfilter/src/main/java/org/fastfilter Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change 22
33import java .util .Random ;
44
5- public final class Hash {
6- private Hash () {
7-
8- }
9-
5+ public class Hash {
106 private static final Random random = new Random ();
117
128 public static void setSeed (long seed ) {
13- // shouldn't we use ThreadLocalRandom.current() instead?
149 random .setSeed (seed );
1510 }
1611
@@ -27,7 +22,7 @@ public static long randomSeed() {
2722 }
2823
2924 /**
30- * Shrink the hash to value 0..n. Kind of like modulo, but using
25+ * Shrink the hash to a value 0..n. Kind of like modulo, but using
3126 * multiplication and shift, which are faster to compute.
3227 *
3328 * @param hash the hash
@@ -41,7 +36,7 @@ public static int reduce(int hash, int n) {
4136
4237 /**
4338 * Multiply two unsigned 64-bit values.
44- * See <a href=" https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8188044">JDK-8188044</a>
39+ * See https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8188044
4540 *
4641 * @param a the first value
4742 * @param b the second value
Original file line number Diff line number Diff line change 11package org .fastfilter .xor ;
22
3- import java .lang .reflect .Constructor ;
43import java .nio .ByteBuffer ;
54import java .util .Arrays ;
6-
75import org .fastfilter .Filter ;
86import org .fastfilter .utils .Hash ;
97
@@ -61,7 +59,7 @@ static int calculateSegmentLength(int arity, int size) {
6159 }
6260
6361 static double calculateSizeFactor (int arity , int size ) {
64- final double sizeFactor ;
62+ double sizeFactor ;
6563 if (arity == 3 ) {
6664 sizeFactor = Math .max (1.125 , 0.875 + 0.25 * Math .log (1000000 ) / Math .log (size ));
6765 } else if (arity == 4 ) {
@@ -151,7 +149,8 @@ private void addAll(long[] keys) {
151149 countMask |= t2count [index ];
152150 }
153151 }
154- if (countMask < 0 ) {
152+ startPos = null ;
153+ if (countMask < 0 ) {
155154 // we have a possible counter overflow
156155 continue mainloop ;
157156 }
@@ -216,7 +215,10 @@ private void addAll(long[] keys) {
216215 seed = Hash .randomSeed ();
217216 }
218217
219- for (int i = reverseOrderPos - 1 ; i >= 0 ; i --) {
218+ alone = null ;
219+ t2count = null ;
220+ t2hash = null ;
221+ for (int i = reverseOrderPos - 1 ; i >= 0 ; i --) {
220222 long hash = reverseOrder [i ];
221223 int found = reverseH [i ];
222224 short xor2 = fingerprint (hash );
You can’t perform that action at this time.
0 commit comments