Changeset: e3ae9b7d347a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e3ae9b7d347a
Added Files:
monetdb5/modules/kernel/batstr.c
monetdb5/modules/kernel/batstr.h
monetdb5/modules/kernel/batstr.mal
Removed Files:
monetdb5/modules/kernel/batstr.mx
Modified Files:
monetdb5/modules/kernel/Makefile.ag
Branch: default
Log Message:
De-mx batstr module
diffs (truncated from 1466 to 300 lines):
diff --git a/monetdb5/modules/kernel/Makefile.ag
b/monetdb5/modules/kernel/Makefile.ag
--- a/monetdb5/modules/kernel/Makefile.ag
+++ b/monetdb5/modules/kernel/Makefile.ag
@@ -47,7 +47,7 @@ lib_kernel = {
batifthen.mx \
batmmath.c batmmath.h \
batmtime.mx \
- batstr.mx \
+ batstr.c batstr.h \
calc.c \
counters.c counters.h \
group.mx \
@@ -64,7 +64,7 @@ headers_mal = {
HEADERS = mal
DIR = libdir/monetdb5
SOURCES = calc.mal bat5.mal algebra.mx status.mal unix.mal \
- mmath.mal lock.mal sema.mal alarm.mal batstr.mx batmtime.mx \
+ mmath.mal lock.mal sema.mal alarm.mal batstr.mal batmtime.mx \
batcolor.mal batifthen.mx batcalc.mal batmmath.mal \
group.mx aggr.mx array.mal \
counters.mal logger.mal microbenchmark.mal
diff --git a/monetdb5/modules/kernel/batstr.mx
b/monetdb5/modules/kernel/batstr.c
rename from monetdb5/modules/kernel/batstr.mx
rename to monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.mx
+++ b/monetdb5/modules/kernel/batstr.c
@@ -1,28 +1,25 @@
-@/
-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
+/*
+ * 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.
+*/
-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.
-@
-
-@f batstr
-
-@c
/*
- * @a M.L. Kersten
- * @+ String multiplexes
+ * M.L. Kersten
+ * String multiplexes
* [TODO: property propagations]
* The collection of routines provided here are map operations
* for the atom string primitives.
@@ -33,149 +30,6 @@ All Rights Reserved.
* are limited to :void, which can be cheaply realized using
* the GRPsplit operation.
*/
-@mal
-module batstr;
-
-command batstr.length( s:bat[:oid,:str] ) :bat[:oid,:int]
-address STRbatLength
-comment "Return the length of a string.";
-
-command batstr.stringlength( s:bat[:oid,:str] ) :bat[:oid,:int]
-address STRbatstringLength
-comment "Return the length of a right trimed string.";
-
-command batstr.nbytes( s:bat[:oid,:str] ) :bat[:oid,:int]
-address STRbatBytes
-comment "Return the string length in bytes.";
-
-command batstr.toLower( s:bat[:oid,:str] ) :bat[:oid,:str]
-address STRbatLower
-comment "Convert a string to lower case.";
-command batstr.toUpper( s:bat[:oid,:str] ) :bat[:oid,:str]
-address STRbatUpper
-comment "Convert a string to upper case.";
-
-command batstr.trim( s:bat[:oid,:str] ) :bat[:oid,:str]
-address STRbatStrip
-comment "Strip whitespaces around a string.";
-command batstr.ltrim( s:bat[:oid,:str] ) :bat[:oid,:str]
-address STRbatLtrim
-comment "Strip whitespaces from start of a string.";
-command batstr.rtrim( s:bat[:oid,:str] ) :bat[:oid,:str]
-address STRbatRtrim
-comment "Strip whitespaces from end of a string.";
-
-command
batstr.startsWith(s:bat[:oid,:str],prefix:bat[:oid,:str]):bat[:oid,:bit]
-address STRbatPrefix
-comment "Prefix check.";
-command batstr.startsWith(s:bat[:oid,:str],prefix:str):bat[:oid,:bit]
-address STRbatPrefixcst
-comment "Prefix check.";
-
-command batstr.endsWith( s:bat[:oid,:str], suffix:bat[:oid,:str] )
:bat[:oid,:bit]
-address STRbatSuffix
-comment "Suffix check.";
-command batstr.endsWith( s:bat[:oid,:str], suffix:str ) :bat[:oid,:bit]
-address STRbatSuffixcst
-comment "Suffix check.";
-
-command batstr.search( s:bat[:oid,:str], c:bat[:oid,:str] ) :bat[:oid,:int]
-address STRbatstrSearch
-comment "Search for a substring. Returns position, -1 if not found.";
-command batstr.search( s:bat[:oid,:str], c:str ) :bat[:oid,:int]
-address STRbatstrSearchcst
-comment "Search for a substring. Returns position, -1 if not found.";
-
-command batstr.r_search( s:bat[:oid,:str], c:bat[:oid,:str] ) :bat[:oid,:int]
-address STRbatRstrSearch
-comment "Reverse search for a substring. Returns position, -1 if not found.";
-command batstr.r_search( s:bat[:oid,:str], c:str ) :bat[:oid,:int]
-address STRbatRstrSearchcst
-comment "Reverse search for a substring. Returns position, -1 if not found.";
-
-command batcalc.+( l:bat[:oid,:str], r:bat[:oid,:str]) :bat[:oid,:str]
-address STRbatConcat
-comment "Concatenate two strings.";
-command batcalc.+( l:bat[:oid,:str], r:str) :bat[:oid,:str]
-address STRbatConcatcst
-comment "Concatenate a string to a bat of strings.";
-command batcalc.+( l:str, r:bat[:oid,:str]) :bat[:oid,:str]
-address STRcstConcatbat
-comment "Concatenate two strings.";
-
-command batstr.string(b:bat[:oid,:str],offset:bat[:oid,:int]) :bat[:oid,:str]
-address STRbatTail
-comment "Return the tail s[offset..n] of a string s[0..n].";
-command batstr.string(b:bat[:oid,:str],offset:int) :bat[:oid,:str]
-address STRbatTailcst
-comment "Return the tail s[offset..n] of a string s[0..n].";
-
-command batstr.substring( s:bat[:oid,:str], start:bat[:oid,:int],
- index:bat[:oid,:int]) :bat[:oid,:str]
-address STRbatsubstring
-comment "Substring extraction using [start,start+length]";
-
-command batstr.substring( s:bat[:oid,:str], start:int, index:int)
- :bat[:oid,:str]
-address STRbatsubstringcst
-comment "Substring extraction using [start,start+length]";
-
-command batstr.unicodeAt(s:bat[:oid,:str], index:bat[:oid,:int])
:bat[:oid,:int]
-address STRbatWChrAt
-comment "get a unicode character (as an int) from a string position.";
-command batstr.unicodeAt(s:bat[:oid,:str], index:int) :bat[:oid,:int]
-address STRbatWChrAtcst
-comment "get a unicode character (as an int) from a string position.";
-
-command
batstr.substitute(s:bat[:oid,:str],src:str,dst:str,rep:bit):bat[:oid,:str]
-address STRbatSubstitutecst
-comment "Substitute first occurrence of 'src' by
- 'dst'. Iff repeated = true this is
- repeated while 'src' can be found in the
- result string. In order to prevent
- recursion and result strings of unlimited
- size, repeating is only done iff src is
- not a substring of dst.";
-
-command batstr.like_uselect(s:bat[:oid,:str],pat:str):bat[:oid,:void]
-address STRbatlike_uselect2
-comment "Perform SQL like operation against a string bat";
-
-command batstr.like_uselect(s:bat[:oid,:str],pat:str,esc:str):bat[:oid,:void]
-address STRbatlike_uselect
-comment "Perform SQL like operation against a string bat";
-
-command batstr.replace(s:bat[:oid,:str],pat:str,s2:str):bat[:oid,:str]
-address STRbatreplace
-comment "Insert a string into another";
-
-@c
-/*
- * @+ Implementation
- */
-#include "monetdb_config.h"
-#include <gdk.h>
-#include "ctype.h"
-#include <string.h>
-#include "mal_exception.h"
-#include "str.h"
-
-#ifdef HAVE_LANGINFO_H
-#include <langinfo.h>
-#endif
-#ifdef HAVE_ICONV_H
-#include <iconv.h>
-#endif
-
-#ifdef WIN32
-#if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) &&
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) &&
!defined(LIBMONETDB5)
-#define batstr_export extern __declspec(dllimport)
-#else
-#define batstr_export extern __declspec(dllexport)
-#endif
-#else
-#define batstr_export extern
-#endif
#define prepareOperand(X,Y,Z) \
if( (X= BATdescriptor(*Y)) == NULL ) \
@@ -218,26 +72,58 @@ comment "Insert a string into another";
BBPkeepref(*(X));\
BBPreleaseref(Z->batCacheid);
-@= BATint
-batstr_export str STRbat@1(int *ret, int *l);
-str STRbat@1(int *ret, int *l)
+str STRbatLength(int *ret, int *l)
{
BATiter bi;
BAT *bn, *b;
BUN p,q;
- @3 x;
+ str x;
int y, *yp = &y;
- prepareOperand(b,l,"@1");
- prepareResult(bn,b,TYPE_int,"@1");
+ prepareOperand(b,l,"Length");
+ prepareResult(bn,b,TYPE_int,"Length");
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 || strcmp(x,@3_nil)== 0) {
+ x = (str) BUNtail(bi,p);
+ if (x== 0 || strcmp(x,str_nil)== 0) {
+ y= int_nil;
+ bn->T->nonil = 0;
+ } else
+ strLength(yp,x);
+ bunfastins(bn, h, yp);
+ }
+ BATaccessEnd(b, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
+ finalizeResult(ret,bn,b);
+ return MAL_SUCCEED;
+bunins_failed:
+ BATaccessEnd(b, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
+ BBPreleaseref(b->batCacheid);
+ BBPunfix(bn->batCacheid);
+ throw(MAL, "batstr.Length", OPERATION_FAILED " During bulk operation");
+}
+
+str STRbatstringLength(int *ret, int *l)
+{
+ BATiter bi;
+ BAT *bn, *b;
+ BUN p,q;
+ str x;
+ int y, *yp = &y;
+
+ prepareOperand(b,l,"stringLength");
+ prepareResult(bn,b,TYPE_int,"stringLength");
+
+ bi = bat_iterator(b);
+
+ BATaccessBegin(b, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
+ BATloop(b, p, q) {
+ ptr h = BUNhead(bi,p);
+ x = (str) BUNtail(bi,p);
+ if (x== 0 || strcmp(x,str_nil)== 0) {
y= int_nil;
bn->T->nonil = 0;
} else
@@ -251,26 +137,52 @@ bunins_failed:
BATaccessEnd(b, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
BBPreleaseref(b->batCacheid);
BBPunfix(bn->batCacheid);
- throw(MAL, "batstr.@1", OPERATION_FAILED " During bulk operation");
+ throw(MAL, "batstr.stringLength", OPERATION_FAILED " During bulk
operation");
}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list