Changeset: c9d8a4e45254 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c9d8a4e45254 Added Files: monetdb5/modules/kernel/algebra.c monetdb5/modules/kernel/algebra.h monetdb5/modules/kernel/algebra.mal Removed Files: monetdb5/modules/kernel/algebra.mx Modified Files: monetdb5/modules/kernel/Makefile.ag Branch: default Log Message:
De-mx algebra.mx. diffs (truncated from 2632 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 @@ -29,7 +29,7 @@ lib_kernel = { SOURCES = \ aggr.c \ alarm.c alarm.h \ - algebra.mx \ + algebra.c algebra.h \ array.c array.h \ bat5.c bat5.h \ batcolor.c batcolor.h \ @@ -49,13 +49,13 @@ lib_kernel = { headers_mal = { HEADERS = mal DIR = libdir/monetdb5 - SOURCES = bat5.mal algebra.mx status.mal unix.mal \ + SOURCES = bat5.mal algebra.mal status.mal unix.mal \ mmath.mal lock.mal sema.mal alarm.mal batstr.mal \ batcolor.mal batmmath.mal \ group.mal aggr.mal array.mal \ counters.mal logger.mal microbenchmark.mal } -EXTRA_DIST = alarm.mal counters.mal lock.mal logger.mal microbenchmark.mal sema.mal unix.mal aggr.mal group.mal +EXTRA_DIST = alarm.mal counters.mal lock.mal logger.mal microbenchmark.mal sema.mal unix.mal aggr.mal group.mal algebra.mal EXTRA_DIST_DIR = Tests diff --git a/monetdb5/modules/kernel/algebra.mx b/monetdb5/modules/kernel/algebra.c rename from monetdb5/modules/kernel/algebra.mx rename to monetdb5/modules/kernel/algebra.c --- a/monetdb5/modules/kernel/algebra.mx +++ b/monetdb5/modules/kernel/algebra.c @@ -1,27 +1,24 @@ -@/ -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-2013 MonetDB B.V. -All Rights Reserved. -@ - -@f algebra - -@c /* - * @a Peter Boncz, Martin Kersten, Niels Nes + * @a Peter Boncz, Martin Kersten, Niels Nes, Sjoerd Mullender * @v 2.0 * @+ BAT Algebra * This modules contains the most common algebraic BAT manipulation @@ -52,1130 +49,6 @@ All Rights Reserved. } \ } while (0) -@ -@mal -# We split between selections that return one value, and selections -# that return a BAT. -# @+ Value Selections -module algebra; - -command exist(b:bat[:any_1,:any_2], h:any_1):bit -address ALGexist -comment "Returns whether 'h' occurs as a head value in b."; - -command exist(b:bat[:any_1,:any_2], h:any_1, t:any_2):bit -address ALGexistBUN -comment "Returns true when 'h,t' occurs as a bun in b."; - -command find(b:bat[:any_1,:any_2], h:any_1):any_2 -address ALGfind -comment "Returns the tail value 't' for which some [h,t] BUN - exists in b. If no such BUN exists, an error occurs." ; - -command position(b:bat[:any_1,:any_2], v:any_1):wrd -address ALGposition -comment "Returns BAT position [0.. b.count] of 'v' in the head - column of b. It Return an error if 'v' does not exist."; - -command position(b:bat[:any_1,:any_2], val:any_1, tval:any_2) :wrd -address ALGpositionBUN -comment "Returns the position of the value pair It returns an - error if 'val' does not exist."; - -command fetch(b:bat[:any_2,:any_1], x:oid) :any_1 -address ALGfetchoid; -command fetch(b:bat[:any_2,:any_1], x:lng) :any_1 -address ALGfetch; -command fetch(b:bat[:any_2,:any_1], x:int) :any_1 -address ALGfetchint -comment "Returns the tail value of the BUN at x-th position - with 0 <= x < b.count"; - -# @+ BAT Selections -# A simple sampling operation is also provided. -# @- Range selection -# The range selections are targeted at the tail of the BAT. -command subselect(b:bat[:oid,:any_1], low:any_1, high:any_1, li:bit, hi:bit, anti:bit) :bat[:oid,:oid] -address ALGsubselect1 -comment "Select all head values for which the tail value is in range. - Input is a dense-headed BAT, output is a dense-headed BAT with in - the tail the head value of the input BAT for which the tail value - is between the values low and high (inclusive if li respectively - hi is set). The output BAT is sorted on the tail value. If low - or high is nil, the boundary is not considered (effectively - and - + infinity). If anti is set, the result is the complement. Nil - values in the tail are never matched, unless low=nil, high=nil, - li=1, hi=1, anti=0. All non-nil values are returned if low=nil, - high=nil, and li, hi are not both 1, or anti=1. - Note that the output is suitable as second input for the other - version of this function."; - -command subselect(b:bat[:oid,:any_1], s:bat[:oid,:oid], low:any_1, high:any_1, li:bit, hi:bit, anti:bit) :bat[:oid,:oid] -address ALGsubselect2 -comment "Select all head values of the first input BAT for which the tail value - is in range and for which the head value occurs in the tail of the - second input BAT. - The first input is a dense-headed BAT, the second input is a - dense-headed BAT with sorted tail, output is a dense-headed BAT - with in the tail the head value of the input BAT for which the - tail value is between the values low and high (inclusive if li - respectively hi is set). The output BAT is sorted on the tail - value. If low or high is nil, the boundary is not considered - (effectively - and + infinity). If anti is set, the result is the - complement. Nil values in the tail are never matched, unless - low=nil, high=nil, li=1, hi=1, anti=0. All non-nil values are - returned if low=nil, high=nil, and li, hi are not both 1, or anti=1. - Note that the output is suitable as second input for this - function."; - -command thetasubselect(b:bat[:oid,:any_1], val:any_1, op:str) :bat[:oid,:oid] -address ALGthetasubselect1 -comment "Select all head values for which the tail value obeys the relation - value OP VAL. - Input is a dense-headed BAT, output is a dense-headed BAT with in - the tail the head value of the input BAT for which the - relationship holds. The output BAT is sorted on the tail value."; - -command thetasubselect(b:bat[:oid,:any_1], s:bat[:oid,:oid], val:any_1, op:str) :bat[:oid,:oid] -address ALGthetasubselect2 -comment "Select all head values of the first input BAT for which the tail value - obeys the relation value OP VAL and for which the head value occurs in - the tail of the second input BAT. - Input is a dense-headed BAT, output is a dense-headed BAT with in - the tail the head value of the input BAT for which the - relationship holds. The output BAT is sorted on the tail value."; - -command select(b:bat[:any_1,:any_2], low:any_2, high:any_2) - :bat[:any_1,:any_2] -address ALGselect -comment "Select all BUNs that have tail values: {v| low <= v <= high}. - NIL boundary values have a special meaning. - + low == nil means: no lower bound - + high == nil means: no upper bound. - NOTE 1: you should cast the nil to the appropriate type, - e.g. int(nil) in order to circumvent type clashes. - NOTE 2: as the 'nil' element has no clear place in the - ordered domain of values, tuples with 'nil' values - are NEVER returned by the range select."; - -command thetaselect(b:bat[:any_1,:any_2], val:any_2, op:str) :bat[:any_1,:any_2] -address ALGthetaselect -comment "The theta (<=,<,=,>,>=) select()"; - -command select(b:bat[:any_1,:any_2], low:any_2, - high:any_2, li:bit, hi:bit) :bat[:any_1,:any_2] -address ALGselectInclusive -comment "Select all BUNs that have tail values: {v| low <{=} v <{=} high}. - Boundary inclusion is indicated separately. - NIL boundary values have a special meaning. - + low == nil means: no lower bound - + high == nil means: no upper bound."; - -command select(b:bat[:any_1,:any_2],value:any_2) :bat[:any_1,:any_2] -address ALGselect1 -comment "Select all BUNs of a BAT with a certain - tail value. Selection on NIL is also - possible (it should be properly casted, - e.g.:int(nil))."; - -command selectNotNil(b:bat[:any_1,:any_2]):bat[:any_1,:any_2] -address ALGselectNotNil -comment "Select all not-nil values"; - -# The second group uses the head to perform the range selection. -command selectH(b:bat[:any_1,:any_2], low:any_1, high:any_1) - :bat[:any_1,:any_2] -address ALGselectHead; - -command selectH(b:bat[:any_1,:any_2], low:any_1, - high:any_1, li:bit, hi:bit) :bat[:any_1,:any_2] -address ALGselectInclusiveHead; - -command selectH(b:bat[:any_1,:any_2],value:any_1) :bat[:any_1,:any_2] -address ALGselect1Head; - -# A special case for this set are the void tailed bats. -command select(b:bat[:any_2,:void], low:any_2) - :bat[:any_2,:void] -address ALGselect1Head; - -command select(b:bat[:any_2,:void], low:any_2, high:any_2) - :bat[:any_2,:void] -address ALGselectHead; -command select(b:bat[:any_2,:void], low:any_2, high:any_2,li:bit, hi:bit) - :bat[:any_2,:void] -address ALGselectInclusiveHead; - -# The second group uses the head to perform the range selection - -command fragment ( b:bat[:any_1,:any_2], hlow:any_1, hhigh:any_1, - tlow:any_2, thigh:any_2 ) :bat[:any_1,:any_2] -address ALGfragment -comment "Select both on head and tail range."; - -command slice(b:bat[:any_1,:any_2], x:oid, y:oid) :bat[:any_1,:any_2] -address ALGslice_oid -comment "Return the slice based on head oid x till y (exclusive)."; - -command slice(b:bat[:any_1,:any_2], x:lng, y:lng) :bat[:any_1,:any_2] -address ALGslice -comment "Return the slice with the BUNs at position x till y."; - -command slice(b:bat[:any_1,:any_2], x:int, y:int) :bat[:any_1,:any_2] -address ALGslice_int -comment "Return the slice with the BUNs at position x till y."; - -command slice(b:bat[:any_1,:any_2], x:wrd, y:wrd) :bat[:any_1,:any_2] -address ALGslice_wrd -comment "Return the slice with the BUNs at position x till y."; - -command subslice(b:bat[:oid,:any_1], x:wrd, y:wrd) :bat[:oid,:oid] -address ALGsubslice_wrd -comment "Return the oids of the slice with the BUNs at position x till y."; - -command topN( b:bat[:any_1,:any_2], top:lng ) :bat[:any_1,:any_2] -address ALGtopN -comment "Trim all but the top N tuples."; - -command groupby(gids:bat[:oid,:oid], cnts:bat[:oid,:wrd]) :bat[:oid,:oid] -address ALGgroupby -comment "Produces a new BAT with groups identified by the head column. The result contains tail times the head value, ie the tail contains the result group sizes."; - -command uselect(b:bat[:any_1,:any_2], low:any_2, high:any_2, - li:bit, hi:bit) :bat[:any_1,:void] -address ALGuselectInclusive -comment "See select() but limited to head values"; - -command thetauselect(b:bat[:any_1,:any_2], val:any_2, op:str) :bat[:any_1,:void] -address ALGthetauselect -comment "The theta (<=,<,=,>,>=) select() limited to head values"; - -command uselect(b:bat[:any_1,:any_2], low:any_2, high:any_2):bat[:any_1,:void] -address ALGuselect; -command uselect(b:bat[:any_1,:any_2], value:any_2) :bat[:any_1,:void] -address ALGuselect1 -comment "Value select, but returning only the - head values. SEE ALSO:select(bat,val)"; - -command antiuselect(b:bat[:any_1,:any_2], value:any_2) :bat[:any_1,:void] -address ALGantiuselect1 -comment "Value select, but returning only the - head values. SEE ALSO:select(bat,val)"; - -command antiuselect(b:bat[:any_1,:any_2], low:any_2, high:any_2, - li:bit, hi:bit) :bat[:any_1,:void] -address ALGantiuselectInclusive -comment "See select() but limited to head values"; -# @- Pattern matching -command like(b:bat[:any_1,:str], substr:str) :bat[:any_1,:str] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list