Commit 663aff89 authored by Cyprien Borée's avatar Cyprien Borée

distribute bins after initialization

for more info see #3393.
parent c13287b9
Pipeline #34836 failed with stages
in 2 minutes and 51 seconds
......@@ -36,23 +36,8 @@ void BinReadStorage::init(size_t nb_bins, size_t max_score, const VirtualReadSco
}
void BinReadStorage::reallocate(){
auto new_bins = new list<Sequence>[nb_bins+1];
auto new_score_bins = new double[nb_bins+1];
auto new_nb_scores = new size_t[nb_bins+1];
for(auto const& i : bins[0]){
float score = scorer->getScore(i);
size_t bin = scoreToBin(score);
addScore(bin, score);
all_read_lengths += i.sequence.length();
if (nb_stored < getMaxNbReadsStored()) {
new_bins[bin].push_back(i);
nb_stored++;
if (bin < (size_t)smallest_bin_not_empty){
smallest_bin_not_empty = bin;
}
}
}
auto tmp_bin = bins;
if(bins){
delete [] bins;
}
......@@ -62,14 +47,16 @@ void BinReadStorage::reallocate(){
if(nb_scores){
delete [] nb_scores;
}
bins = new_bins;
score_bins = new_score_bins;
nb_scores = new_nb_scores;
for (size_t i = 1; i <= nb_bins; i++) {
score_bins[i] = 0;
nb_scores[i] = 0;
bins = new list<Sequence>[nb_bins+1];
score_bins = new double[nb_bins+1];
nb_scores = new size_t[nb_bins+1];
for(auto s : tmp_bin[0]){
  • Par rapport au problème que tu rencontres, ici tmp_bin est un pointeur vers bins, dont l'espace mémoire vient d'être libéré. Cela peut donc provoquer des problèmes.

    Par ailleurs dans la suite tu ne restockes pas s dans bins. Il va donc nous manquer les séquences.

Please register or sign in to reply
float score = scorer->getScore(s);
size_t bin = scoreToBin(score);
addScore(bin, score);
all_read_lengths += s.sequence.length();
}
}
BinReadStorage::~BinReadStorage() {
......@@ -99,11 +86,6 @@ void BinReadStorage::addScore(size_t bin, float score) {
void BinReadStorage::add(Sequence &s) {
float score = scorer->getScore(s);
size_t bin = scoreToBin(score);
addScore(bin, score);
all_read_lengths += s.sequence.length();
if(nb_inserted >= nb_stored){
reallocate();
}
if (nb_stored < getMaxNbReadsStored()) {
bins[bin].push_back(s);
nb_stored++;
......@@ -112,7 +94,8 @@ void BinReadStorage::add(Sequence &s) {
} else {
// We don't have space left.
// Either we don't insert that sequence or it replaces another one
if (bin > smallest_bin_not_empty) {
reallocate();
if (bin > smallest_bin_not_empty) {
bins[smallest_bin_not_empty].erase(bins[smallest_bin_not_empty].begin());
if (bins[smallest_bin_not_empty].size() == 0)
update_smallest_bin_not_empty();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment