From fe4429f621037a7510746738b8646e51c3ec0e2e Mon Sep 17 00:00:00 2001 From: Evelin Date: Wed, 11 Sep 2024 12:39:59 +0200 Subject: [PATCH] Move short query resources and copy split query resources --- include/valik/search/iterate_queries.hpp | 2 +- include/valik/search/query_record.hpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/valik/search/iterate_queries.hpp b/include/valik/search/iterate_queries.hpp index 21420927..3b4d04b6 100644 --- a/include/valik/search/iterate_queries.hpp +++ b/include/valik/search/iterate_queries.hpp @@ -180,7 +180,7 @@ void iterate_split_queries(search_arguments const & arguments, for (auto const & seg : meta.segments_from_ind(seqCount)) { // each split query record contains a copy of the same shared pointer - query_records.emplace_back(seqan2::toCString(std::move(id)), seg, query_ptr); + query_records.emplace_back(seqan2::toCString(id), seg, query_ptr); if (query_records.size() > chunk_size) { diff --git a/include/valik/search/query_record.hpp b/include/valik/search/query_record.hpp index 635f37b7..db6dd6b1 100644 --- a/include/valik/search/query_record.hpp +++ b/include/valik/search/query_record.hpp @@ -34,12 +34,12 @@ struct shared_query_record seqan2::Segment querySegment; std::shared_ptr underlyingData; - shared_query_record(TSequence seq, std::string id) : sequence_id(std::move(id)) + shared_query_record(TSequence && seq, std::string && id) : sequence_id(std::move(id)) { // make_shared returns a newly allocated object - auto query_ptr = std::make_shared(std::move(seq)); + underlyingData = std::make_shared(std::move(seq)); std::vector seg_vec{}; - for (auto & c : *query_ptr) + for (auto & c : *underlyingData) { seqan3::dna4 nuc; nuc.assign_char(c); @@ -47,11 +47,10 @@ struct shared_query_record } sequence = std::move(seg_vec); - querySegment = seqan2::infix(*query_ptr, 0, seqan2::length(*query_ptr)); - underlyingData = query_ptr; + querySegment = seqan2::infix(*underlyingData, 0, seqan2::length(*underlyingData)); } - shared_query_record(std::string id, metadata::segment_stats const & seg, std::shared_ptr query_ptr) : sequence_id(std::move(id)) + shared_query_record(std::string const & id, metadata::segment_stats const & seg, std::shared_ptr const & query_ptr) : sequence_id(id) { seqan2::Segment inf = seqan2::infixWithLength(*query_ptr, seg.start, seg.len); std::vector seg_vec{};