@@ -35,11 +35,17 @@ impl SegmentWriter for InOrderSegmentWriter {
35
35
}
36
36
37
37
impl InOrderSegmentWriter {
38
+ // TODO: split to get &self, should modify self.region to come after all the splits
38
39
pub fn split ( self , splits : usize ) -> VortexResult < Vec < Self > > {
40
+ let unwritten_region = Region {
41
+ start : self . region . start + self . region_offset ,
42
+ end : self . region . end ,
43
+ } ;
44
+
39
45
Ok ( self
40
46
. buffers
41
47
. lock ( )
42
- . split_region ( & self . region , splits) ?
48
+ . split_region ( & unwritten_region , splits) ?
43
49
. map ( |region| Self {
44
50
buffers : self . buffers . clone ( ) ,
45
51
region,
@@ -61,10 +67,12 @@ impl InOrderSegmentWriter {
61
67
writer : & mut futures:: io:: Cursor < W > ,
62
68
segment_specs : & mut Vec < SegmentSpec > ,
63
69
) -> VortexResult < ( ) > {
64
- let completed = {
65
- let mut guard = self . buffers . lock ( ) ;
66
- guard. completed_buffers ( ) ?
67
- } ;
70
+ let completed = self . buffers . lock ( ) . take_buffers ( ) ?;
71
+ // we are the only writer if here, reclaim the entire region
72
+ self . region = Region :: default ( ) ;
73
+ self . region_offset = 0 ;
74
+
75
+ // TODO(os): spawn everything below
68
76
for buffers in completed. into_values ( ) {
69
77
// The API requires us to write these buffers contiguously. Therefore, we can only
70
78
// respect the alignment of the first one.
0 commit comments