Changeset: d551207cf432 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d551207cf432
Added Files:
        monetdb5/modules/mal/array.c
        monetdb5/modules/mal/array.h
        monetdb5/modules/mal/array.mal
Branch: SciQL-2
Log Message:

.mx files are not supported anymore. Thus, I copied the array.h, array.c and 
array.mal files that were missing
from the version that was supporting .mx files


diffs (truncated from 27155 to 300 lines):

diff --git a/monetdb5/modules/mal/array.c b/monetdb5/modules/mal/array.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/array.c
@@ -0,0 +1,25682 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2014 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+#line 213 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+/*============================================================================*/
+#include "monetdb_config.h"
+#include "mal_client.h"
+#include "array.h"
+
+/*----------------------------------------------------------------------------*/
+
+
+
+#line 221 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+#include "mal.h"
+#include "mal_interpreter.h"
+
+
+#line 315 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+
+#line 224 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+str
+ARRAYseries_bte(bat *ret, bte *start, bte *step, bte *stop, int *group, int 
*series)
+{
+       BAT *bn;
+       bte i, *o;
+       BUN cnt= 0;
+       int s,g;
+
+       if ( *group < 1 )
+               throw(MAL, "array.series", "#groups must be > 0,  got (%d)", 
*group);
+       if ( *series < 1 )
+               throw(MAL, "array.series", "#series must be > 0,  got (%d)", 
*series);
+       
+       if (*step == 0 || *start == *stop || (*start < *stop && *step < 0) ||
+                       (*start > *stop && *step > 0))
+               throw(MAL, "array.series", "Illegal dimension range: 
[%d:%d:%d]",
+                               *start, *step, *stop);
+
+
+       cnt =  (BUN) ceil(((*stop * 1.0 - *start) / *step)) * *group * *series ;
+       bn = BATnew(TYPE_void, TYPE_bte, cnt);
+       if ( bn == NULL)
+               throw(MAL, "array.series", MAL_MALLOC_FAIL);
+
+       o = (bte*)Tloc(bn, BUNfirst(bn));
+
+       if ( *start < *stop && *step > 0) {
+               for ( s = 0; s < *series; s++)
+                       for ( i = *start; i < *stop; i += *step)
+                               for( g = 0; g < *group; g++){
+                                       *o = i;
+                                       o++;
+                               }
+       } else {
+               for ( s = 0; s < *series; s++)
+                       for ( i = *start; i > *stop; i += *step)
+                               for( g = 0; g < *group; g++){
+                                       *o = i;
+                                       o++;
+                               }
+       }
+       BATsetcount(bn, cnt);
+       BATseqbase(bn,0);
+       bn->hdense = TRUE;
+       BATkey(bn, TRUE);
+       bn->hsorted = 1;
+       bn->hrevsorted = (cnt <= 1);
+       bn->tsorted = (cnt <= 1 || (*series == 1 && *step > 0));
+       bn->trevsorted = (cnt <= 1 || (*series == 1 && *step < 0));
+       bn->T->nonil = TRUE;
+
+       if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
+       *ret = bn->batCacheid;
+       BBPkeepref(*ret);
+       return MAL_SUCCEED;
+}
+
+str
+ARRAYoffsets_bte(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       bat *ret = (bat*) getArgReference(stk,pci,0);
+       BUN p, rescnt = pci->argc - pci->retc;
+       BAT *res;
+       bte *resT;
+       int i;
+
+       (void) cntxt;
+       (void) mb;
+
+       res = BATnew(TYPE_void, TYPE_bte, rescnt);
+       if(res == NULL) {
+               throw(MAL, "array.offsets", MAL_MALLOC_FAIL);
+       }
+       resT = (bte*) Tloc(res, BUNfirst(res));
+
+       for (p = 0, i = pci->retc; p < rescnt; p++, i++)
+               resT[p] = *(bte*) getArgReference(stk,pci,i);
+
+       BATsetcount(res, rescnt);
+       BATseqbase(res, 0);
+       res->hdense = TRUE;
+       BATkey(res, TRUE);
+       res->hsorted = 1;
+       res->hrevsorted = (rescnt <= 1);
+       res->tsorted = res->trevsorted = (rescnt <= 1);
+       res->T->nonil = TRUE;
+       BBPkeepref(*ret = res->batCacheid);
+       return MAL_SUCCEED;
+}
+
+
+
+#line 315 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+
+
+#line 224 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+str
+ARRAYseries_sht(bat *ret, sht *start, sht *step, sht *stop, int *group, int 
*series)
+{
+       BAT *bn;
+       sht i, *o;
+       BUN cnt= 0;
+       int s,g;
+
+       if ( *group < 1 )
+               throw(MAL, "array.series", "#groups must be > 0,  got (%d)", 
*group);
+       if ( *series < 1 )
+               throw(MAL, "array.series", "#series must be > 0,  got (%d)", 
*series);
+       
+       if (*step == 0 || *start == *stop || (*start < *stop && *step < 0) ||
+                       (*start > *stop && *step > 0))
+               throw(MAL, "array.series", "Illegal dimension range: 
[%d:%d:%d]",
+                               *start, *step, *stop);
+
+
+       cnt =  (BUN) ceil(((*stop * 1.0 - *start) / *step)) * *group * *series ;
+       bn = BATnew(TYPE_void, TYPE_sht, cnt);
+       if ( bn == NULL)
+               throw(MAL, "array.series", MAL_MALLOC_FAIL);
+
+       o = (sht*)Tloc(bn, BUNfirst(bn));
+
+       if ( *start < *stop && *step > 0) {
+               for ( s = 0; s < *series; s++)
+                       for ( i = *start; i < *stop; i += *step)
+                               for( g = 0; g < *group; g++){
+                                       *o = i;
+                                       o++;
+                               }
+       } else {
+               for ( s = 0; s < *series; s++)
+                       for ( i = *start; i > *stop; i += *step)
+                               for( g = 0; g < *group; g++){
+                                       *o = i;
+                                       o++;
+                               }
+       }
+       BATsetcount(bn, cnt);
+       BATseqbase(bn,0);
+       bn->hdense = TRUE;
+       BATkey(bn, TRUE);
+       bn->hsorted = 1;
+       bn->hrevsorted = (cnt <= 1);
+       bn->tsorted = (cnt <= 1 || (*series == 1 && *step > 0));
+       bn->trevsorted = (cnt <= 1 || (*series == 1 && *step < 0));
+       bn->T->nonil = TRUE;
+
+       if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
+       *ret = bn->batCacheid;
+       BBPkeepref(*ret);
+       return MAL_SUCCEED;
+}
+
+str
+ARRAYoffsets_sht(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       bat *ret = (bat*) getArgReference(stk,pci,0);
+       BUN p, rescnt = pci->argc - pci->retc;
+       BAT *res;
+       sht *resT;
+       int i;
+
+       (void) cntxt;
+       (void) mb;
+
+       res = BATnew(TYPE_void, TYPE_sht, rescnt);
+       if(res == NULL) {
+               throw(MAL, "array.offsets", MAL_MALLOC_FAIL);
+       }
+       resT = (sht*) Tloc(res, BUNfirst(res));
+
+       for (p = 0, i = pci->retc; p < rescnt; p++, i++)
+               resT[p] = *(sht*) getArgReference(stk,pci,i);
+
+       BATsetcount(res, rescnt);
+       BATseqbase(res, 0);
+       res->hdense = TRUE;
+       BATkey(res, TRUE);
+       res->hsorted = 1;
+       res->hrevsorted = (rescnt <= 1);
+       res->tsorted = res->trevsorted = (rescnt <= 1);
+       res->T->nonil = TRUE;
+       BBPkeepref(*ret = res->batCacheid);
+       return MAL_SUCCEED;
+}
+
+
+
+#line 316 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+
+
+#line 224 "/ufs/alvanaki/DEV/MonetDB-private/monetdb5/modules/mal/array.mx"
+str
+ARRAYseries_int(bat *ret, int *start, int *step, int *stop, int *group, int 
*series)
+{
+       BAT *bn;
+       int i, *o;
+       BUN cnt= 0;
+       int s,g;
+
+       if ( *group < 1 )
+               throw(MAL, "array.series", "#groups must be > 0,  got (%d)", 
*group);
+       if ( *series < 1 )
+               throw(MAL, "array.series", "#series must be > 0,  got (%d)", 
*series);
+       
+       if (*step == 0 || *start == *stop || (*start < *stop && *step < 0) ||
+                       (*start > *stop && *step > 0))
+               throw(MAL, "array.series", "Illegal dimension range: 
[%d:%d:%d]",
+                               *start, *step, *stop);
+
+
+       cnt =  (BUN) ceil(((*stop * 1.0 - *start) / *step)) * *group * *series ;
+       bn = BATnew(TYPE_void, TYPE_int, cnt);
+       if ( bn == NULL)
+               throw(MAL, "array.series", MAL_MALLOC_FAIL);
+
+       o = (int*)Tloc(bn, BUNfirst(bn));
+
+       if ( *start < *stop && *step > 0) {
+               for ( s = 0; s < *series; s++)
+                       for ( i = *start; i < *stop; i += *step)
+                               for( g = 0; g < *group; g++){
+                                       *o = i;
+                                       o++;
+                               }
+       } else {
+               for ( s = 0; s < *series; s++)
+                       for ( i = *start; i > *stop; i += *step)
+                               for( g = 0; g < *group; g++){
+                                       *o = i;
+                                       o++;
+                               }
+       }
+       BATsetcount(bn, cnt);
+       BATseqbase(bn,0);
+       bn->hdense = TRUE;
+       BATkey(bn, TRUE);
+       bn->hsorted = 1;
+       bn->hrevsorted = (cnt <= 1);
+       bn->tsorted = (cnt <= 1 || (*series == 1 && *step > 0));
+       bn->trevsorted = (cnt <= 1 || (*series == 1 && *step < 0));
+       bn->T->nonil = TRUE;
+
+       if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
+       *ret = bn->batCacheid;
+       BBPkeepref(*ret);
+       return MAL_SUCCEED;
+}
+
+str
+ARRAYoffsets_int(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       bat *ret = (bat*) getArgReference(stk,pci,0);
+       BUN p, rescnt = pci->argc - pci->retc;
+       BAT *res;
+       int *resT;
+       int i;
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to