Skip to content

Commit

Permalink
drain
Browse files Browse the repository at this point in the history
  • Loading branch information
Weili Gu committed Mar 15, 2024
1 parent 6806e4b commit 80edb42
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rust/worker/src/types/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ impl TryFrom<chroma_proto::Segment> for Segment {
type Error = SegmentConversionError;

fn try_from(proto_segment: chroma_proto::Segment) -> Result<Self, Self::Error> {
let mut proto_segment = proto_segment;

let segment_uuid = match Uuid::try_parse(&proto_segment.id) {
Ok(uuid) => uuid,
Err(_) => return Err(SegmentConversionError::InvalidUuid),
Expand Down Expand Up @@ -81,11 +83,13 @@ impl TryFrom<chroma_proto::Segment> 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,
Expand Down

0 comments on commit 80edb42

Please sign in to comment.