Changeset: e11e4001ca5e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e11e4001ca5e
Modified Files:
        monetdb5/modules/kernel/colcolor.mx
        monetdb5/modules/kernel/column.mx
Branch: headless
Log Message:

File name changes and cleanup


diffs (truncated from 518 to 300 lines):

diff --git a/monetdb5/modules/kernel/colcolor.mx 
b/monetdb5/modules/kernel/colcolor.mx
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/kernel/colcolor.mx
@@ -0,0 +1,277 @@
+@/
+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://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+
+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-2011 MonetDB B.V.
+All Rights Reserved.
+@
+
+@f batcolor
+@a M.L. Kersten
+@+ Color multiplexes
+[TODO: property propagations and general testing]
+The collection of routines provided here are map operations
+for the color string primitives. 
+
+In line with the batcalc module, we assume that
+if two bat operands are provided that they are already
+aligned on the head. Moreover, the head of the BATs
+are limited to :oid, which can be cheaply realized using
+the GRPsplit operation.
+@{
+@mal
+module batcolor;
+command str(b:bat[:oid,:color]):bat[:oid,:str]
+address CLRbatStr
+comment "Identity mapping for string bats";
+
+command color(s:bat[:oid,:str]):bat[:oid,:color]
+address CLRbatColor
+comment "Converts string to color";
+
+command rgb(r:bat[:oid,:int], g:bat[:oid,:int], 
b:bat[:oid,:int]):bat[:oid,:color] 
+address CLRbatRgb
+comment        "Converts an RGB triplets to a color atom";
+
+command red(c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatRed
+comment        "Extracts red component from a color atom";
+
+command green(c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatGreen
+comment        "Extracts green component from a color atom";
+
+command blue (c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatBlue
+comment        "Extracts blue component from a color atom";
+
+command hue(c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatHueInt
+comment        "Extracts hue component from a color atom";
+
+command saturation(c:bat[:oid,:color]) :bat[:oid,:int]
+address CLRbatSaturationInt
+comment        "Extracts saturation component from a color atom";
+
+command value(c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatValueInt
+comment        "Extracts value component from a color atom";
+
+command hsv(h:bat[:oid,:flt],s:bat[:oid,:flt], v:bat[:oid,:flt]) 
:bat[:oid,:color] 
+address CLRbatHsv
+comment        "Converts an HSV triplets to a color atom";
+
+command hue(c:bat[:oid,:color]) :bat[:oid,:flt] 
+address CLRbatHue
+comment        "Extracts hue component from a color atom";
+
+command saturation(c:bat[:oid,:color]) :bat[:oid,:flt] 
+address CLRbatSaturation
+comment        "Extracts saturation component from a color atom";
+
+command value(c:bat[:oid,:color]) :bat[:oid,:flt] 
+address CLRbatValue
+comment        "Extracts value component from a color atom";
+
+@-
+#command ycc(y:bat[:oid,:int],cr:bat[:oid,:int],cb:bat[:oid,:int]) 
:bat[:oid,:color] 
+#address CLRbatycc
+#comment       "Converts an YCC triplets to a color atom";
+@mal
+
+command luminance (c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatLuminance
+comment        "Extracts Y(luminance) component from a color atom";
+
+command cr(c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatCr
+comment        "Extracts Cr(red color) component from a color atom";
+
+command cb(c:bat[:oid,:color]) :bat[:oid,:int] 
+address CLRbatCb
+comment        "Extracts Cb(blue color) component from a color atom";
+@+ Implementation
+@c
+#include "monetdb_config.h"
+#include <gdk.h>
+#include <string.h>
+#include <mal.h>
+#include <color.h>
+#include "mal_exception.h"
+
+#ifdef WIN32
+#if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) && 
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) && 
!defined(LIBMONETDB5)
+#define batcolor_export extern __declspec(dllimport)
+#else
+#define batcolor_export extern __declspec(dllexport)
+#endif
+#else
+#define batcolor_export extern
+#endif
+
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
+
+#define prepareOperand(X,Y,Z) \
+       if( (X= BATdescriptor(*Y)) == NULL ) \
+               throw(MAL, "batstr." Z, RUNTIME_OBJECT_MISSING);
+#define prepareOperand2(X,Y,A,B,Z) \
+       if( (X= BATdescriptor(*Y)) == NULL ) \
+               throw(MAL, "batstr." Z, RUNTIME_OBJECT_MISSING); \
+       if( (A= BATdescriptor(*B)) == NULL ){\
+               BBPreleaseref(X->batCacheid); \
+               throw(MAL, "batstr."Z, RUNTIME_OBJECT_MISSING); \
+       }
+#define prepareResult(X,Y,T,Z) \
+       X= BATnew(Y->htype,T,BATcount(Y)); \
+       if( X == NULL){ \
+               BBPreleaseref(Y->batCacheid); \
+               throw(MAL, "batstr." Z, MAL_MALLOC_FAIL); \
+       } \
+       if( Y->htype== TYPE_void) \
+               BATseqbase(X, Y->hseqbase); \
+       X->hsorted=Y->hsorted; \
+       X->tsorted=0; 
+#define finalizeResult(X,Y,Z) \
+       if (!((Y)->batDirty&2)) (Y) = BATsetaccess((Y), BAT_READ); \
+       *X = (Y)->batCacheid; \
+       BBPkeepref(*(X));\
+       BBPreleaseref(Z->batCacheid);
+@= BATwalk
+batcolor_export str CLRbat@1(int *ret, int *l);
+str CLRbat@1(int *ret, int *l)
+{   
+       BATiter bi;
+       BAT *bn, *b;
+       BUN p,q;
+       @3 *x;
+       @4 y, *yp = &y;
+
+       prepareOperand(b,l,"@1");
+       prepareResult(bn,b,getTypeIndex("@4",-1,TYPE_int),"@1");
+
+       bi = bat_iterator(b);
+
+       BATaccessBegin(b,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATloop(b, p, q) {
+               ptr h = BUNhead(bi,p);
+               x= (@3 *) BUNtail(bi,p);
+               if (x== 0 || *x == @3_nil) {
+                       y = (@4)@4_nil;
+                       bn->T->nonil = 0;
+               } else 
+                       @2(yp,x);
+               bunfastins(bn, h, yp);
+       }
+       BATaccessEnd(b,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       bn->H->nonil = b->H->nonil;
+       finalizeResult(ret,bn,b);
+       return MAL_SUCCEED;
+bunins_failed:
+       BATaccessEnd(b,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(bn->batCacheid);
+       throw(MAL, "batstr.==", OPERATION_FAILED " During bulk operation");
+}
+
+@c
+@:BATwalk(Color,CLRcolor,str,color)@
+@:BATwalk(Str,CLRstr,color,str)@
+
+@:BATwalk(Red,CLRred,color,int)@
+@:BATwalk(Green,CLRgreen,color,int)@
+@:BATwalk(Blue,CLRblue,color,int)@
+
+@:BATwalk(Hue,CLRhue,color,flt)@
+@:BATwalk(Saturation,CLRsaturation,color,flt)@
+@:BATwalk(Value,CLRvalue,color,flt)@
+
+@:BATwalk(HueInt,CLRhueInt,color,int)@
+@:BATwalk(SaturationInt,CLRsaturationInt,color,int)@
+@:BATwalk(ValueInt,CLRvalueInt,color,int)@
+
+@:BATwalk(Luminance,CLRluminance,color,int)@
+@:BATwalk(Cr,CLRcr,color,int)@
+@:BATwalk(Cb,CLRcb,color,int)@
+
+@-
+A few triple versions.
+
+@= BATwalk3
+batcolor_export str CLRbat@1(int *ret, int *l, int *bid2, int *bid3);
+str CLRbat@1(int *ret, int *l, int *bid2, int *bid3)
+{   
+       BATiter bi, b2i, b3i;
+       BAT *bn, *b2,*b3, *b;
+       BUN p,q,p2,p3;
+       @3 *x, *x2, *x3;
+       @4 y, *yp = &y;
+
+       prepareOperand(b,l,"@1");
+       b2= BATdescriptor(*bid2);
+       if(b2== NULL) 
+               throw(MAL, "batcolor.@1",RUNTIME_OBJECT_MISSING);
+       b3= BATdescriptor(*bid3);
+       if(b3== NULL) 
+               throw(MAL, "batcolor.@1",RUNTIME_OBJECT_MISSING);
+       prepareResult(bn,b,getTypeIndex("@4",-1,TYPE_int),"@1");
+
+       bi = bat_iterator(b);
+       b2i = bat_iterator(b2);
+       b3i = bat_iterator(b3);
+
+       p2= BUNfirst(b2);
+       p3= BUNfirst(b3);
+       BATaccessBegin(b,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATaccessBegin(b2,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATaccessBegin(b3,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATloop(b, p, q) {
+               ptr h = BUNhead(bi,p);
+               x= (@3 *) BUNtail(bi,p);
+               x2= (@3 *) BUNtail(b2i,p);
+               x3= (@3 *) BUNtail(b3i,p);
+               if (x== 0 || *x == @3_nil ||
+                  x2== 0 || *x2 == @3_nil ||
+                  x3== 0 || *x3 == @3_nil) {
+                       y = @4_nil;
+                       bn->T->nonil = 0;
+               } else 
+                       @2(yp,x,x2,x3);
+               bunfastins(bn, h, yp);
+               p2++;
+               p3++;
+       }
+       BATaccessEnd(b,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATaccessEnd(b2,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATaccessEnd(b3,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       bn->H->nonil = b->H->nonil;
+       finalizeResult(ret,bn,b);
+       return MAL_SUCCEED;
+bunins_failed:
+       BATaccessEnd(b,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATaccessEnd(b2,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BATaccessEnd(b3,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(bn->batCacheid);
+       throw(MAL, "batstr.==", OPERATION_FAILED " During bulk operation");
+}
+@c
+@:BATwalk3(Hsv,CLRhsv,flt,color)@
+@:BATwalk3(Rgb,CLRrgb,int,color)@
+@:BATwalk3(ycc,CLRycc,int,color)@
+@}
diff --git a/monetdb5/modules/kernel/column.mx 
b/monetdb5/modules/kernel/column.mx
--- a/monetdb5/modules/kernel/column.mx
+++ b/monetdb5/modules/kernel/column.mx
@@ -17,7 +17,7 @@
 All Rights Reserved.
 @
 
-@f bat5
+@f column
 @v 2.0
 @a Peter Boncz, M.L. Kersten
 @+ Binary Association Tables
@@ -607,114 +607,114 @@
 
 #ifdef WIN32
 #if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) && 
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) && 
!defined(LIBMONETDB5)
-#define bat5_export extern __declspec(dllimport)
+#define column_export extern __declspec(dllimport)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to