mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 03:48:37 +08:00
Add ut to ensure hash result (#26417)
Signed-off-by: wayblink <anyang.wang@zilliz.com>
This commit is contained in:
parent
123ad921e0
commit
ab8214fef9
@ -69,6 +69,77 @@ func TestHash32_String(t *testing.T) {
|
|||||||
assert.Equal(t, uint32(h), h2)
|
assert.Equal(t, uint32(h), h2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHash32_Uint64_Value(t *testing.T) {
|
||||||
|
h, _ := Hash32Int64(int64(0))
|
||||||
|
assert.Equal(t, uint32(1669671676), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(1))
|
||||||
|
assert.Equal(t, uint32(1392991556), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(10))
|
||||||
|
assert.Equal(t, uint32(1857498428), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(100))
|
||||||
|
assert.Equal(t, uint32(1177227376), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(1000))
|
||||||
|
assert.Equal(t, uint32(679959820), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(10000))
|
||||||
|
assert.Equal(t, uint32(1785225994), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(100000))
|
||||||
|
assert.Equal(t, uint32(258819970), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(1000000))
|
||||||
|
assert.Equal(t, uint32(1669527334), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(10000000))
|
||||||
|
assert.Equal(t, uint32(112035536), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(100000000))
|
||||||
|
assert.Equal(t, uint32(107125476), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(1000000000))
|
||||||
|
assert.Equal(t, uint32(913068403), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(10000000000))
|
||||||
|
assert.Equal(t, uint32(1151135), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(100000000000))
|
||||||
|
assert.Equal(t, uint32(2136277055), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(1000000000000))
|
||||||
|
assert.Equal(t, uint32(636570700), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(10000000000000))
|
||||||
|
assert.Equal(t, uint32(469485073), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(100000000000000))
|
||||||
|
assert.Equal(t, uint32(745519692), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(1000000000000000))
|
||||||
|
assert.Equal(t, uint32(1724407835), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(10000000000000000))
|
||||||
|
assert.Equal(t, uint32(2022854314), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(100000000000000000))
|
||||||
|
assert.Equal(t, uint32(1713940411), h)
|
||||||
|
|
||||||
|
h, _ = Hash32Int64(int64(1000000000000000000))
|
||||||
|
assert.Equal(t, uint32(2117120843), h)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHashString2Uint32(t *testing.T) {
|
||||||
|
u := "abcdef"
|
||||||
|
assert.Equal(t, uint32(1267612143), HashString2Uint32(u))
|
||||||
|
|
||||||
|
longStr := "Milvus was created in 2019 with a singular goal: store, index, and manage massive embedding vectors generated by deep neural networks and other machine learning (ML) models.\n\nAs a database specifically designed to handle queries over input vectors, it is capable of indexing vectors on a trillion scale. Unlike existing relational databases which mainly deal with structured data following a pre-defined pattern, Milvus is designed from the bottom-up to handle embedding vectors converted from unstructured data.\n\nAs the Internet grew and evolved, unstructured data became more and more common, including emails, papers, IoT sensor data, Facebook photos, protein structures, and much more. In order for computers to understand and process unstructured data, these are converted into vectors using embedding techniques. Milvus stores and indexes these vectors. Milvus is able to analyze the correlation between two vectors by calculating their similarity distance. If the two embedding vectors are very similar, it means that the original data sources are similar as well."
|
||||||
|
hash := HashString2Uint32(longStr)
|
||||||
|
assert.Equal(t, uint32(2922592797), hash)
|
||||||
|
}
|
||||||
|
|
||||||
func TestHashPK2Channels(t *testing.T) {
|
func TestHashPK2Channels(t *testing.T) {
|
||||||
channels := []string{"test1", "test2"}
|
channels := []string{"test1", "test2"}
|
||||||
int64IDs := &schemapb.IDs{
|
int64IDs := &schemapb.IDs{
|
||||||
|
Loading…
Reference in New Issue
Block a user