未验证 提交 ab8214fe 编写于 作者: W wayblink 提交者: GitHub

Add ut to ensure hash result (#26417)

Signed-off-by: Nwayblink <anyang.wang@zilliz.com>
上级 123ad921
......@@ -69,6 +69,77 @@ func TestHash32_String(t *testing.T) {
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) {
channels := []string{"test1", "test2"}
int64IDs := &schemapb.IDs{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册