Skip to content

Commit

Permalink
Move short query resources and copy split query resources
Browse files Browse the repository at this point in the history
  • Loading branch information
eaasna committed Sep 11, 2024
1 parent 9bca02d commit fe4429f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/valik/search/iterate_queries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
11 changes: 5 additions & 6 deletions include/valik/search/query_record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,23 @@ struct shared_query_record
seqan2::Segment<TSequence const, seqan2::InfixSegment> querySegment;
std::shared_ptr<TSequence> 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<TSequence>(std::move(seq));
underlyingData = std::make_shared<TSequence>(std::move(seq));
std::vector<seqan3::dna4> seg_vec{};
for (auto & c : *query_ptr)
for (auto & c : *underlyingData)
{
seqan3::dna4 nuc;
nuc.assign_char(c);
seg_vec.push_back(nuc);
}

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<TSequence> query_ptr) : sequence_id(std::move(id))
shared_query_record(std::string const & id, metadata::segment_stats const & seg, std::shared_ptr<TSequence> const & query_ptr) : sequence_id(id)
{
seqan2::Segment<TSequence const, seqan2::InfixSegment> inf = seqan2::infixWithLength(*query_ptr, seg.start, seg.len);
std::vector<seqan3::dna4> seg_vec{};
Expand Down

0 comments on commit fe4429f

Please sign in to comment.