@@ -26,14 +26,14 @@ use common_catalog::table_context::TableContext;
26
26
use common_exception:: ErrorCode ;
27
27
use common_exception:: Result ;
28
28
use common_storages_table_meta:: meta:: Location ;
29
+ use common_storages_table_meta:: meta:: SnapshotId ;
29
30
use common_storages_table_meta:: meta:: TableSnapshot ;
30
31
use common_storages_table_meta:: meta:: TableSnapshotLite ;
31
32
use futures:: stream:: StreamExt ;
32
33
use futures_util:: future;
33
34
use futures_util:: TryStreamExt ;
34
35
use opendal:: ObjectMode ;
35
36
use opendal:: Operator ;
36
- use roaring:: RoaringBitmap ;
37
37
use tracing:: info;
38
38
use tracing:: warn;
39
39
use tracing:: Instrument ;
@@ -49,11 +49,10 @@ pub struct SnapshotsIO {
49
49
format_version : u64 ,
50
50
}
51
51
52
- pub type PositionTagged < T > = ( T , usize ) ;
53
52
pub struct SnapshotLiteListExtended {
54
53
pub chained_snapshot_lites : Vec < TableSnapshotLite > ,
55
- pub segment_locations : HashMap < Location , RoaringBitmap > ,
56
- pub orphan_snapshot_lites : Vec < PositionTagged < TableSnapshotLite > > ,
54
+ pub segment_locations : HashMap < Location , HashSet < SnapshotId > > ,
55
+ pub orphan_snapshot_lites : Vec < TableSnapshotLite > ,
57
56
}
58
57
59
58
pub enum ListSnapshotLiteOption < ' a > {
@@ -173,7 +172,8 @@ impl SnapshotsIO {
173
172
// List all the snapshot file paths
174
173
// note that snapshot file paths of ongoing txs might be included
175
174
let mut snapshot_files = vec ! [ ] ;
176
- let mut segment_location_with_index: HashMap < Location , RoaringBitmap > = HashMap :: new ( ) ;
175
+ let mut segment_location_with_index: HashMap < Location , HashSet < SnapshotId > > =
176
+ HashMap :: new ( ) ;
177
177
if let Some ( prefix) = Self :: get_s3_prefix_from_file ( & root_snapshot_file) {
178
178
snapshot_files = self . list_files ( & prefix, limit, None ) . await ?;
179
179
}
@@ -198,11 +198,9 @@ impl SnapshotsIO {
198
198
continue ;
199
199
}
200
200
let snapshot_lite = TableSnapshotLite :: from ( snapshot. as_ref ( ) ) ;
201
+ let snapshot_id = snapshot_lite. snapshot_id ;
201
202
snapshot_lites. push ( snapshot_lite) ;
202
203
203
- // since we use u32 RoaringBitmap to index the snapshots
204
- // just in case, here we check if number of snapshot is within upper bound
205
- let idx = u32:: try_from ( snapshot_lites. len ( ) - 1 ) ?;
206
204
if let ListSnapshotLiteOption :: NeedSegmentsWithExclusion ( filter) = list_options {
207
205
// collects segments, and the snapshots that reference them.
208
206
for segment_location in & snapshot. segments {
@@ -214,9 +212,9 @@ impl SnapshotsIO {
214
212
segment_location_with_index
215
213
. entry ( segment_location. clone ( ) )
216
214
. and_modify ( |v| {
217
- v. insert ( idx ) ;
215
+ v. insert ( snapshot_id ) ;
218
216
} )
219
- . or_insert_with ( || RoaringBitmap :: from_iter ( vec ! [ idx ] ) ) ;
217
+ . or_insert_with ( || HashSet :: from_iter ( vec ! [ snapshot_id ] ) ) ;
220
218
}
221
219
}
222
220
}
@@ -255,11 +253,11 @@ impl SnapshotsIO {
255
253
fn chain_snapshots (
256
254
snapshot_lites : Vec < TableSnapshotLite > ,
257
255
root_snapshot : & TableSnapshot ,
258
- ) -> ( Vec < TableSnapshotLite > , Vec < ( TableSnapshotLite , usize ) > ) {
256
+ ) -> ( Vec < TableSnapshotLite > , Vec < TableSnapshotLite > ) {
259
257
let mut snapshot_map = HashMap :: new ( ) ;
260
258
let mut chained_snapshot_lites = vec ! [ ] ;
261
- for ( idx , snapshot_lite) in snapshot_lites. into_iter ( ) . enumerate ( ) {
262
- snapshot_map. insert ( snapshot_lite. snapshot_id , ( snapshot_lite, idx ) ) ;
259
+ for snapshot_lite in snapshot_lites. into_iter ( ) {
260
+ snapshot_map. insert ( snapshot_lite. snapshot_id , snapshot_lite) ;
263
261
}
264
262
let root_snapshot_lite = TableSnapshotLite :: from ( root_snapshot) ;
265
263
let mut prev_snapshot_id_tuple = root_snapshot_lite. prev_snapshot_id ;
@@ -270,7 +268,7 @@ impl SnapshotsIO {
270
268
None => {
271
269
break ;
272
270
}
273
- Some ( ( prev_snapshot, _idx ) ) => {
271
+ Some ( prev_snapshot) => {
274
272
prev_snapshot_id_tuple = prev_snapshot. prev_snapshot_id ;
275
273
chained_snapshot_lites. push ( prev_snapshot) ;
276
274
}
0 commit comments