@@ -19,10 +19,11 @@ use std::collections::HashMap;
19
19
use std:: future:: Future ;
20
20
use std:: ops:: BitAndAssign ;
21
21
use std:: pin:: Pin ;
22
- use std:: sync:: { Arc , RwLock } ;
22
+ use std:: sync:: { Arc , OnceLock , RwLock } ;
23
23
use std:: task:: { Context , Poll } ;
24
24
25
25
use futures:: channel:: oneshot;
26
+ use futures:: future:: join_all;
26
27
use futures:: { StreamExt , TryStreamExt } ;
27
28
use roaring:: RoaringTreemap ;
28
29
@@ -41,19 +42,32 @@ use crate::{Error, ErrorKind, Result};
41
42
// state that can be awaited upon to get te EQ deletes. That way we can check to see if
42
43
// a load of each Eq delete file is already in progress and avoid starting another one.
43
44
#[ derive( Debug , Clone ) ]
44
- struct EqDelFuture { }
45
+ struct EqDelFuture {
46
+ result : OnceLock < Predicate > ,
47
+ }
45
48
46
49
impl EqDelFuture {
47
50
pub fn new ( ) -> ( oneshot:: Sender < Predicate > , Self ) {
48
- todo ! ( )
51
+ let ( tx, rx) = oneshot:: channel ( ) ;
52
+ let result = OnceLock :: new ( ) ;
53
+
54
+ crate :: runtime:: spawn ( {
55
+ let result = result. clone ( ) ;
56
+ async move { result. set ( rx. await . unwrap ( ) ) }
57
+ } ) ;
58
+
59
+ ( tx, Self { result } )
49
60
}
50
61
}
51
62
52
63
impl Future for EqDelFuture {
53
64
type Output = Predicate ;
54
65
55
66
fn poll ( self : Pin < & mut Self > , _cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
56
- todo ! ( )
67
+ match self . result . get ( ) {
68
+ None => Poll :: Pending ,
69
+ Some ( predicate) => Poll :: Ready ( predicate. clone ( ) ) ,
70
+ }
57
71
}
58
72
}
59
73
@@ -189,6 +203,16 @@ impl DeleteFileManager {
189
203
. try_collect :: < Vec < _ > > ( )
190
204
. await ?;
191
205
206
+ // wait for all in-progress EQ deletes from other tasks
207
+ let _ = join_all ( results. iter ( ) . filter_map ( |i| {
208
+ if let ParsedDeleteFileContext :: InProgEqDel ( fut) = i {
209
+ Some ( fut. clone ( ) )
210
+ } else {
211
+ None
212
+ }
213
+ } ) )
214
+ . await ;
215
+
192
216
let merged_delete_vectors = results
193
217
. into_iter ( )
194
218
. fold ( HashMap :: default ( ) , Self :: merge_delete_vectors) ;
0 commit comments