@@ -204,7 +204,7 @@ impl<RT: Runtime, T: SearchIndexConfigParser> SearchIndexCompactor<RT, T> {
204204 log_compaction_total_segments ( total_compacted_segments, Self :: search_type ( ) ) ;
205205
206206 let new_segment = self
207- . compact ( & job. developer_config , & segments_to_compact)
207+ . compact ( & job. developer_config , segments_to_compact. clone ( ) )
208208 . await ?;
209209 let stats = new_segment. statistics ( ) ?;
210210
@@ -216,11 +216,7 @@ impl<RT: Runtime, T: SearchIndexConfigParser> SearchIndexCompactor<RT, T> {
216216 job. index_id ,
217217 job. index_name ,
218218 snapshot_ts,
219- segments_to_compact
220- . clone ( )
221- . into_iter ( )
222- . cloned ( )
223- . collect_vec ( ) ,
219+ segments_to_compact. clone ( ) ,
224220 new_segment. clone ( ) ,
225221 * SEARCH_WORKER_PASSIVE_PAGES_PER_SECOND ,
226222 )
@@ -304,9 +300,13 @@ impl<RT: Runtime, T: SearchIndexConfigParser> SearchIndexCompactor<RT, T> {
304300 developer_config : & ' a <T :: IndexType as SearchIndex >:: DeveloperConfig ,
305301 compaction_config : & CompactionConfig ,
306302 ) -> anyhow:: Result < (
307- Vec < & ' a <T :: IndexType as SearchIndex >:: Segment > ,
303+ Vec < <T :: IndexType as SearchIndex >:: Segment > ,
308304 CompactionReason ,
309305 ) > {
306+ fn to_owned < R : Clone > ( borrowed : Vec < & R > ) -> Vec < R > {
307+ borrowed. into_iter ( ) . cloned ( ) . collect_vec ( )
308+ }
309+
310310 let segments_and_sizes = segments
311311 . iter ( )
312312 . map ( |segment| Ok ( ( segment, segment. total_size_bytes ( developer_config) ?) ) )
@@ -327,7 +327,7 @@ impl<RT: Runtime, T: SearchIndexConfigParser> SearchIndexCompactor<RT, T> {
327327 let compact_small =
328328 Self :: max_compactable_segments ( small_segments, developer_config, compaction_config) ?;
329329 if let Some ( compact_small) = compact_small {
330- return Ok ( ( compact_small, CompactionReason :: SmallSegments ) ) ;
330+ return Ok ( ( to_owned ( compact_small) , CompactionReason :: SmallSegments ) ) ;
331331 }
332332 // Next check to see if we have too many larger segments and if so, compact
333333 // them.
@@ -341,7 +341,7 @@ impl<RT: Runtime, T: SearchIndexConfigParser> SearchIndexCompactor<RT, T> {
341341 compaction_config,
342342 ) ?;
343343 if let Some ( compact_large) = compact_large {
344- return Ok ( ( compact_large, CompactionReason :: LargeSegments ) ) ;
344+ return Ok ( ( to_owned ( compact_large) , CompactionReason :: LargeSegments ) ) ;
345345 }
346346
347347 // Finally check to see if any individual segment has a large number of deleted
@@ -361,7 +361,7 @@ impl<RT: Runtime, T: SearchIndexConfigParser> SearchIndexCompactor<RT, T> {
361361 } ) ?
362362 . map ( |( segment, _) | vec ! [ segment] ) ;
363363 if let Some ( compact_deletes) = compact_deletes {
364- return Ok ( ( compact_deletes, CompactionReason :: Deletes ) ) ;
364+ return Ok ( ( to_owned ( compact_deletes) , CompactionReason :: Deletes ) ) ;
365365 }
366366 tracing:: trace!(
367367 "Found no segments to compact, segments: {:#?}" ,
@@ -396,7 +396,7 @@ impl<RT: Runtime, T: SearchIndexConfigParser> SearchIndexCompactor<RT, T> {
396396 async fn compact (
397397 & self ,
398398 developer_config : & <T :: IndexType as SearchIndex >:: DeveloperConfig ,
399- segments : & Vec < & <T :: IndexType as SearchIndex >:: Segment > ,
399+ segments : Vec < <T :: IndexType as SearchIndex >:: Segment > ,
400400 ) -> anyhow:: Result < <T :: IndexType as SearchIndex >:: Segment > {
401401 let total_segment_size_bytes: u64 = segments
402402 . iter ( )
0 commit comments