Changeset: 2ea7de6705e3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2ea7de6705e3
Modified Files:
        sql/backends/monet5/vaults/bam/bam_loader.c
Branch: default
Log Message:

Don't recurse if a simple loop will do.


diffs (88 lines):

diff --git a/sql/backends/monet5/vaults/bam/bam_loader.c 
b/sql/backends/monet5/vaults/bam/bam_loader.c
--- a/sql/backends/monet5/vaults/bam/bam_loader.c
+++ b/sql/backends/monet5/vaults/bam/bam_loader.c
@@ -118,45 +118,48 @@ run_process_bam_alignments(void *d)
        reader_thread_data *data = (reader_thread_data *) d;
        bam_wrapper *bw;
 
-       TO_LOG("<Thread %d> Starting on next file...\n", data->thread_id);
-       /* First, find out on which bam wrapper we have to work */
-       MT_lock_set(data->reader_lock);
-       if (*data->cur_file == data->nr_files - 1) {
-               /* The last file is already (being) processed, this
-                * thread is done */
+       for (;;) {
+               TO_LOG("<Thread %d> Starting on next file...\n", 
data->thread_id);
+               /* First, find out on which bam wrapper we have to work */
+               MT_lock_set(data->reader_lock);
+               if (*data->cur_file == data->nr_files - 1) {
+                       /* The last file is already (being) processed, this
+                        * thread is done */
+                       MT_lock_unset(data->reader_lock);
+                       TO_LOG("<Thread %d> No files left to work on; thread 
done\n",
+                                  data->thread_id);
+                       return;
+               }
+               (*data->cur_file) += 1;
+               bw = &data->bws[*data->cur_file];
                MT_lock_unset(data->reader_lock);
-               TO_LOG("<Thread %d> No files left to work on; thread done\n",
-                          data->thread_id);
-               return;
-       }
-       (*data->cur_file) += 1;
-       bw = &data->bws[*data->cur_file];
-       MT_lock_unset(data->reader_lock);
-       TO_LOG("<Thread %d> Processing alignments of file '%s' (file id "
-                  LLFMT ")...\n", data->thread_id, bw->file_location,
-                  bw->file_id);
+               TO_LOG("<Thread %d> Processing alignments of file '%s' (file id 
"
+                          LLFMT ")...\n", data->thread_id, bw->file_location,
+                          bw->file_id);
 
-       if ((data->msg =
-                process_alignments(bw, data->failure)) != MAL_SUCCEED) {
-               TO_LOG("<Thread %d> Error while processing alignments of file 
'%s' (file id " LLFMT ") (%s)\n", data->thread_id, bw->file_location, 
bw->file_id, data->msg);
-               REUSE_EXCEPTION(data->msg, MAL, "run_process_bam_alignments",
-                               "Error while processing alignments of file '%s' 
(file id "
-                               LLFMT "): %s", bw->file_location, bw->file_id,
-                               data->msg);
-               return;
+               if ((data->msg =
+                        process_alignments(bw, data->failure)) != MAL_SUCCEED) 
{
+                       TO_LOG("<Thread %d> Error while processing alignments 
of file '%s' "
+                                  "(file id " LLFMT ") (%s)\n",
+                                  data->thread_id, bw->file_location, 
bw->file_id, data->msg);
+                       REUSE_EXCEPTION(data->msg, MAL, 
"run_process_bam_alignments",
+                                                       "Error while processing 
alignments of file '%s' "
+                                                       "(file id " LLFMT "): 
%s",
+                                                       bw->file_location, 
bw->file_id, data->msg);
+                       return;
+               }
+               if (*data->failure) {
+                       /* process_bam_alignments returned because another
+                        * thread failed and not because this thread failed */
+                       TO_LOG("<Thread %d> Exit due to failure in other 
thread\n",
+                                  data->thread_id);
+                       return;
+               }
+
+               TO_LOG("<Thread %d> All alignments in file '%s' (file id " LLFMT
+                          ") processed!\n", data->thread_id, bw->file_location,
+                          bw->file_id);
        }
-       if (*data->failure) {
-               /* process_bam_alignments returned because another
-                * thread failed and not because this thread failed */
-               TO_LOG("<Thread %d> Exit due to failure in other thread\n",
-                          data->thread_id);
-               return;
-       }
-
-       TO_LOG("<Thread %d> All alignments in file '%s' (file id " LLFMT
-                  ") processed!\n", data->thread_id, bw->file_location,
-                  bw->file_id);
-       run_process_bam_alignments(d);
 }
 
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to