PragmaTwice commented on code in PR #3562:
URL: https://github.com/apache/kvrocks/pull/3562#discussion_r3639750864


##########
src/search/hnsw_indexer.cc:
##########
@@ -173,14 +172,15 @@ StatusOr<double> ComputeSimilarity(const VectorItem& 
left, const VectorItem& rig
 }
 
 HnswIndex::HnswIndex(const SearchKey& search_key, HnswVectorFieldMetadata* 
vector, engine::Storage* storage,
-                     std::random_device::result_type seed)
+                     std::optional<std::random_device::result_type> seed)
     : search_key(search_key),
       metadata(vector),
       storage(storage),
-      generator(std::mt19937(seed)),
+      seed(seed),
       m_level_normalization_factor(1.0 / std::log(metadata->m)) {}
 
 uint16_t HnswIndex::RandomizeLayer() {
+  static thread_local std::mt19937 generator = [this] { return 
std::mt19937(seed.value_or(std::random_device()())); }();

Review Comment:
   1. I think we can just remove `seed` here.
   2. After the change, don't forget to rewrite the PR title and description to 
match the current implementation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to