Changeset: 5f61fae233b0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5f61fae233b0
Modified Files:
        monetdb5/mal/Tests/tst1200.mal
        monetdb5/mal/Tests/tst1200.stable.out
        monetdb5/mal/Tests/tst1205.mal
        monetdb5/mal/Tests/tst1205.stable.out
        monetdb5/mal/Tests/tst2510.mal
        monetdb5/mal/Tests/tst2510.stable.out
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/kernel/bat5.h
        monetdb5/modules/kernel/bat5.mal
        monetdb5/tests/suite_00/Tests/test_15.mal
        monetdb5/tests/suite_00/Tests/test_15.stable.out
Branch: default
Log Message:

Reduce the MAL interface
Remove some auxillary functions.
Use the tail as the target for setKey and isaKey


diffs (truncated from 336 to 300 lines):

diff --git a/monetdb5/mal/Tests/tst1200.mal b/monetdb5/mal/Tests/tst1200.mal
--- a/monetdb5/mal/Tests/tst1200.mal
+++ b/monetdb5/mal/Tests/tst1200.mal
@@ -511,7 +511,7 @@ io.print("daytime_bat,bh_a,dh_a,fh_a,hh_
 ## create timestamps in bulk from the above bats with dates, daytimes and 
tzones
 # Skipped due to coercion implication
        kh_a:bat[:oid,:timestamp] := 
mal.multiplex("mtime","timestamp",date_bat,daytime_bat,tzone_bat);
-       timestamp_bat:=kh_a; bat.setWriteMode(kh_a);
+       timestamp_bat:=kh_a; bat.setAccess(kh_a,"w");
 #var timestamp_bat := 
[timestamp](date_bat,daytime_bat,tzone_bat).access(BAT_WRITE);
 ## KILL
 ## var timestamp_now := timestamp(epoch());
diff --git a/monetdb5/mal/Tests/tst1200.stable.out 
b/monetdb5/mal/Tests/tst1200.stable.out
--- a/monetdb5/mal/Tests/tst1200.stable.out
+++ b/monetdb5/mal/Tests/tst1200.stable.out
@@ -1064,7 +1064,7 @@ exit lf_a;
 # Skipped due to coercion implication 
     kh_a:bat[:oid,:timestamp]  := 
mal.manifold("mtime","timestamp",date_bat,daytime_bat,tzone_bat);
     timestamp_bat := kh_a;
-    bat.setWriteMode(kh_a);
+    bat.setAccess(kh_a,"w");
 #var timestamp_bat := 
[timestamp](date_bat,daytime_bat,tzone_bat).access(BAT_WRITE); 
 ## KILL 
 ## var timestamp_now := timestamp(epoch()); 
diff --git a/monetdb5/mal/Tests/tst1205.mal b/monetdb5/mal/Tests/tst1205.mal
--- a/monetdb5/mal/Tests/tst1205.mal
+++ b/monetdb5/mal/Tests/tst1205.mal
@@ -329,6 +329,6 @@ io.print("daytime_bat,bh_a,dh_a,fh_a,hh_
 ## create timestamps in bulk from the above bats with dates, daytimes and 
tzones
 # Skipped due to coercion implication
        kh_a:bat[:oid,:timestamp] := 
mal.multiplex("mtime","timestamp",date_bat,daytime_bat,tzone_bat);
-       timestamp_bat:=kh_a; bat.setWriteMode(kh_a);
+       timestamp_bat:=kh_a; bat.setAccess(kh_a,"w");
 #var timestamp_bat := 
[timestamp](date_bat,daytime_bat,tzone_bat).access(BAT_WRITE);
 ## KILL
diff --git a/monetdb5/mal/Tests/tst1205.stable.out 
b/monetdb5/mal/Tests/tst1205.stable.out
--- a/monetdb5/mal/Tests/tst1205.stable.out
+++ b/monetdb5/mal/Tests/tst1205.stable.out
@@ -666,7 +666,7 @@ exit lf_a;
 # Skipped due to coercion implication 
     kh_a:bat[:oid,:timestamp]  := 
mal.manifold("mtime","timestamp",date_bat,daytime_bat,tzone_bat);
     timestamp_bat := kh_a;
-    bat.setWriteMode(kh_a);
+    bat.setAccess(kh_a,"w");
 #var timestamp_bat := 
[timestamp](date_bat,daytime_bat,tzone_bat).access(BAT_WRITE); 
 ## KILL 
 end main;
diff --git a/monetdb5/mal/Tests/tst2510.mal b/monetdb5/mal/Tests/tst2510.mal
--- a/monetdb5/mal/Tests/tst2510.mal
+++ b/monetdb5/mal/Tests/tst2510.mal
@@ -2,7 +2,7 @@
 
 factory tryme():bit;
        b:= bat.new(:oid,:int);
-    bat.setWriteMode(b);
+    bat.setAccess(b,"w");
 barrier always:= true;
     yield always;
     redo always;
diff --git a/monetdb5/mal/Tests/tst2510.stable.out 
b/monetdb5/mal/Tests/tst2510.stable.out
--- a/monetdb5/mal/Tests/tst2510.stable.out
+++ b/monetdb5/mal/Tests/tst2510.stable.out
@@ -27,7 +27,7 @@ stdout of test 'tst2510` in directory 'm
 #end tryme;
 factory user.tryme():bit;
     b := bat.new(:oid,:int);
-    bat.setWriteMode(b);
+    bat.setAccess(b,"w");
 barrier always := true;
     yield tryme := always;
     redo always;
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -1248,7 +1248,7 @@ BKCsetkey(bat *res, const bat *bid, cons
        if ((b = BATdescriptor(*bid)) == NULL) {
                throw(MAL, "bat.setKey", RUNTIME_OBJECT_MISSING);
        }
-       BATkey(b, *param ? BOUND2BTRUE :FALSE);
+       BATkey(BATmirror(b), *param ? BOUND2BTRUE :FALSE);
        *res = b->batCacheid;
        BBPkeepref(b->batCacheid);
        return MAL_SUCCEED;
@@ -1291,21 +1291,15 @@ BKCgetKey(bit *ret, const bat *bid)
 {
        BAT *b;
 
-       if ((b = BATdescriptor(*bid)) == NULL) {
+       if ((b = BATdescriptor(*bid)) == NULL) 
                throw(MAL, "bat.setPersistence", RUNTIME_OBJECT_MISSING);
-       }
-       /* we must take care of the special case of a nil column
-        * (TYPE_void,seqbase=nil): such nil columns never set hkey (and
-        * BUNins will never invalidate it if set) yet a nil column of a
-        * BAT with <= 1 entries does not contain doubles => return TRUE.
-        */
        if (BATcount(b) <= 1) {
                *ret = TRUE;
        } else {
-               if (!b->hkey) {
-                       BATderiveHeadProps(b, 1);
+               if (!b->tkey) {
+                       BATderiveHeadProps(BATmirror(b), 1);
                }
-               *ret = b->hkey ? TRUE : FALSE;
+               *ret = b->tkey ? TRUE : FALSE;
        }
        BBPreleaseref(b->batCacheid);
        return MAL_SUCCEED;
@@ -1369,81 +1363,6 @@ BKCisTransient(bit *res, const bat *bid)
 }
 
 str
-BKCsetWriteMode(bat *res, const bat *bid)
-{
-       BAT *b;
-
-    if ((b = BATdescriptor(*bid)) == NULL)
-        throw(MAL, "bat.setWriteMode", RUNTIME_OBJECT_MISSING);
-       if ((b = setaccess(b, BAT_WRITE)) == NULL)
-               throw(MAL, "bat.setWriteMode", OPERATION_FAILED);
-       BBPkeepref(*res = b->batCacheid);
-       return MAL_SUCCEED;
-}
-
-str
-BKChasWriteMode(bit *res, const bat *bid)
-{
-       BAT *b;
-
-    if ((b = BATdescriptor(*bid)) == NULL)
-        throw(MAL, "bat.setWriteMode", RUNTIME_OBJECT_MISSING);
-       *res = BATgetaccess(b) == BAT_WRITE;
-       BBPreleaseref(b->batCacheid);
-       return MAL_SUCCEED;
-}
-
-str
-BKCsetReadMode(bat *res, const bat *bid)
-{
-       BAT *b;
-
-    if ((b = BATdescriptor(*bid)) == NULL)
-        throw(MAL, "bat.setReadMode", RUNTIME_OBJECT_MISSING);
-       if ((b = setaccess(b, BAT_READ)) == NULL)
-               throw(MAL, "bat.setReadMode", OPERATION_FAILED);
-       BBPkeepref(*res = b->batCacheid);
-       return MAL_SUCCEED;
-}
-
-str
-BKChasReadMode(bit *res, const bat *bid)
-{
-       BAT *b;
-
-    if ((b = BATdescriptor(*bid)) == NULL)
-        throw(MAL, "bat.setReadMode", RUNTIME_OBJECT_MISSING);
-       *res = BATgetaccess(b) == BAT_READ;
-       BBPreleaseref(b->batCacheid);
-       return MAL_SUCCEED;
-}
-
-str
-BKCsetAppendMode(bat *res, const bat *bid)
-{
-       BAT *b;
-
-    if ((b = BATdescriptor(*bid)) == NULL)
-        throw(MAL, "bat.setAppendMode", RUNTIME_OBJECT_MISSING);
-       if ((b = setaccess(b, BAT_APPEND)) == NULL)
-               throw(MAL, "bat.setAppendMode", OPERATION_FAILED);
-       BBPkeepref(*res = b->batCacheid);
-       return MAL_SUCCEED;
-}
-
-str
-BKChasAppendMode(bit *res, const bat *bid)
-{
-       BAT *b;
-
-    if ((b = BATdescriptor(*bid)) == NULL)
-        throw(MAL, "bat.setAppendMode", RUNTIME_OBJECT_MISSING);
-       *res = BATgetaccess(b) == BAT_APPEND;
-       BBPreleaseref(b->batCacheid);
-       return MAL_SUCCEED;
-}
-
-str
 BKCsetAccess(bat *res, const bat *bid, const char * const *param)
 {
        BAT *b;
diff --git a/monetdb5/modules/kernel/bat5.h b/monetdb5/modules/kernel/bat5.h
--- a/monetdb5/modules/kernel/bat5.h
+++ b/monetdb5/modules/kernel/bat5.h
@@ -109,14 +109,6 @@ bat5_export str BKCshrinkBAT(bat *ret, c
 bat5_export str BKCreuseBAT(bat *ret, const bat *bid, const bat *did);
 bat5_export str BKCshrinkBATmap(bat *ret, const bat *bid, const bat *did);
 bat5_export str BKCreuseBATmap(bat *ret, const bat *bid, const bat *did);
-
-bat5_export str BKCsetWriteMode(bat *res, const bat *bid) ;
-bat5_export str BKChasWriteMode(bit *res, const bat *bid);
-bat5_export str BKCsetReadMode(bat *res, const bat *bid) ;
-bat5_export str BKChasReadMode(bit *res, const bat *bid);
-bat5_export str BKCsetAppendMode(bat *res, const bat *bid) ;
-bat5_export str BKChasAppendMode(bit *res, const bat *bid);
-
 bat5_export str BKCmergecand(bat *ret, const bat *aid, const bat *bid);
 bat5_export str BKCintersectcand(bat *ret, const bat *aid, const bat *bid);
 #endif /*_BAT_H_*/
diff --git a/monetdb5/modules/kernel/bat5.mal b/monetdb5/modules/kernel/bat5.mal
--- a/monetdb5/modules/kernel/bat5.mal
+++ b/monetdb5/modules/kernel/bat5.mal
@@ -16,15 +16,15 @@
 # All Rights Reserved.
 
 module bat;
-command attach(tt:int, heapfile:str) :bat[:void,:any_1]
+command attach(tt:int, heapfile:str) :bat[:oid,: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."
+        server.";
 
-command densebat(size:wrd) :bat[:oid,:oid]
+command densebat(sz:wrd) :bat[:oid,:oid]
 address BKCdensebat
-comment "Creates a new [void,void] BAT of size 'size'."
+comment "Creates a new [void,void] BAT of size 'sz'.";
 
 command reverse(b:bat[:any_1,:any_2]) :bat[:any_2,:any_1] 
 address BKCreverse
@@ -85,66 +85,40 @@ command getRole ( bid:bat[:oid,:any_2] )
 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] 
+command setKey( b:bat[:oid,:any_2], mode:bit) :bat[:oid,:any_2] 
 address BKCsetkey
-comment "Sets the 'key' property of the head column to 'mode'. In 'key' mode, 
+comment "Sets the 'key' property of the tail 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;";
+               function does not automatically eliminate duplicates. ";
 
-command isaKey( b:bat[:any_1,:any_2]) :bit 
+command isaKey( b:bat[:oid,:any_1]) :bit 
 address BKCgetKey
-comment "return whether the head column of a BAT is unique (key).";
+comment "Return whether the column tail values are unique (key).";
 
-command setAccess( b:bat[:any_1,:any_2], mode:str) :bat[:any_1,:any_2]
+command setAccess( b:bat[:oid,:any_1], mode:str) :bat[:oid,:any_1]
 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.";
+        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 
+command getAccess( b:bat[:oid,:any_1]):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.";
-
+comment "Return the access mode attached to this BAT as a character.";
 
 command getSequenceBase( b:bat[:oid,:any_1]):oid 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to