Skip to content

Commit 8cc6c99

Browse files
committed
adding fuse16
1 parent be4c019 commit 8cc6c99

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

fastfilter/src/test/java/org/fastfilter/TestFilterType.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.fastfilter.xor.Xor16;
1515
import org.fastfilter.xor.Xor8;
1616
import org.fastfilter.xor.XorBinaryFuse8;
17+
import org.fastfilter.xor.XorBinaryFuse16;
1718
import org.fastfilter.xor.XorSimple;
1819
import org.fastfilter.xor.XorSimple2;
1920
import org.fastfilter.xorplus.XorPlus8;
@@ -100,6 +101,12 @@ public Filter construct(long[] keys, int setting) {
100101
return XorBinaryFuse8.construct(keys);
101102
}
102103
},
104+
XOR_BINARY_FUSE_16 {
105+
@Override
106+
public Filter construct(long[] keys, int setting) {
107+
return XorBinaryFuse16.construct(keys);
108+
}
109+
},
103110
CUCKOO_8 {
104111
@Override
105112
public Filter construct(long[] keys, int setting) {

fastfilter/src/test/java/org/fastfilter/xor/ProbabilityCFuse.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class ProbabilityCFuse {
2424

2525
public static void main(String... args) {
2626
for(int size = 1; size < 1_000_000; size *= 10) {
27-
// for(int size = 1; size < 1_000_000; size = (size < 100) ? (size + 1) : (int) (size * 1.1)) {
2827
Data best = null;
2928
for (int segmentLengthBits = 3; segmentLengthBits < 14; segmentLengthBits++) {
3029
int segmentLength = 1 << segmentLengthBits;
@@ -65,7 +64,6 @@ static Data getProbability(int size, int segmentLengthBits, double load, Data be
6564
if (best != null && d.bitsPerKey > best.bitsPerKey) {
6665
return null;
6766
}
68-
// System.out.println(" test " + d);
6967
int successCount = 0;
7068
int testCount = Math.max(10, 10_000_000 / size);
7169
for(int seed = 0; seed < testCount; seed++) {

fastfilter/src/test/java/org/fastfilter/xor/ProbabilityCFuse2.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ private static void testProb() {
3737
long seed = 0;
3838
long key = i;
3939
long hash = Hash.hash64(key, seed);
40-
41-
// int r0 = (int) Hash.hash64(hash, 1);
42-
// int x = Hash.reduce(r0, segmentCount);
43-
// int h0 = x + (int) (Hash.hash64(hash, 2) & (segmentLength - 1));
44-
// int h1 = x + (int) (Hash.hash64(hash, 3) & (segmentLength - 1));
45-
// int h2 = x + (int) (Hash.hash64(hash, 4) & (segmentLength - 1));
4640
//
4741
int r0 = (int) Hash.hash64(hash, 1);
4842
int x = Hash.reduce(r0, segmentCount * 2 + segmentLength - 1);
@@ -63,16 +57,9 @@ private static void testProb() {
6357
}
6458

6559
public static void main(String... args) {
66-
//testProb();
67-
//if(true)return;
68-
69-
70-
// for(int size = 100_000; size < 1_000_000; size *= 10) {
7160
for(int size = 1; size < 1_000_000; size *= 10) {
72-
// for(int size = 1; size < 1_000_000; size = (size < 100) ? (size + 1) : (int) (size * 1.1)) {
7361
Data best = null;
7462
for (int segmentLengthBits = 3; segmentLengthBits <= 12; segmentLengthBits++) {
75-
// for (int segmentLengthBits = 3; segmentLengthBits < 14; segmentLengthBits++) {
7663
int segmentLength = 1 << segmentLengthBits;
7764
if (segmentLength > size) {
7865
break;
@@ -89,9 +76,6 @@ public static void main(String... args) {
8976
}
9077
if (best != null) {
9178
System.out.println(best);
92-
// for(int i=0; i<100; i++) {
93-
// System.out.println(i + ": " + best.data[i]);
94-
// }
9579
}
9680
}
9781
}

fastfilter/src/test/java/org/fastfilter/xor/SmallSetTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public void small() {
1313
Xor8.construct(new long[]{0xef9bddc5166c081cL, 0x33bf87adaa46dcfcL});
1414
Xor16.construct(new long[]{0xef9bddc5166c081cL, 0x33bf87adaa46dcfcL});
1515
XorBinaryFuse8.construct(new long[]{0xef9bddc5166c081cL, 0x33bf87adaa46dcfcL});
16+
XorBinaryFuse16.construct(new long[]{0xef9bddc5166c081cL, 0x33bf87adaa46dcfcL});
1617
XorSimple.construct(new long[]{0xef9bddc5166c081cL, 0x33bf87adaa46dcfcL});
1718
XorSimple2.construct(new long[]{0xef9bddc5166c081cL, 0x33bf87adaa46dcfcL});
1819
}
@@ -41,6 +42,19 @@ public void smallSizes() {
4142
}
4243
}
4344

45+
@Test
46+
public void smallSizes16() {
47+
long lastTime = System.currentTimeMillis();
48+
for (int n = 1; n < 1_500_000; n = (int) ((n * 1.01) + 7)) {
49+
XorBinaryFuse16 f = testWithSize16(n);
50+
long now = System.currentTimeMillis();
51+
if (now - lastTime > 5000) {
52+
lastTime = now;
53+
System.out.println("n=" + n + " " + f.toString());
54+
}
55+
}
56+
}
57+
4458
private static XorBinaryFuse8 testWithSize(int n) {
4559
long[] keys = new long[n];
4660
for (int i = 0; i < n; i++) {
@@ -49,4 +63,12 @@ private static XorBinaryFuse8 testWithSize(int n) {
4963
return XorBinaryFuse8.construct(keys);
5064
}
5165

66+
private static XorBinaryFuse16 testWithSize16(int n) {
67+
long[] keys = new long[n];
68+
for (int i = 0; i < n; i++) {
69+
keys[i] = i;
70+
}
71+
return XorBinaryFuse16.construct(keys);
72+
}
73+
5274
}

0 commit comments

Comments
 (0)