Changeset: f459f9ba5ef9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f459f9ba5ef9
Added Files:
        monetdb5/modules/mal/batExtensions.h
Modified Files:
        monetdb5/modules/mal/Makefile.ag
        monetdb5/modules/mal/batExtensions.c
        monetdb5/modules/mal/batExtensions.mal
Branch: default
Log Message:

De-mx cleanup
Combine the BAT extensions in a single file.


diffs (212 lines):

diff --git a/monetdb5/modules/mal/Makefile.ag b/monetdb5/modules/mal/Makefile.ag
--- a/monetdb5/modules/mal/Makefile.ag
+++ b/monetdb5/modules/mal/Makefile.ag
@@ -28,7 +28,6 @@ MTSAFE
 lib_mal = {
        NOINST
        SOURCES = \
-               algebraExtensions.c algebraExtensions.h \
                attach.c attach.h \
                batExtensions.c \
                bbp.c bbp.h \
diff --git a/monetdb5/modules/mal/batExtensions.c 
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -18,10 +18,8 @@
  */
 
 /*
- * @f batExtensions
- * @v 2.0
- * @a M.L.Kersten
- * @+ BAT Extensions
+ * M.L.Kersten
+ * BAT Algebra Extensions
  * The kernel libraries are unaware of the MAL runtime semantics.
  * This calls for declaring some operations in the MAL module section
  * and register them in the kernel modules explicitly.
@@ -33,48 +31,7 @@
  * Another example concerns the (un)pack operations, which direct
  * access the runtime stack to (push)pull the values needed.
  */
-/*
- * @+ Implementation section
- * In most cases we pass a BAT identifier, which should be unified
- * with a BAT descriptor. Upon failure we can simply abort the function.
- *
- */
-#include "monetdb_config.h"
-#include "mal_client.h"
-#include "mal_interpreter.h"
-#include "bat5.h"
-#include "algebra.h"
-
-#ifdef WIN32
-#if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) && 
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) && 
!defined(LIBMONETDB5)
-#define be_export extern __declspec(dllimport)
-#else
-#define be_export extern __declspec(dllexport)
-#endif
-#else
-#define be_export extern
-#endif
-
-be_export str CMDBATsetGarbage(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
-be_export str CMDBATflush(int *res, int *bid);
-be_export str CMDBATreduce(int *ret, int *bid);
-be_export str CMDBATclone(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p);
-be_export str CMDBATnew(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p);
-be_export str CMDBATnewDerived(Client cntxt, MalBlkPtr m, MalStkPtr s, 
InstrPtr p);
-be_export str CMDBATderivedByName(int *ret, str *nme);
-be_export str CMDBATnewint(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p);
-be_export str CMDBBPproject(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
-be_export str CMDBBPprojectNil(int *ret, int *bid);
-be_export str CMDbatunpack(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-be_export str CMDbatpartition(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
-be_export str CMDbatpartition2(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
-be_export str CMDbatpack(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-be_export str CMDbatsingleton(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
-be_export str CMDsetBase(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-
-be_export str CMDgetHead(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-be_export str CMDgetTail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-
+#include "batExtensions.h"
 /*
  * @- Operator implementation
  * A BAT designated as garbage can be removed, provided we
@@ -612,3 +569,39 @@ CMDgetTail(Client cntxt, MalBlkPtr mb, M
        BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
+
+str
+ALGprojectCstBody(bat *result, int *bid, ptr *p, int tt){
+       BAT *b, *bn;
+
+       if ((b = BATdescriptor(*bid)) == NULL) {
+               throw(MAL, "bbp.project", INTERNAL_BAT_ACCESS);
+       }
+
+       if (ATOMvarsized(tt)) {
+               if (p == 0 || *(str *) p == 0)
+                       p = (ptr *) str_nil;
+               else
+                       p = *(ptr **) p;
+       }
+       bn = BATconst(b, tt, p);
+       BBPunfix(b->batCacheid);
+       if (bn) {
+               *result = bn->batCacheid;
+               BBPkeepref(bn->batCacheid);
+               return MAL_SUCCEED;
+       }
+       throw(MAL, "bbp.project", INTERNAL_OBJ_CREATE);
+}
+
+str
+ALGprojectCst(Client cntxt,MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       int *result = (int *) getArgReference(stk, pci, 0);
+       int *bid = (int *) getArgReference(stk, pci, 1);
+       ptr *p = (ptr *) getArgReference(stk, pci, 2);
+       int tt = getArgType(mb, pci, 2);
+
+       (void) cntxt;
+       return ALGprojectCstBody(result, bid, p, tt);
+}
diff --git a/monetdb5/modules/mal/batExtensions.h 
b/monetdb5/modules/mal/batExtensions.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/batExtensions.h
@@ -0,0 +1,62 @@
+/*
+ * 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-2012 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+#ifndef _BAT_EXTENSIONS_
+#define _BAT_EXTENSIONS_
+
+#include "monetdb_config.h"
+#include "mal_client.h"
+#include "mal_interpreter.h"
+#include "bat5.h"
+#include "algebra.h"
+
+#ifdef WIN32
+#if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) && 
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) && 
!defined(LIBMONETDB5)
+#define be_export extern __declspec(dllimport)
+#else
+#define be_export extern __declspec(dllexport)
+#endif
+#else
+#define be_export extern
+#endif
+
+be_export str CMDBATsetGarbage(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+be_export str CMDBATflush(int *res, int *bid);
+be_export str CMDBATreduce(int *ret, int *bid);
+be_export str CMDBATclone(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p);
+be_export str CMDBATnew(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p);
+be_export str CMDBATnewDerived(Client cntxt, MalBlkPtr m, MalStkPtr s, 
InstrPtr p);
+be_export str CMDBATderivedByName(int *ret, str *nme);
+be_export str CMDBATnewint(Client cntxt, MalBlkPtr m, MalStkPtr s, InstrPtr p);
+be_export str CMDBBPproject(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+be_export str CMDBBPprojectNil(int *ret, int *bid);
+be_export str CMDbatunpack(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+be_export str CMDbatpartition(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+be_export str CMDbatpartition2(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+be_export str CMDbatpack(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+be_export str CMDbatsingleton(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+be_export str CMDsetBase(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+
+be_export str CMDgetHead(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+be_export str CMDgetTail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+
+be_export str ALGprojectCst(Client cntxt,MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+be_export str ALGprojectCstBody(bat *result, int *bid, ptr *p, int tt);
+
+#endif /* _BAT_EXTENSIONS_ */
diff --git a/monetdb5/modules/mal/batExtensions.mal 
b/monetdb5/modules/mal/batExtensions.mal
--- a/monetdb5/modules/mal/batExtensions.mal
+++ b/monetdb5/modules/mal/batExtensions.mal
@@ -70,18 +70,10 @@ pattern bat.pack(v:any_1):bat[:oid,:any_
 address CMDbatsingleton
 comment "Create a BAT and store the value";
 
-pattern bat.setBase(b:bat[:any_1,:any_2],c:bat[:any_1,:any_2]...):void
-address CMDsetBase
-comment "Give the non-empty BATs consecutive oid bases.";
+pattern algebra.project( b:bat[:any_1,:any_3], val:any_2) :bat[:any_1,:any_2]
+address ALGprojectCst
+comment "Fill the tail column with a newly typed constant.";
+pattern algebra.project(b:bat[:any_1,:any_3], val:bat[:any_1,:any_2]) 
:bat[:any_1,:any_2]
+address ALGprojectCst
+comment "Fill the tail column with a constant taken from the aligned BAT.";
 
-# The head and tail values can also be extracted using the cursor.
-# It points to the first bun in the chunk under consideration.
-# It is often more effective due to use the iterator with automatic
-# extraction of head and tail value; the overhead involved is much less.
-pattern bat.getHead(b:bat[:any_1,:any],i:lng):any_1
-address ITRgetHead
-comment "return the BUN head value using the cursor.";
-
-pattern bat.getTail(b:bat[:any_2,:any_1],i:lng):any_1
-address ITRgetTail
-comment "return the BUN tail value using the cursor.";
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to