Don't write an empty _vectors field

This commit is contained in:
Louis Dureuil 2024-05-14 11:51:27 +02:00
parent 2f7a8a4efb
commit 0462ebbe58
No known key found for this signature in database

View File

@ -234,16 +234,23 @@ pub(crate) fn write_typed_chunk_into_index(
addition,
)
else {
break 'vectors addition;
break 'vectors Some(addition);
};
vectors.retain_user_provided_vectors();
serde_json::to_writer(&mut vectors_buffer, &vectors.0)
let crate::vector::parsed_vectors::ParsedVectors(vectors) = vectors;
if vectors.is_empty() {
break 'vectors None;
}
serde_json::to_writer(&mut vectors_buffer, &vectors)
.map_err(InternalError::SerdeJson)?;
&vectors_buffer
Some(vectors_buffer.as_slice())
}
_ => addition,
_ => Some(addition),
};
writer.insert(field_id, addition)?;
if let Some(addition) = addition {
writer.insert(field_id, addition)?;
}
}
}