Changeset: af41bd7fe437 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=af41bd7fe437 Modified Files: monetdb5/modules/kernel/bat5.mx monetdb5/modules/kernel/batcalc.mx monetdb5/modules/kernel/batcast.mx monetdb5/modules/kernel/batcolor.mx monetdb5/modules/kernel/batifthen.mx monetdb5/modules/kernel/batmmath.mx monetdb5/modules/kernel/batmtime.mx monetdb5/modules/kernel/batstr.mx monetdb5/modules/kernel/colcolore.mx Branch: headless Log Message:
Files not needed anymore diffs (truncated from 9066 to 300 lines): diff --git a/monetdb5/modules/kernel/bat5.mx b/monetdb5/modules/kernel/bat5.mx deleted file mode 100644 --- a/monetdb5/modules/kernel/bat5.mx +++ /dev/null @@ -1,4135 +0,0 @@ -@/ -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 bat5 -@v 2.0 -@a Peter Boncz, M.L. Kersten -@+ Binary Association Tables -This module contains the commands and patterns to manage Binary -Association Tables (BATs). The relational operations you can execute -on BATs have the form of a neat algebra, described in algebra.mx - -But a database system needs more that just this algebra, since often it -is crucial to do table-updates (this would not be permitted in a strict -algebra). - -All commands needed for BAT updates, property management, basic I/O, -persistence, and storage options can be found in this module. - -All parameters to the modules are passed by reference. -In particular, this means that string values are passed to the module -layer as (str *) -and we have to de-reference them before entering the gdk library. -(Actual a design error in gdk to differentiate passing int/str) -This calls for knowledge on the underlying BAT types`s -@- -@{ -@= derefStr -{ if( @1->@2type >= TYPE_str && ATOMstorage(@1->@2type) >= TYPE_str) - { if(@3== 0 || *(str*)@3==0) @3 = (str)str_nil; - else @3 = *(str *)@3; -}} -@- -The code speaks for itself - -#command access( b:bat[:any_1,:any_2], mode:int) :bat[:any_1,:any_2] -#address BKCaccess; - -#command setSequenceBase( b:bat[:oid,:any_1], base:oid):void -#address BKCsetSequenceBase -#comment "Set the sequence base for the void column of a BAT."; -@mal -module bat; -command attach(tt:int, heapfile:str) :bat[:void,:any_1] -address BKCattach -comment "Returns a new BAT with dense head and tail of the given type and uses - the given file to initialize the tail. The file will be owned by the - server." - -command densebat(size:wrd) :bat[:void,:void] -address BKCdensebat -comment "Creates a new [void,void] BAT of size 'size'." - -command reverse(b:bat[:any_1,:any_2]) :bat[:any_2,:any_1] -address BKCreverse -comment "Returns the reverse view of a BAT (head is tail and tail is head). - BEWARE no copying is involved; input and output refer to the - same object!"; - -command mirror(b:bat[:any_1,:any_2]) :bat[:any_1,:any_1] -address BKCmirror -comment "Returns the head-mirror image of a BAT (two head columns)."; - -command order(b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] -address BKCorder -comment "Sorts the BAT itself on the head, in place. "; -command orderReverse(b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] -address BKCorder_rev -comment "Reverse sorts the BAT itself on the head, in place. "; - -command revert(b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] -address BKCrevert -comment "Puts all BUNs in a BAT in reverse order. (Belongs to the - BAT sequence module)"; - -@+ BAT properties -Properties of BATs not necessarily require loading the BAT completely. -The BAT identifier can be used to access the descriptors. -These properties can be inspected with the -@emph{info(BAT[:any_1,:any_2]) :bat[str,str] } command: -@verbatim -> car_age.info.print; -#---------------------------------# -# BAT: tmp_31 # -# (str) (str) # -#---------------------------------# -[ "batId", "car_age" ] # logical bat name -[ "batCacheid", "26" ] # BBP index -[ "batParentid", "0" ] # set if a BAT is a view -[ "head", "void" ] # physical head-type -[ "tail", "int" ] # physical tail-type -[ "batPersistence", "persistent" ] # transient/session/persistent -[ "batRestricted", "updatable" ] # read-only/append-only/updatable -[ "batDirty", "clean" ] # clean/dirty -[ "batRefcnt", "1" ] # physical refcount -[ "batLRefcnt", "1" ] # logical refcount (total) -[ "batPlevel", "1" ] # logical refcount (persistent part) -[ "batSet", "0" ] # [head,tail] combinations are unique -[ "batCopiedtodisk", "1" ] # has been saved or not -@end verbatim - -Per column, a number of properties are kept. We only show the head-properties; the tail properties -have the first character of their named replaced by 't' (@emph{sorted}, @emph{tdense}, etc.): - -@verbatim -[ "hsorted", "1" ] # column is known to be sorted -[ "hdense", "1" ] # column is known to be densely ascended -[ "hseqbase", "0@0" ] # if densely ascending first value -@end verbatim - -As described in the @[<a href="www/gdk.html#mod_1_3_0">GDK Technical Reference</a>@, -BATs store their data in one to six heaps. For each column type that is @emph{variable-sized} - -like @emph{str} - another -heap might be present (@emph{hheap} and @emph{theap}). - -@verbatim -[ "head.free", "400004" ] # occupied size in bytes -[ "head.size", "400012" ] # allocated size in bytes -[ "head.maxsize", "400012" ] # reserver virtual memory in bytes -[ "head.storage", "malloced" ] # malloced/mmap/priv -@end verbatim - -Properties steer the algorithms that Monet uses to execute algebra command. For instance, -the @emph{find(bat[:any_1,:any_2] b, :any_1) :any_2} that looks up a tail value by head, -uses binary search if and only if the head column is sorted (in other cases, hash-lookup -and scan are execution options). - -Sometimes new (extension) code contains bugs in the property management, leaving false -properties on produced BATs. You can imagine that later on, this leads to additional -bugs, as e,g, the binary search algorithms will yield erroneous results on a non-sorted -sequence. - -@mal -command info ( b:bat[:any_1,:any_2]) :bat[:str,:str] -address BKCinfo -comment "Produce a BAT containing info about a BAT in [attribute,value] format. - It contains all properties of the BAT record. See the BAT documentation - in GDK for more information."; - -command getSize ( b:bat[:any_1,:any_2]) :lng -address BKCbatsize -comment "Calculate the size of the BAT descriptor, heaps and indices in bytes."; - -command getMemorySize ( b:bat[:any_1,:any_2]) :lng -address BKCbatvmsize -comment "Calculate the size of the BAT heaps and indices in bytes -rounded to the memory page size (see bbp.getPageSize())."; - -command getDiskSize ( b:bat[:any_1,:any_2]) :lng -address BKCbatdisksize -comment "Approximate size of the (persistent) BAT heaps as stored on disk -in pages of 512 bytes. Indices are not included, as they only live temporarily -in virtual memory."; - -command getCapacity(b:bat[:any_1,:any_2]):lng -address BKCgetCapacity -comment "Returns the current allocation size (in max number of elements) of a BAT."; - -command getHeadType(b:bat[:any_1,:any_2] ) :str -address BKCgetHeadType -comment "Returns the type of the head column of a BAT, as an integer type number."; - -command getTailType( b:bat[:any_1,:any_2] ) :str -address BKCgetTailType -comment "Returns the type of the tail column of a BAT, as an integer type number."; - -command getRole ( bid:bat[:any_1,:any_2] ) :str -address BKCgetRole -comment "Returns the rolename of the head column of a BAT."; - -command setKey( b:bat[:any_1,:any_2], mode:bit) :bat[:any_1,:any_2] -address BKCsetkey -comment "Sets the 'key' property of the head column to 'mode'. In 'key' mode, - the kernel will silently block insertions that cause a duplicate - entries in the head column. KNOWN BUG:when 'key' is set to TRUE, this - function does not automatically eliminate duplicates. - Use b := b.kunique;"; - -command isaKey( b:bat[:any_1,:any_2]) :bit -address BKCgetKey -comment "return whether the head column of a BAT is unique (key)."; - -command setSet( b:bat[:any_1,:any_2], mode:bit) :bat[:any_1,:any_2] -address BKCsetSet -comment "Sets the 'set' property on this BAT to 'mode'. In 'set' mode, - the kernel will silently block insertions that cause a duplicate - BUN [head,tail] entries in the BAT. KNOWN BUG:when 'set' is set - to TRUE, this function does not automatically eliminate duplicates. - Use b := b.sunique; Returns the BAT itself."; - -command isaSet( b:bat[:any_1,:any_1]) :bit -address BKCisaSet -comment "return whether the BAT mode is set to unique."; - -command setAccess( b:bat[:any_1,:any_2], mode:str) :bat[:any_1,:any_2] -address BKCsetAccess -comment "Try to change the update access priviliges - to this BAT. Mode: - r[ead-only] - allow only read access. - a[append-only] - allow reads and update. - w[riteable] - allow all operations. - BATs are updatable by default. On making a BAT read-only, - all subsequent updates fail with an error message.Returns - the BAT itself."; - -command setAppendMode( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] -address BKCsetAppendMode -comment "Change access privilige of BAT to append only"; - -command setReadMode( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] -address BKCsetReadMode -comment "Change access privilige of BAT to read only"; - -command setWriteMode( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] -address BKCsetWriteMode -comment "Change access privilige of BAT to read and write"; - -command getAccess( b:bat[:any_1,:any_2]):str -address BKCgetAccess -comment "return the access mode attached to this BAT as a character."; - -command hasAppendMode( b:bat[:any_1,:any_2]):bit -address BKChasAppendMode -comment "return true if to this BAT is append only."; - -command hasWriteMode( b:bat[:any_1,:any_2]):bit -address BKChasWriteMode -comment "return true if to this BAT is read and write."; - -command hasReadMode( b:bat[:any_1,:any_2]):bit -address BKChasReadMode -comment "return true if to this BAT is read only."; - - -command getSequenceBase( b:bat[:oid,:any_1]):oid -address BKCgetSequenceBase -comment "Get the sequence base for the void column of a BAT."; - -command setSorted(b:bat[:any_1,:any_2]) :bit -address BKCsetSorted -comment "Assure BAT is ordered on the head."; - -command isSorted(b:bat[:any_1,:any_2]) :bit -address BKCisSorted -comment "Returns whether a BAT is ordered on head or not."; -command isSortedReverse(b:bat[:any_1,:any_2]) :bit -address BKCisSortedReverse -comment "Returns whether a BAT is ordered on head or not."; - -command getStorageSize(b:bat[:any_1,:any_2]) :lng -address BKCgetStorageSize -comment "Determine the total space (in bytes) reserved for a BAT."; - -command getSpaceUsed(b:bat[:any_1,:any_2]) :lng -address BKCgetSpaceUsed -comment "Determine the total space (in bytes) occupied by a BAT."; - -@- BAT updates -Update commands come in many disguises. Note that we don;t return -the BAT id, but merely a success/failure code. -@mal -command insert(b:bat[:any_1,:any_2], src:bat[:any_1,:any_2]):bat[:any_1,:any_2] -address BKCinsert_bat -comment "Insert all BUNs of the second BAT into the first."; - -command insert(b:bat[:any_1,:any_2], src:bat[:any_1,:any_2], force:bit):bat[:any_1,:any_2] -address BKCinsert_bat_force -comment "Insert all BUNs of the second BAT into the first."; - -command insert(b:bat[:any_1,:any_2], h:any_1, t:any_2) :bat[:any_1,:any_2] -address BKCinsert_bun -comment "Insert one BUN[h,t] in a BAT."; - -command insert(b:bat[:any_1,:any_2], h:any_1, t:any_2, force:bit) :bat[:any_1,:any_2] -address BKCinsert_bun_force -comment "Insert one BUN[h,t] in a BAT."; - -@+ -@mal -command replace(b:bat[:any_1, :any_2], src:bat[:any_1,:any_2]) :bat[:any_1,:any_2] _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
