@@ -217,8 +217,11 @@ class filter_core:empty_value<Allocator,0>
217
217
using difference_type=std::ptrdiff_t ;
218
218
using pointer=unsigned char *;
219
219
using const_pointer=const unsigned char *;
220
- static constexpr std::size_t bulk_insert_size=16 ;
221
- static constexpr std::size_t bulk_may_contain_size=16 ;
220
+ static constexpr std::size_t bulk_insert_size=
221
+ (32 +prefetched_cachelines-1 )/prefetched_cachelines;
222
+ static constexpr std::size_t bulk_may_contain_size=
223
+ (32 +prefetched_cachelines-1 )/prefetched_cachelines;
224
+
222
225
223
226
explicit filter_core (std::size_t m=0 ):filter_core{m,allocator_type{}}{}
224
227
@@ -391,25 +394,132 @@ class filter_core:empty_value<Allocator,0>
391
394
template <typename HashStream>
392
395
BOOST_FORCEINLINE void bulk_insert (HashStream h,std::size_t n)
393
396
{
394
- while (n>=2 *bulk_insert_size){
397
+ std::uint64_t hashes[bulk_insert_size];
398
+ unsigned char * positions[bulk_insert_size];
399
+
400
+ if (n>=2 *bulk_insert_size){
401
+ for (auto i=bulk_insert_size;i--;){
402
+ auto & hash=hashes[i]=h ();
403
+ auto & p=positions[i];
404
+ hs.prepare_hash (hash);
405
+ p=next_element (hash);
406
+ }
407
+ if (BOOST_UNLIKELY (ar.data ==nullptr ))return ;
408
+ do {
409
+ for (auto j=k-1 ;j--;){
410
+ for (auto i=bulk_insert_size;i--;){
411
+ auto & hash=hashes[i];
412
+ auto & p=positions[i];
413
+ set (p,hash);
414
+ p=next_element (hash);
415
+ }
416
+ }
417
+ for (auto i=bulk_insert_size;i--;){
418
+ auto & hash=hashes[i];
419
+ auto & p=positions[i];
420
+ set (p,hash);
421
+ hash=h ();
422
+ hs.prepare_hash (hash);
423
+ p=next_element (hash);
424
+ }
425
+ n-=bulk_insert_size;
426
+ }while (n>=2 *bulk_insert_size);
427
+ for (auto j=k-1 ;j--;){
428
+ for (auto i=bulk_insert_size;i--;){
429
+ auto & hash=hashes[i];
430
+ auto & p=positions[i];
431
+ set (p,hash);
432
+ p=next_element (hash);
433
+ }
434
+ }
435
+ for (auto i=bulk_insert_size;i--;){
436
+ auto & hash=hashes[i];
437
+ auto & p=positions[i];
438
+ set (p,hash);
439
+ }
440
+ n-=bulk_insert_size;
441
+ }
442
+ while (n--)insert (h ());
443
+
444
+ #if 0
445
+ while(n>=2*bulk_insert_size){
395
446
bulk_insert_impl(h,bulk_insert_size);
396
447
n-=bulk_insert_size;
397
448
}
398
449
if(n){
399
450
bulk_insert_impl(h,n);
400
451
}
452
+ #endif
401
453
}
402
454
403
455
template <typename HashStream,typename F>
404
456
BOOST_FORCEINLINE void bulk_may_contain (HashStream h,std::size_t n,F f)const
405
457
{
458
+ std::uint64_t hashes[bulk_may_contain_size];
459
+ const unsigned char * positions[bulk_may_contain_size];
460
+ bool results[bulk_may_contain_size];
461
+
462
+ if (n>=2 *bulk_may_contain_size){
463
+ for (auto i=bulk_may_contain_size;i--;){
464
+ auto & hash=hashes[i]=h ();
465
+ auto & p=positions[i];
466
+ auto & res=results[i];
467
+ hs.prepare_hash (hash);
468
+ p=next_element (hash);
469
+ res=true ;
470
+ }
471
+ do {
472
+ for (auto j=k-1 ;j--;){
473
+ for (auto i=bulk_may_contain_size;i--;){
474
+ auto & hash=hashes[i];
475
+ auto & p=positions[i];
476
+ auto & res=results[i];
477
+ res&=get (p,hash);
478
+ p=next_element (hash);
479
+ }
480
+ }
481
+ for (auto i=bulk_may_contain_size;i--;){
482
+ auto & hash=hashes[i];
483
+ auto & p=positions[i];
484
+ auto & res=results[i];
485
+ res&=get (p,hash);
486
+ f (res);
487
+ hash=h ();
488
+ hs.prepare_hash (hash);
489
+ p=next_element (hash);
490
+ res=true ;
491
+ }
492
+ n-=bulk_may_contain_size;
493
+ }while (n>=2 *bulk_may_contain_size);
494
+ for (auto j=k-1 ;j--;){
495
+ for (auto i=bulk_may_contain_size;i--;){
496
+ auto & hash=hashes[i];
497
+ auto & p=positions[i];
498
+ auto & res=results[i];
499
+ res&=get (p,hash);
500
+ p=next_element (hash);
501
+ }
502
+ }
503
+ for (auto i=bulk_may_contain_size;i--;){
504
+ auto & hash=hashes[i];
505
+ auto & p=positions[i];
506
+ auto & res=results[i];
507
+ res&=get (p,hash);
508
+ f (res);
509
+ }
510
+ n-=bulk_may_contain_size;
511
+ }
512
+ while (n--)f (may_contain (h ()));
513
+
514
+ #if 0
406
515
while(n>=2*bulk_may_contain_size){
407
516
bulk_may_contain_impl(h,bulk_may_contain_size,f);
408
517
n-=bulk_may_contain_size;
409
518
}
410
519
if(n){
411
520
bulk_may_contain_impl(h,n,f);
412
521
}
522
+ #endif
413
523
}
414
524
415
525
void swap (filter_core& x)noexcept (
0 commit comments