3333{
3434 /// Iterator over the shard files in the set, opening readers.
3535 shard_reader_iter :
36- Box < dyn Iterator < Item = Result < UnsortedShardFileReader < T , S > , Error > > + Send > ,
36+ Box < dyn Iterator < Item = Result < UnsortedShardFileReader < T , S > , Error > > + Send + Sync > ,
3737
3838 /// Iterator over the current shard file.
3939 active_shard_reader : Option < UnsortedShardFileReader < T , S > > ,
@@ -42,22 +42,16 @@ where
4242impl < T , S > UnsortedShardReader < T , S >
4343where
4444 T : DeserializeOwned ,
45- <S as SortKey < T > >:: Key : Clone + Ord + DeserializeOwned + Send ,
45+ <S as SortKey < T > >:: Key : Clone + Ord + DeserializeOwned + Send + Sync + ' static ,
4646 S : SortKey < T > ,
4747{
4848 /// Open a single shard file.
49- pub fn open < P : AsRef < Path > > ( shard_file : P ) -> Self
50- where
51- <S as SortKey < T > >:: Key : ' static ,
52- {
49+ pub fn open < P : AsRef < Path > > ( shard_file : P ) -> Self {
5350 Self :: open_set ( & [ shard_file] )
5451 }
5552
5653 /// Open a set of shard files.
57- pub fn open_set < P : AsRef < Path > > ( shard_files : & [ P ] ) -> Self
58- where
59- <S as SortKey < T > >:: Key : ' static ,
60- {
54+ pub fn open_set < P : AsRef < Path > > ( shard_files : & [ P ] ) -> Self {
6155 let reader_iter = shard_files
6256 . iter ( )
6357 . map ( |f| f. as_ref ( ) . into ( ) )
7165 }
7266
7367 /// Compute the total number of elements in this set of shard files.
74- pub fn len < P : AsRef < Path > > ( shard_files : & [ P ] ) -> Result < usize , Error >
75- where
76- <S as SortKey < T > >:: Key : ' static ,
77- {
68+ pub fn len < P : AsRef < Path > > ( shard_files : & [ P ] ) -> Result < usize , Error > {
7869 // Create a set reader, and consume all the files, just getting counts.
7970 let files_reader = Self :: open_set ( shard_files) ;
8071 let mut count = 0 ;
@@ -138,7 +129,7 @@ where
138129impl < T , S > Iterator for UnsortedShardReader < T , S >
139130where
140131 T : DeserializeOwned ,
141- <S as SortKey < T > >:: Key : Clone + Ord + DeserializeOwned + Send ,
132+ <S as SortKey < T > >:: Key : Clone + Ord + DeserializeOwned + Send + Sync + ' static ,
142133 S : SortKey < T > ,
143134{
144135 type Item = Result < T , Error > ;
@@ -178,23 +169,20 @@ where
178169 S : SortKey < T > ,
179170{
180171 count : usize ,
181- file_index_iter : Box < dyn Iterator < Item = KeylessShardRecord > + Send > ,
172+ file_index_iter : Box < dyn Iterator < Item = KeylessShardRecord > + Send + Sync > ,
182173 shard_iter : Option < UnsortedShardIter < T > > ,
183174 phantom : PhantomData < S > ,
184175}
185176
186177impl < T , S > UnsortedShardFileReader < T , S >
187178where
188179 T : DeserializeOwned ,
189- <S as SortKey < T > >:: Key : Clone + Ord + DeserializeOwned + Send ,
180+ <S as SortKey < T > >:: Key : Clone + Ord + DeserializeOwned + Send + Sync + ' static ,
190181 S : SortKey < T > ,
191182{
192183 /// Create a unsorted reader for a single shard file.
193184 /// Return Ok(None) if the specified shard file is empty.
194- pub fn new ( path : & Path ) -> Result < Option < Self > , Error >
195- where
196- <S as SortKey < T > >:: Key : ' static ,
197- {
185+ pub fn new ( path : & Path ) -> Result < Option < Self > , Error > {
198186 let reader = ShardReaderSingle :: < T , S > :: open ( path) ?;
199187 let count = reader. len ( ) ;
200188 let mut file_index_iter = reader. index . into_iter ( ) . map ( |r| KeylessShardRecord {
@@ -348,3 +336,11 @@ struct SkipResult {
348336 skipped : usize ,
349337 exhausted : bool ,
350338}
339+
340+ /// Ensure that readers are Sync.
341+ #[ allow( dead_code) ]
342+ const fn assert_readers_are_sync ( ) {
343+ const fn takes_sync < T : Sync > ( ) { }
344+ takes_sync :: < UnsortedShardFileReader < usize , DefaultSort > > ( ) ;
345+ takes_sync :: < UnsortedShardReader < usize , DefaultSort > > ( ) ;
346+ }
0 commit comments