Skip to content

Commit e0c69b4

Browse files
authored
Use uint32 for hash funcs (#437)
* use uint32 for hash funcs * fix
1 parent b961b65 commit e0c69b4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/models/hashfunction/hashfunction.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ const (
1818
)
1919

2020
var (
21-
noSuchHashFunction = fmt.Errorf("no such hash function")
21+
errNoSuchHashFunction = fmt.Errorf("no such hash function")
2222
)
2323

2424
func ApplyHashFunction(inp []byte, hf HashFunctionType) ([]byte, error) {
2525
switch hf {
2626
case HashFunctionIdent:
2727
return inp, nil
2828
case HashFunctionMurmur:
29-
h := murmur3.Sum64(inp)
30-
return []byte(strconv.FormatUint(h, 10)), nil
29+
h := murmur3.Sum32(inp)
30+
return []byte(strconv.FormatUint(uint64(h), 10)), nil
3131
case HashFunctionCity:
32-
h := city.Hash64(inp)
33-
return []byte(strconv.FormatUint(h, 10)), nil
32+
h := city.Hash32(inp)
33+
return []byte(strconv.FormatUint(uint64(h), 10)), nil
3434
default:
35-
return nil, noSuchHashFunction
35+
return nil, errNoSuchHashFunction
3636
}
3737
}
3838

@@ -45,6 +45,6 @@ func HashFunctionByName(hfn string) (HashFunctionType, error) {
4545
case "city":
4646
return HashFunctionCity, nil
4747
default:
48-
return 0, noSuchHashFunction
48+
return 0, errNoSuchHashFunction
4949
}
5050
}

0 commit comments

Comments
 (0)