Changeset: 9ac831deacb3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9ac831deacb3
Modified Files:
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/kernel/bat5.h
        monetdb5/modules/kernel/bat5.mal
Branch: graph1
Log Message:

Add the operator bat.getCount() to retrieve the cardinality of a bat


diffs (48 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
@@ -496,6 +496,19 @@ BKCgetColumnType(str *res, const bat *bi
 }
 
 str
+BKCgetCount(lng *res, const bat *bid)
+{
+       *res = lng_nil;
+       if (BBPcheck(*bid, "bat.getCount")) {
+               BAT *b = BBPquickdesc(*bid, 0);
+
+               if (b != NULL)
+                       *res = (lng) BATcount(b);
+       }
+       return MAL_SUCCEED;
+}
+
+str
 BKCgetRole(str *res, const bat *bid)
 {
        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
@@ -29,6 +29,7 @@ mal_export str BKCbun_inplace_force(bat 
 mal_export str BKCbat_inplace_force(bat *r, const bat *bid, const bat *rid, 
const bat *uid, const bit *force);
 mal_export str BKCgetCapacity(lng *res, const bat *bid);
 mal_export str BKCgetColumnType(str *res, const bat *bid);
+mal_export str BKCgetCount(lng *res, const bat *bid);
 mal_export str BKCgetRole(str *res, const bat *bid);
 mal_export str BKCsetkey(bat *res, const bat *bid, const bit *param);
 mal_export str BKCisSorted(bit *res, const bat *bid);
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
@@ -77,6 +77,10 @@ command getCapacity(b:bat[:any_1]):lng
 address BKCgetCapacity
 comment "Returns the current allocation size (in max number of elements) of a 
BAT.";
 
+command getCount(b:bat[:any_1]):lng
+address BKCgetCount
+comment "Returns the current tuple count of a BAT.";
+
 command getColumnType( b:bat[:any_1] ) :str 
 address BKCgetColumnType 
 comment "Returns the type of the tail column of a BAT, as an integer type 
number.";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to