Changeset: 19686dfee569 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=19686dfee569
Modified Files:
        sql/backends/monet5/bam/bam_export.c
Branch: bamloader
Log Message:

Finished sam_export and properly catch the not yet working bam_export


diffs (75 lines):

diff --git a/sql/backends/monet5/bam/bam_export.c 
b/sql/backends/monet5/bam/bam_export.c
--- a/sql/backends/monet5/bam/bam_export.c
+++ b/sql/backends/monet5/bam/bam_export.c
@@ -30,6 +30,7 @@
 #include <samtools/bam.h>
 
 #include "bam_globals.h"
+#include "bam_db_interface.h"
 #include "bam_export.h"
 
 
@@ -44,7 +45,7 @@ typedef struct bam_field {
 
 /**
  * Copied directly from bam.h/bam_import.c for use by fill_bam_alig
- * Can not change the call to realloc to GDKrealloc, since
+ * Can not change the calls to realloc to GDKrealloc, since
  * bam_destroy1 does not use GDKfree...
  */
 #ifndef kroundup32
@@ -393,6 +394,7 @@ cleanup_fields(bam_field fields[11]) {
     }
 }
 
+
 #define CUR_STR(field, i) ((str) BUNtail(field.iter, (field.cur+i)))
 #define CUR_SHT(field, i) (*(sht *) BUNtail(field.iter, (field.cur+i)))
 #define CUR_INT(field, i) (*(int *) BUNtail(field.iter, (field.cur+i)))
@@ -409,6 +411,7 @@ sam_export(Client cntxt, MalBlkPtr mb, M
     int tuple_count = 0;
     
     int i;
+    str sql;
     str msg = MAL_SUCCEED;
     
     memset(fields, 0, 11 * sizeof(bam_field));
@@ -433,6 +436,13 @@ sam_export(Client cntxt, MalBlkPtr mb, M
                 CUR_STR(fields[9], i), CUR_STR(fields[10], i));
     }
     
+    /* If we got here, we succesfully exported the result. Drop all data in 
export table */
+    sql = "DELETE FROM bam.export;";
+    RUN_SQL(cntxt, &sql, "bam.drop_export", msg);
+    if (msg != MAL_SUCCEED) {
+        REUSE_EXCEPTION(msg, MAL, "sam_export", "Could not clear the export 
table after exporting: %s", msg);
+    }
+    
     (void)stk;
     (void)pci;
     
@@ -465,7 +475,10 @@ bam_export(Client cntxt, MalBlkPtr mb, M
     bam1_t *alig = NULL;
     
     int i;
+    str sql;
     str msg = MAL_SUCCEED;
+    
+    throw(MAL, "bam_export", "Exporting to BAM files is not implemented yet. 
This is our first priority for the next release of the BAM library.");
 
     if ((output = bam_open(output_path, "wb")) == NULL) {
         msg = createException(MAL, "bam_export", "Could not open output file 
'%s' for writing", output_path);
@@ -518,6 +531,13 @@ bam_export(Client cntxt, MalBlkPtr mb, M
         bam_write1(output, alig);
     }
     
+    /* If we got here, we succesfully exported the result. Drop all data in 
export table */
+    sql = "DELETE FROM bam.export;";
+    RUN_SQL(cntxt, &sql, "bam.drop_export", msg);
+    if (msg != MAL_SUCCEED) {
+        REUSE_EXCEPTION(msg, MAL, "sam_export", "Could not clear the export 
table after exporting: %s", msg);
+    }
+    
     (void)stk;
     (void)pci;
     
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to