@@ -217,8 +217,8 @@ 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=( 8 +prefetched_cachelines- 1 )/prefetched_cachelines ;
221
- static constexpr std::size_t bulk_may_contain_size=( 8 +prefetched_cachelines- 1 )/prefetched_cachelines ;
220
+ static constexpr std::size_t bulk_insert_size=16 ;
221
+ static constexpr std::size_t bulk_may_contain_size=16 ;
222
222
223
223
explicit filter_core (std::size_t m=0 ):filter_core{m,allocator_type{}}{}
224
224
@@ -392,7 +392,7 @@ class filter_core:empty_value<Allocator,0>
392
392
BOOST_FORCEINLINE void bulk_insert (HashStream h,std::size_t n)
393
393
{
394
394
while (n>=2 *bulk_insert_size){
395
- bulk_insert_impl (h,bulk_insert_size );
395
+ bulk_insert_impl<bulk_insert_size>(h );
396
396
n-=bulk_insert_size;
397
397
}
398
398
if (n){
@@ -404,7 +404,7 @@ class filter_core:empty_value<Allocator,0>
404
404
BOOST_FORCEINLINE void bulk_may_contain (HashStream h,std::size_t n,F f)const
405
405
{
406
406
while (n>=2 *bulk_may_contain_size){
407
- bulk_may_contain_impl (h,bulk_may_contain_size ,f);
407
+ bulk_may_contain_impl<bulk_may_contain_size>(h ,f);
408
408
n-=bulk_may_contain_size;
409
409
}
410
410
if (n){
@@ -729,6 +729,34 @@ class filter_core:empty_value<Allocator,0>
729
729
return p;
730
730
}
731
731
732
+ template <std::size_t N,typename HashStream>
733
+ BOOST_FORCEINLINE void bulk_insert_impl (HashStream&& h)
734
+ {
735
+ std::uint64_t hashes[N];
736
+ unsigned char * positions[N];
737
+
738
+ for (auto i=N;i--;){
739
+ auto & hash=hashes[i]=h ();
740
+ auto & p=positions[i];
741
+ hs.prepare_hash (hash);
742
+ p=next_element (hash);
743
+ }
744
+ if (BOOST_UNLIKELY (ar.data ==nullptr ))return ;
745
+ for (auto j=k-1 ;j--;){
746
+ for (auto i=N;i--;){
747
+ auto & hash=hashes[i];
748
+ auto & p=positions[i];
749
+ set (p,hash);
750
+ p=next_element (hash);
751
+ }
752
+ }
753
+ for (auto i=N;i--;){
754
+ auto & hash=hashes[i];
755
+ auto & p=positions[i];
756
+ set (p,hash);
757
+ }
758
+ }
759
+
732
760
template <typename HashStream>
733
761
BOOST_FORCEINLINE void bulk_insert_impl (HashStream&& h,std::size_t n)
734
762
{
@@ -757,6 +785,56 @@ class filter_core:empty_value<Allocator,0>
757
785
}
758
786
}
759
787
788
+ template <std::size_t N,typename HashStream,typename F>
789
+ BOOST_FORCEINLINE void bulk_may_contain_impl (HashStream&& h,F&& f)const
790
+ {
791
+ if (k==1 ){
792
+ std::uint64_t hashes[N];
793
+ const unsigned char * positions[N];
794
+
795
+ for (auto i=N;i--;){
796
+ auto & hash=hashes[i]=h ();
797
+ auto & p=positions[i];
798
+ hs.prepare_hash (hash);
799
+ p=next_element (hash);
800
+ }
801
+ for (auto i=N;i--;){
802
+ auto & hash=hashes[i];
803
+ auto & p=positions[i];
804
+ f (get (p,hash));
805
+ }
806
+ }
807
+ else {
808
+ std::uint64_t hashes[N];
809
+ const unsigned char * positions[N];
810
+ bool results[N];
811
+
812
+ for (auto i=N;i--;){
813
+ auto & hash=hashes[i]=h ();
814
+ auto & p=positions[i];
815
+ results[i]=true ;
816
+ hs.prepare_hash (hash);
817
+ p=next_element (hash);
818
+ }
819
+ for (auto j=k-1 ;j--;){
820
+ for (auto i=N;i--;){
821
+ auto & hash=hashes[i];
822
+ auto & p=positions[i];
823
+ auto & res=results[i];
824
+ res&=get (p,hash);
825
+ p=next_element (hash);
826
+ }
827
+ }
828
+ for (auto i=N;i--;){
829
+ auto & hash=hashes[i];
830
+ auto & p=positions[i];
831
+ auto & res=results[i];
832
+ res&=get (p,hash);
833
+ f (res);
834
+ }
835
+ }
836
+ }
837
+
760
838
template <typename HashStream,typename F>
761
839
BOOST_FORCEINLINE void bulk_may_contain_impl (
762
840
HashStream&& h,std::size_t n,F&& f)const
0 commit comments