-
Notifications
You must be signed in to change notification settings - Fork 1
/
rplsh_test.go
37 lines (32 loc) · 1001 Bytes
/
rplsh_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Random Projection Local Sensitive Hashing
// By Jurriaan Schreuder
package rplsh
import (
"testing"
)
func TestRplsh(t *testing.T) {
ht := NewHashTable(5, 32)
t.Logf("%08b\n", ht.Hash([]float64{0, 1, 0, 1, 0}))
t.Logf("%08b\n", ht.Hash([]float64{1, 1, 0, 1, 0}))
t.Logf("%08b\n", ht.Hash([]float64{1, 0, 0, 1, 0}))
t.Logf("%08b\n", ht.Hash([]float64{1, 0, 1, 1, 0}))
t.Logf("%08b\n", ht.Hash([]float64{1, 0, 1, 0, 0}))
t.Logf("%08b\n", ht.Hash([]float64{1, 0, 1, 0, 1}))
t.Log(ht.HashUint8([]float64{1, 0, 1, 0, 1}))
t.Log(ht.HashUint16([]float64{1, 0, 1, 0, 1}))
t.Log(ht.HashUint32([]float64{1, 0, 1, 0, 1}))
t.Log(ht.HashUint64([]float64{1, 0, 1, 0, 1}))
}
func TestSave(t *testing.T) {
ht := NewHashTable(5, 64)
t.Log("before save", ht.HashUint64([]float64{1, 0, 1, 0, 1}))
err := ht.Save("test_save.js")
if err != nil {
t.Fatal(err)
}
ht2, err := Load("test_save.js")
if err != nil {
t.Fatal(err)
}
t.Log("after save", ht2.HashUint64([]float64{1, 0, 1, 0, 1}))
}