@@ -21,6 +21,7 @@ use std::collections::HashMap;
2121
2222use itertools:: Itertools ;
2323use quickwit_doc_mapper:: { BinaryFormat , FieldMappingType } ;
24+ use quickwit_proto:: metastore:: SourceType ;
2425use quickwit_proto:: types:: SourceId ;
2526use serde:: { Deserialize , Serialize } ;
2627
@@ -59,6 +60,7 @@ pub(crate) struct FileBackedIndexV0_7 {
5960 #[ serde( rename = "index" ) ]
6061 metadata : IndexMetadata ,
6162 splits : Vec < Split > ,
63+ // TODO: Remove `skip_serializing_if` when we release ingest v2.
6264 #[ serde( default , skip_serializing_if = "HashMap::is_empty" ) ]
6365 shards : HashMap < SourceId , SerdeShards > ,
6466 #[ serde( default ) ]
@@ -76,6 +78,7 @@ impl From<FileBackedIndex> for FileBackedIndexV0_7 {
7678 . per_source_shards
7779 . into_iter ( )
7880 . filter_map ( |( source_id, shards) | {
81+ // TODO: Remove this filter when we release ingest v2.
7982 // Skip serializing empty shards since the feature is hidden and disabled by
8083 // default. This way, we can still modify the serialization format without worrying
8184 // about backward compatibility post `0.7`.
@@ -130,7 +133,7 @@ impl From<FileBackedIndexV0_7> for FileBackedIndex {
130133 split. split_metadata . index_uid = index. metadata . index_uid . clone ( ) ;
131134 }
132135 }
133- let shards = index
136+ let mut shards: HashMap < SourceId , Shards > = index
134137 . shards
135138 . into_iter ( )
136139 . map ( |( source_id, serde_shards) | {
@@ -141,6 +144,16 @@ impl From<FileBackedIndexV0_7> for FileBackedIndex {
141144 )
142145 } )
143146 . collect ( ) ;
147+ // TODO: Remove this when we release ingest v2.
148+ for source in index. metadata . sources . values ( ) {
149+ if source. source_type ( ) == SourceType :: IngestV2
150+ && !shards. contains_key ( & source. source_id )
151+ {
152+ let index_uid = index. metadata . index_uid . clone ( ) ;
153+ let source_id = source. source_id . clone ( ) ;
154+ shards. insert ( source_id. clone ( ) , Shards :: empty ( index_uid, source_id) ) ;
155+ }
156+ }
144157 Self :: new ( index. metadata , index. splits , shards, index. delete_tasks )
145158 }
146159}
0 commit comments