From 80edb42b6c799862fc7319f8e64ea9a8b78ef46b Mon Sep 17 00:00:00 2001 From: Weili Gu Date: Fri, 15 Mar 2024 15:13:42 -0700 Subject: [PATCH] drain --- rust/worker/src/types/segment.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rust/worker/src/types/segment.rs b/rust/worker/src/types/segment.rs index ead2e4df29f..d85d1293eea 100644 --- a/rust/worker/src/types/segment.rs +++ b/rust/worker/src/types/segment.rs @@ -51,6 +51,8 @@ impl TryFrom for Segment { type Error = SegmentConversionError; fn try_from(proto_segment: chroma_proto::Segment) -> Result { + let mut proto_segment = proto_segment; + let segment_uuid = match Uuid::try_parse(&proto_segment.id) { Ok(uuid) => uuid, Err(_) => return Err(SegmentConversionError::InvalidUuid), @@ -81,11 +83,13 @@ impl TryFrom for Segment { return Err(SegmentConversionError::InvalidUuid); } }; + let mut file_paths = HashMap::new(); - for (key, value) in proto_segment.file_paths { - let values = value.paths.iter().map(|x| x.to_string()).collect(); - file_paths.insert(key, values); + let drain = proto_segment.file_paths.drain(); + for (key, mut value) in drain { + file_paths.insert(key, value.paths); } + Ok(Segment { id: segment_uuid, r#type: segment_type,