Changeset: 35525df8ed60 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=35525df8ed60
Modified Files:
        monetdb5/mal/mal_debugger.c
        monetdb5/modules/mal/mal_io.c
Branch: Oct2020
Log Message:

Code deduplication: use BATprint instead of BATprintcolumns.


diffs (86 lines):

diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -82,7 +82,7 @@ printBATproperties(stream *f, BAT *b)
 static void
 printBATelm(stream *f, bat i, BUN cnt, BUN first)
 {
-       BAT *b, *bs[2]={0};
+       BAT *b, *bs = NULL;
        str tpe;
 
        b = BATdescriptor(i);
@@ -99,19 +99,14 @@ printBATelm(stream *f, bat i, BUN cnt, B
                                mnstr_printf(f, "Sample " BUNFMT " out of " 
BUNFMT "\n", cnt, BATcount(b));
                        }
                        /* cut out a portion of the BAT for display */
-                       bs[1] = BATslice(b, first, first + cnt);
+                       bs = BATslice(b, first, first + cnt);
                        /* get the void values */
-                       if (bs[1] == NULL)
+                       if (bs == NULL)
                                mnstr_printf(f, "Failed to take chunk\n");
                        else {
-                               bs[0] = BATdense(0, bs[1]->hseqbase, 
BATcount(bs[1]));
-                               if( bs[0] == NULL){
-                                       mnstr_printf(f, "Failed to take chunk 
index\n");
-                               } else {
-                                       BATprintcolumns(f, 2, bs);
-                                       BBPunfix(bs[0]->batCacheid);
-                                       BBPunfix(bs[1]->batCacheid);
-                               }
+                               if (BATprint(f, bs) != GDK_SUCCEED)
+                                       mnstr_printf(f, "Failed to print 
chunk\n");
+                               BBPunfix(bs->batCacheid);
                        }
                }
 
diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c
--- a/monetdb5/modules/mal/mal_io.c
+++ b/monetdb5/modules/mal/mal_io.c
@@ -87,7 +87,7 @@ IOprintBoth(Client cntxt, MalBlkPtr mb, 
                return MAL_SUCCEED;
        }
        if (isaBatType(tpe) ) {
-               BAT *b[2];
+               BAT *b;
 
                if (is_bat_nil(*(bat *) val)) {
                        if (hd)
@@ -97,31 +97,20 @@ IOprintBoth(Client cntxt, MalBlkPtr mb, 
                                mnstr_printf(fp, "%s", tl);
                        return MAL_SUCCEED;
                }
-               b[1] = BATdescriptor(*(bat *) val);
-               if (b[1] == NULL) {
+               b = BATdescriptor(*(bat *) val);
+               if (b == NULL) {
                        throw(MAL, "io.print", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
                }
                if (nobat) {
                        if (hd)
                                mnstr_printf(fp, "%s", hd);
-                       mnstr_printf(fp, "<%s>", BBPname(b[1]->batCacheid));
+                       mnstr_printf(fp, "<%s>", BBPname(b->batCacheid));
                        if (tl)
                                mnstr_printf(fp, "%s", tl);
                } else {
-                       b[0] = BATdense(b[1]->hseqbase, b[1]->hseqbase, 
BATcount(b[1]));
-                       if (b[0] == NULL) {
-                               BBPunfix(b[1]->batCacheid);
-                               throw(MAL, "io.print", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-                       }
-                       if (BATroles(b[0], "h") != GDK_SUCCEED) {
-                               BBPunfix(b[0]->batCacheid);
-                               BBPunfix(b[1]->batCacheid);
-                               throw(MAL, "io.print", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-                       }
-                       BATprintcolumns(cntxt->fdout, 2, b);
-                       BBPunfix(b[0]->batCacheid);
+                       BATprint(cntxt->fdout, b);
                }
-               BBPunfix(b[1]->batCacheid);
+               BBPunfix(b->batCacheid);
                return MAL_SUCCEED;
        }
        if (hd)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to