github.com/weaviate/weaviate@v1.24.6/adapters/repos/db/vector/hnsw/helper_for_test.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package hnsw 13 14 import ( 15 "fmt" 16 "math/rand" 17 "strings" 18 "time" 19 ) 20 21 func dumpIndex(index *hnsw, labels ...string) { 22 if len(labels) > 0 { 23 fmt.Printf("--------------------------------------------------\n") 24 fmt.Printf("-- %s\n", strings.Join(labels, ", ")) 25 } 26 fmt.Printf("--------------------------------------------------\n") 27 fmt.Printf("ID: %s\n", index.id) 28 fmt.Printf("Entrypoint: %d\n", index.entryPointID) 29 fmt.Printf("Max Level: %d\n", index.currentMaximumLayer) 30 fmt.Printf("Tombstones %v\n", index.tombstones) 31 fmt.Printf("\nNodes and Connections:\n") 32 for _, node := range index.nodes { 33 if node == nil { 34 continue 35 } 36 37 fmt.Printf(" Node %d\n", node.id) 38 for level, conns := range node.connections { 39 fmt.Printf(" Level %d: Connections: %v\n", level, conns) 40 } 41 } 42 43 fmt.Printf("--------------------------------------------------\n") 44 } 45 46 func getRandomSeed() *rand.Rand { 47 return rand.New(rand.NewSource(time.Now().UnixNano())) 48 }