Skip to content

Commit 9a6685f

Browse files
authored
Create empty shards if necessary (#4375)
1 parent bb7043a commit 9a6685f

File tree

1 file changed

+14
-1
lines changed
  • quickwit/quickwit-metastore/src/metastore/file_backed_metastore/file_backed_index

1 file changed

+14
-1
lines changed

quickwit/quickwit-metastore/src/metastore/file_backed_metastore/file_backed_index/serialize.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::collections::HashMap;
2121

2222
use itertools::Itertools;
2323
use quickwit_doc_mapper::{BinaryFormat, FieldMappingType};
24+
use quickwit_proto::metastore::SourceType;
2425
use quickwit_proto::types::SourceId;
2526
use 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

Comments
 (0)