Skip to content

Commit

Permalink
refactor: Move pre-filtering to mapModule to prevent memory buildup
Browse files Browse the repository at this point in the history
  • Loading branch information
ekg committed Nov 21, 2024
1 parent 9ca2140 commit 2d2deec
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/map/include/computeMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,21 +721,6 @@ namespace skch

aggregator.join();

// Filter mappings for this subset to reduce memory usage
for (auto& [querySeqId, mappings] : combinedMappings) {
if (param.filterMode == filter::MAP || param.filterMode == filter::ONETOONE) {
MappingResultsVector_t filteredMappings;
filterByGroup(mappings, filteredMappings, param.numMappingsForSegment - 1, false, *idManager, progress);
mappings = std::move(filteredMappings);

// Also apply length and identity filters
filterWeakMappings(mappings, std::floor(param.block_length / param.segLength));
if (param.filterLengthMismatches) {
filterFalseHighIdentity(mappings);
}
sparsifyMappings(mappings);
}
}

// Reset flags and clear aggregatedMappings for next iteration
reader_done.store(false);
Expand Down Expand Up @@ -956,6 +941,20 @@ namespace skch

mappingBoundarySanityCheck(input, output->results);

// Apply pre-filtering immediately after mapping against this subset
if (param.filterMode == filter::MAP || param.filterMode == filter::ONETOONE) {
MappingResultsVector_t filteredMappings;
filterByGroup(output->results, filteredMappings, param.numMappingsForSegment - 1, false, *idManager, input->progress);
output->results = std::move(filteredMappings);

// Also apply length and identity filters
filterWeakMappings(output->results, std::floor(param.block_length / param.segLength));
if (param.filterLengthMismatches) {
filterFalseHighIdentity(output->results);
}
sparsifyMappings(output->results);
}

return output;
}

Expand Down

0 comments on commit 2d2deec

Please sign in to comment.