Changeset: b5365174ffe3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b5365174ffe3
Modified Files:
monetdb5/modules/kernel/bat5.c
monetdb5/modules/kernel/bat5.h
monetdb5/modules/kernel/bat5.mal
monetdb5/modules/mal/Tests/inspect05.stable.out.int128
monetdb5/scheduler/Tests/memo01.mal
monetdb5/scheduler/Tests/memo01.stable.out
monetdb5/scheduler/Tests/memo02.mal
monetdb5/scheduler/Tests/memo02.stable.out
Branch: default
Log Message:
Simplify MAL interface and use headless semantics.
The info() command still provides the details for further analysis.
diffs (truncated from 455 to 300 lines):
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
@@ -343,73 +343,6 @@ CMDinfo(BAT **ret1, BAT **ret2, BAT *b)
return GDK_SUCCEED;
}
-#define ROUND_UP(x,y) ((y)*(((x)+(y)-1)/(y)))
-
-static int
-CMDbatdisksize(lng *tot, BAT *b)
-{
- size_t blksize = 512;
- size_t size = 0;
-
- if (!isVIEW(b)) {
- size += ROUND_UP(b->H->heap.free, blksize);
- size += ROUND_UP(b->T->heap.free, blksize);
- if (b->H->vheap)
- size += ROUND_UP(b->H->vheap->free, blksize);
- if (b->T->vheap)
- size += ROUND_UP(b->T->vheap->free, blksize);
- }
- *tot = size;
- return GDK_SUCCEED;
-}
-
-static int
-CMDbatvmsize(lng *tot, BAT *b)
-{
- size_t blksize = MT_pagesize();
- size_t size = 0;
-
- if (!isVIEW(b)) {
- BUN cnt = BATcapacity(b);
-
- size += ROUND_UP(b->H->heap.size, blksize);
- size += ROUND_UP(b->T->heap.size, blksize);
- if (b->H->vheap)
- size += ROUND_UP(b->H->vheap->size, blksize);
- if (b->T->vheap)
- size += ROUND_UP(b->T->vheap->size, blksize);
- if (b->H->hash)
- size += ROUND_UP(sizeof(BUN) * cnt, blksize);
- if (b->T->hash)
- size += ROUND_UP(sizeof(BUN) * cnt, blksize);
- }
- *tot = size;
- return GDK_SUCCEED;
-}
-
-static int
-CMDbatsize(lng *tot, BAT *b, int force)
-{
- size_t size = 0;
-
- if ( force || !isVIEW(b)) {
- BUN cnt = BATcapacity(b);
-
- size += b->H->heap.size;
- size += b->T->heap.size;
- if (b->H->vheap)
- size += b->H->vheap->size;
- if (b->T->vheap)
- size += b->T->vheap->size;
- if (b->H->hash)
- size += sizeof(BUN) * cnt;
- if (b->T->hash)
- size += sizeof(BUN) * cnt;
- }
- *tot = size;
- return GDK_SUCCEED;
-}
-
/*
* BBP Management, IO
*/
@@ -1262,7 +1195,7 @@ BKCisSorted(bit *res, const bat *bid)
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "bat.isSorted", RUNTIME_OBJECT_MISSING);
}
- *res = BATordered(b);
+ *res = BATordered(BATmirror(b));
BBPreleaseref(b->batCacheid);
return MAL_SUCCEED;
}
@@ -1275,7 +1208,7 @@ BKCisSortedReverse(bit *res, const bat *
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "bat.isSorted", RUNTIME_OBJECT_MISSING);
}
- *res = BATordered_rev(b);
+ *res = BATordered_rev(BATmirror(b));
BBPreleaseref(b->batCacheid);
return MAL_SUCCEED;
}
@@ -1442,88 +1375,38 @@ BKCinfo(bat *ret1, bat *ret2, const bat
throw(MAL, "BKCinfo", GDK_EXCEPTION);
}
-str
-BKCbatdisksize(lng *tot, const bat *bid){
- BAT *b;
- if ((b = BATdescriptor(abs(*bid))) == NULL)
- throw(MAL, "bat.getDiskSize", RUNTIME_OBJECT_MISSING);
- CMDbatdisksize(tot,b);
- BBPreleaseref(*bid);
- return MAL_SUCCEED;
-}
+// get the actual size of all constituents, also for views
+#define ROUND_UP(x,y) ((y)*(((x)+(y)-1)/(y)))
str
-BKCbatvmsize(lng *tot, const bat *bid){
+BKCgetSize(lng *tot, const bat *bid){
BAT *b;
+ lng size = 0;
+ lng blksize = (lng) MT_pagesize();
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "bat.getDiskSize", RUNTIME_OBJECT_MISSING);
}
- CMDbatvmsize(tot,b);
+
+ size = sizeof (bat);
+ if ( !isVIEW(b)) {
+ BUN cnt = BATcapacity(b);
+ size += ROUND_UP(b->H->heap.free, blksize);
+ size += ROUND_UP(b->T->heap.free, blksize);
+ if (b->H->vheap)
+ size += ROUND_UP(b->H->vheap->free, blksize);
+ if (b->T->vheap)
+ size += ROUND_UP(b->T->vheap->free, blksize);
+ if (b->H->hash)
+ size += ROUND_UP(sizeof(BUN) * cnt, blksize);
+ if (b->T->hash)
+ size += ROUND_UP(sizeof(BUN) * cnt, blksize);
+ size += IMPSimprintsize(b);
+ }
+ *tot = size;
BBPreleaseref(*bid);
return MAL_SUCCEED;
}
-str
-BKCbatsize(lng *tot, const bat *bid){
- BAT *b;
- if ((b = BATdescriptor(*bid)) == NULL) {
- throw(MAL, "bat.getDiskSize", RUNTIME_OBJECT_MISSING);
- }
- CMDbatsize(tot,b, FALSE);
- BBPreleaseref(*bid);
- return MAL_SUCCEED;
-}
-
-str
-BKCgetStorageSize(lng *tot, const bat *bid)
-{
- BAT *b;
-
- if ((b = BATdescriptor(*bid)) == NULL)
- throw(MAL, "bat.getStorageSize", RUNTIME_OBJECT_MISSING);
- CMDbatsize(tot,b,TRUE);
- BBPreleaseref(b->batCacheid);
- return MAL_SUCCEED;
-}
-str
-BKCgetSpaceUsed(lng *tot, const bat *bid)
-{
- BAT *b;
- size_t size = BATSTORESIZE;
-
- if ((b = BATdescriptor(*bid)) == NULL)
- throw(MAL, "bat.getSpaceUsed", RUNTIME_OBJECT_MISSING);
-
- if (!isVIEW(b)) {
- BUN cnt = BATcount(b);
-
- size += headsize(b, cnt);
- size += tailsize(b, cnt);
- /* the upperbound is used for the heaps */
- if (b->H->vheap)
- size += b->H->vheap->size;
- if (b->T->vheap)
- size += b->T->vheap->size;
- if (b->H->hash)
- size += sizeof(BUN) * cnt;
- if (b->T->hash)
- size += sizeof(BUN) * cnt;
- }
- *tot = size;
- BBPreleaseref(b->batCacheid);
- return MAL_SUCCEED;
-}
-
-str
-BKCgetStorageSize_str(lng *tot, str batname)
-{
- int bid = BBPindex(batname);
-
- if (bid == 0)
- throw(MAL, "bat.getStorageSize", RUNTIME_OBJECT_MISSING);
- return BKCgetStorageSize(tot, &bid);
-}
-
/*
* Synced BATs
*/
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
@@ -81,12 +81,7 @@ bat5_export str BKCisTransient(bit *res,
bat5_export str BKCsetAccess(bat *res, const bat *bid, const char * const
*param);
bat5_export str BKCgetAccess(str *res, const bat *bid);
bat5_export str BKCinfo(bat *ret1, bat *ret2, const bat *bid);
-bat5_export str BKCbatsize(lng *tot, const bat *bid);
-bat5_export str BKCbatvmsize(lng *tot, const bat *bid);
-bat5_export str BKCbatdisksize(lng *tot, const bat *bid);
-bat5_export str BKCgetStorageSize(lng *tot, const bat *bid);
-bat5_export str BKCgetSpaceUsed(lng *tot, const bat *bid);
-bat5_export str BKCgetStorageSize_str(lng *tot, str batname);
+bat5_export str BKCgetSize(lng *tot, const bat *bid);
bat5_export str BKCisSynced(bit *ret, const bat *bid1, const bat *bid2);
bat5_export str BKCsetColumn(void *r, const bat *bid, const char * const
*tname);
bat5_export str BKCsetColumns(void *r, const bat *bid, const char * const
*hname, const char * const *tname);
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
@@ -50,24 +50,14 @@ comment "Puts all BUNs in a BAT in rever
command info ( b:bat[:oid,:any_2]) (:bat[:oid,:str], :bat[:oid,:str])
address BKCinfo
-comment "Produce a BAT containing info about a BAT in [attribute,value]
format.
+comment "Produce a table containing information 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[:oid,:any_2]) :lng
-address BKCbatsize
-comment "Calculate the size of the BAT descriptor, heaps and indices in
bytes.";
-
-command getMemorySize ( b:bat[:oid,: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[:oid,: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 getSize ( b:bat[:oid,:any_1]) :lng
+address BKCgetSize
+comment "Calculate the actual size of the BAT descriptor, heaps, hashes and
imprint indices in bytes
+ rounded to the memory page size (see bbp.getPageSize()).";
command getCapacity(b:bat[:oid,:any_2]):lng
address BKCgetCapacity
@@ -115,20 +105,12 @@ command getSequenceBase( b:bat[:oid,:any
address BKCgetSequenceBase
comment "Get the sequence base for the void column of a BAT.";
-command isSorted(b:bat[:oid,:any_2]) :bit
+command isSorted(b:bat[:oid,:any_1]) :bit
address BKCisSorted
-comment "Returns whether a BAT is ordered on head or not.";
-command isSortedReverse(b:bat[:oid,:any_2]) :bit
+comment "Returns true if BAT values are ordered.";
+command isSortedReverse(b:bat[:oid,:any_1]) :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.";
+comment "Returns true if BAT values are reversely ordered.";
command insert(b:bat[:any_1,:any_2], src:bat[:any_1,:any_2]):bat[:any_1,:any_2]
address BKCinsert_bat
diff --git a/monetdb5/modules/mal/Tests/inspect05.stable.out.int128
b/monetdb5/modules/mal/Tests/inspect05.stable.out.int128
--- a/monetdb5/modules/mal/Tests/inspect05.stable.out.int128
+++ b/monetdb5/modules/mal/Tests/inspect05.stable.out.int128
@@ -40,31 +40,23 @@ end main;
[ "append", "command", "bat",
"(i:bat[:oid,:any_1],u:any_1):bat[:oid,:any_1] ",
"BKCappend_val_wrap;"
]
[ "append", "command", "bat",
"(i:bat[:any_1,:any_2],u:bat[:any_1,:any_2],force:bit):bat[:any_1,:any_2] ",
"BKCappend_force_wrap;"
]
[ "append", "command", "bat",
"(i:bat[:any_1,:any_2],u:bat[:any_1,:any_2]):bat[:any_1,:any_2] ",
"BKCappend_wrap;"
]
-[ "attach", "command", "bat",
"(tt:int,heapfile:str):bat[:void,:any_1] ",
"BKCattach;"
]
+[ "attach", "command", "bat", "(tt:int,heapfile:str):bat[:oid,:any_1]
", "BKCattach;" ]
[ "delete", "command", "bat",
"(b:bat[:any_1,:any_2],src:bat[:any_1,:any_2]):bat[:any_1,:any_2] ",
"BKCdelete_bat_bun;"
]
[ "delete", "command", "bat",
"(b:bat[:any_1,:any_2]):bat[:any_1,:any_2] ",
"BKCdelete_all;"
]
[ "delete", "command", "bat",
"(b:bat[:any_1,:any_2],h:any_1):bat[:any_1,:any_2] ",
"BKCdelete;"
]
[ "delete", "command", "bat",
"(b:bat[:any_1,:any_2],h:any_1,t:any_2):bat[:any_1,:any_2] ",
"BKCdelete_bun;"
]
-[ "deleteHead", "command", "bat",
"(b:bat[:any_1,:any_2],src:bat[:any_1,:any]):void ",
"BKCdelete_bat;" ]
-[ "densebat", "command", "bat",
"(size:wrd):bat[:void,:void] ",
"BKCdensebat;"
]
-[ "getAccess", "command", "bat",
"(b:bat[:any_1,:any_2]):str ",
"BKCgetAccess;" ]
+[ "densebat", "command", "bat", "(sz:wrd):bat[:oid,:oid] ",
"BKCdensebat;" ]
+[ "getAccess", "command", "bat", "(b:bat[:oid,:any_1]):str ",
"BKCgetAccess;" ]
[ "getAlpha", "command", "bat",
"(b:bat[:any_1,:any_2]):bat[:any_1,:any_2] ",
"BKCgetAlpha;" ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list