Changeset: 31eaf8312a35 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=31eaf8312a35
Modified Files:
        monetdb5/modules/kernel/algebra.mx
Branch: default
Log Message:

Add BAT slice selection based on oids.


diffs (54 lines):

diff --git a/monetdb5/modules/kernel/algebra.mx 
b/monetdb5/modules/kernel/algebra.mx
--- a/monetdb5/modules/kernel/algebra.mx
+++ b/monetdb5/modules/kernel/algebra.mx
@@ -171,6 +171,10 @@ command fragment ( b: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.";
@@ -1064,6 +1068,7 @@ algebra_export str ALGlike(int *ret, int
 algebra_export str ALGslice(int *ret, bat *bid, lng *start, lng *end);
 algebra_export str ALGslice_int(int *ret, bat *bid, int *start, int *end);
 algebra_export str ALGslice_wrd(int *ret, bat *bid, wrd *start, wrd *end);
+algebra_export str ALGslice_oid(int *ret, bat *bid, oid *start, oid *end);
 algebra_export str ALGposition(wrd *retval, int *bid, ptr val);
 algebra_export str ALGpositionBUN(wrd *retval, int *bid, ptr val, ptr tval);
 algebra_export str doALGfetch(ptr ret, BAT *b, lng *pos);
@@ -3386,6 +3391,31 @@ ALGslice_wrd(int *ret, bat *bid, wrd *st
        return ALGslice(ret, bid, &s, &e);
 }
 
+/* carve out a slice based on the OIDs */
+/* beware that BATs may have different OID bases */
+str
+ALGslice_oid(int *ret, bat *bid, oid *start, oid *end)
+{
+       BAT *b, *bv;
+
+       if ((b = BATdescriptor(*bid)) == NULL) 
+               throw(MAL, "algebra.slice", RUNTIME_OBJECT_MISSING);
+       
+       bv  = BATmirror( b);
+       if ( bv == NULL)
+               throw(MAL, "algebra.slice", MAL_MALLOC_FAIL);
+       bv  = BATselect( bv, (void*) start, (void*) end);
+       if ( bv == NULL)
+               throw(MAL, "algebra.slice", MAL_MALLOC_FAIL);
+       bv  = BATmirror( bv);
+       if ( bv == NULL)
+               throw(MAL, "algebra.slice", MAL_MALLOC_FAIL);
+       *ret = bv->batCacheid;
+       BBPkeepref(*ret);
+       BBPreleaseref(b->batCacheid);
+       return MAL_SUCCEED;
+}
+
 /*
  * @- BUN Get/Fetch
  */
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to