@@ -241,15 +241,6 @@ void executor::scan_collisions() const
241241 return map;
242242 };
243243
244- constexpr auto hash = [](const auto & key)
245- {
246- constexpr auto length = array_count<decltype (key)>;
247- constexpr auto size = std::min (length, sizeof (size_t ));
248- size_t value{};
249- std::copy_n (key.begin (), size, system::byte_cast (value).begin ());
250- return value;
251- };
252-
253244 logger (BN_OPERATION_INTERRUPT);
254245
255246 // header & txs (txs is a proxy for validated_bk)
@@ -264,8 +255,11 @@ void executor::scan_collisions() const
264255 while (!cancel_ && (++index < header_records))
265256 {
266257 const header_link link{ possible_narrow_cast<hint>(index) };
267- ++header.at (hash (query_.get_header_key (link.value )) % header_buckets);
268- ++txs.at (hash ((header_link::bytes)link) % header_buckets);
258+ const auto key = query_.get_header_key (link.value );
259+ ++header.at (database::keys::hash (key) % header_buckets);
260+ ++txs.at (database::keys::hash (
261+ link.operator data_array<header_link::size>()) %
262+ header_buckets);
269263
270264 if (is_zero (index % block_frequency))
271265 logger (format (" header/txs" BN_READ_ROW) % index %
@@ -317,8 +311,10 @@ void executor::scan_collisions() const
317311 while (!cancel_ && (++index < tx_records))
318312 {
319313 const tx_link link{ possible_narrow_cast<tx_link::integer>(index) };
320- ++tx.at (hash (query_.get_tx_key (link.value )) % tx_buckets);
321- ++strong_tx.at (hash ((tx_link::bytes)link) % tx_buckets);
314+ const auto key = query_.get_tx_key (link.value );
315+ ++tx.at (database::keys::hash (key) % tx_buckets);
316+ ++strong_tx.at (database::keys::hash (
317+ link.operator data_array<tx_link::size>()) % tx_buckets);
322318
323319 if (is_zero (index % tx_frequency))
324320 logger (format (" tx & strong_tx" BN_READ_ROW) % index %
@@ -364,8 +360,8 @@ void executor::scan_collisions() const
364360 auto total = zero;
365361 index = max_size_t ;
366362 start = logger::now ();
367- const auto spend_buckets = query_.point_buckets ();
368- std_vector<size_t > spend (spend_buckets , empty);
363+ const auto point_buckets = query_.point_buckets ();
364+ std_vector<size_t > spend (point_buckets , empty);
369365 while (!cancel_ && (++index < query_.header_records ()))
370366 {
371367 const header_link link{ possible_narrow_cast<hint>(index) };
@@ -375,11 +371,12 @@ void executor::scan_collisions() const
375371 const auto points = query_.to_points (transaction);
376372 for (const auto & point: points)
377373 {
374+ const auto key = query_.get_point (point);
375+ ++spend.at (database::keys::hash (key) % point_buckets);
378376 ++total;
379- ++spend.at (hash (query_.get_point_key (point)) % spend_buckets);
380377
381- if (is_zero (index % put_frequency))
382- logger (format (" spend " BN_READ_ROW) % total %
378+ if (is_zero (total % put_frequency))
379+ logger (format (" point " BN_READ_ROW) % total %
383380 duration_cast<seconds>(logger::now () - start).count ());
384381 }
385382 }
@@ -390,18 +387,18 @@ void executor::scan_collisions() const
390387
391388 // ........................................................................
392389
393- const auto spend_count = count (spend);
390+ const auto point_count = count (spend);
394391 span = duration_cast<seconds>(logger::now () - start);
395- logger (format (" spend : %1% in %2%s buckets %3% filled %4% rate %5%" ) %
396- total % span.count () % spend_buckets % spend_count %
397- (to_double (spend_count ) / spend_buckets ));
392+ logger (format (" point : %1% in %2%s buckets %3% filled %4% rate %5%" ) %
393+ total % span.count () % point_buckets % point_count %
394+ (to_double (point_count ) / point_buckets ));
398395
399396 for (const auto & entry: dump (spend))
400- logger (format (" spend : %1% frequency: %2%" ) %
397+ logger (format (" point : %1% frequency: %2%" ) %
401398 entry.first % entry.second );
402399
403- spend .clear ();
404- spend .shrink_to_fit ();
400+ // //point .clear();
401+ // //point .shrink_to_fit();
405402}
406403
407404} // namespace node
0 commit comments