On Aug 06, 2010, at 00:13 , Jennie Zhang wrote: > Changeset: c9bb76c454ec for MonetDB > URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c9bb76c454ec > Modified Files: > MonetDB5/src/modules/mal/Tests/zorder.mal > MonetDB5/src/modules/mal/zorder.mx > Branch: default > Log Message: > > [mq]: zorder.patch
I forgot to add a log message to 'hg qfinish' and could not find a way to add it afterward, so adding it this way: zorder xy -> {xy,x,y} - extended the zorder module with (MAL) commands to extract only the x/y-coordinates from a z-order encoding - added tests for the new commands > > > diffs (237 lines): > > diff -r e9d9b58d5f1e -r c9bb76c454ec MonetDB5/src/modules/mal/Tests/zorder.mal > --- a/MonetDB5/src/modules/mal/Tests/zorder.mal Thu Aug 05 16:56:34 > 2010 +0200 > +++ b/MonetDB5/src/modules/mal/Tests/zorder.mal Thu Aug 05 17:06:49 > 2010 +0200 > @@ -21,6 +21,15 @@ > (x,y):= zorder.decode(z3); io.print(x,y); > (x,y):= zorder.decode(z4); io.print(x,y); > > +x := zorder.decode_x(z1); > +y := zorder.decode_y(z1); io.print(x, y); > +x := zorder.decode_x(z2); > +y := zorder.decode_y(z2); io.print(x, y); > +x := zorder.decode_x(z3); > +y := zorder.decode_y(z3); io.print(x, y); > +x := zorder.decode_x(z4); > +y := zorder.decode_y(z4); io.print(x, y); > + > bx:= bat.new(:oid,:int); > bat.append(bx,0); > bat.append(bx,1); > @@ -62,6 +71,9 @@ > io.print(bz); > (cx,cy):= zorder.decode(bz); > io.print(cx,cy); > +dx:= zorder.decode_x(bz); > +dy:= zorder.decode_y(bz); > +io.print(dx,dy); > > # taking a slice > bs:= zorder.slice(1,1,3,3); > diff -r e9d9b58d5f1e -r c9bb76c454ec MonetDB5/src/modules/mal/zorder.mx > --- a/MonetDB5/src/modules/mal/zorder.mx Thu Aug 05 16:56:34 2010 +0200 > +++ b/MonetDB5/src/modules/mal/zorder.mx Thu Aug 05 17:06:49 2010 +0200 > @@ -49,6 +49,22 @@ > address ZORDbatdecode_int_oid > comment "Derive the z-order pair"; > > +command decode_x(z:oid)(x:int) > +address ZORDdecode_int_oid_x > +comment "Derive the z-order x-coordinate"; > + > +command decode_x(z:bat[:oid,:oid]):bat[:oid,:int] > +address ZORDbatdecode_int_oid_x > +comment "Derive the z-order x-coordinate"; > + > +command decode_y(z:oid)(y:int) > +address ZORDdecode_int_oid_y > +comment "Derive the z-order y-coordinate"; > + > +command decode_y(z:bat[:oid,:oid]):bat[:oid,:int] > +address ZORDbatdecode_int_oid_y > +comment "Derive the z-order y-coordinate"; > + > command slice(xb:int, yb:int, xt:int, yt:int ):bat[:oid,:oid] > address ZORDslice_int > comment "Extract the Z-order indices between two points"; > @@ -71,7 +87,11 @@ > zorder_export str ZORDencode_int_oid(oid *z, int *x, int *y); > zorder_export str ZORDbatencode_int_oid(int *z, int *x, int *y); > zorder_export str ZORDdecode_int_oid(int *x, int *y, oid *z); > +zorder_export str ZORDdecode_int_oid_x(int *x, oid *z); > +zorder_export str ZORDdecode_int_oid_y(int *y, oid *z); > zorder_export str ZORDbatdecode_int_oid(int *x, int *y, int *z); > +zorder_export str ZORDbatdecode_int_oid_x(int *x, int *z); > +zorder_export str ZORDbatdecode_int_oid_y(int *y, int *z); > zorder_export str ZORDslice_int(int *r, int *xb, int *yb, int *xt, int *yt); > > #endif /* _ZORDER_H */ > @@ -113,6 +133,31 @@ > *x = xv; > *y = yv; > } > +static inline void zdeco...@1_@2_x(@1 *x, @2 *z) > +{ > + @1 xv = 0, mask =1; > + @2 zv = *z; > + int i; > + for ( i = 0; i < (int) (8 * sizeof(@2)); i+= 2) { > + xv |= ((zv & 1) * mask); > + zv >>= 2; > + mask <<=1; > + } > + *x = xv; > +} > +static inline void zdeco...@1_@2_y(@1 *y, @2 *z) > +{ > + @1 yv=0, mask =1; > + @2 zv = *z; > + int i; > + for ( i = 0; i < (int) (8 * sizeof(@2)); i+= 2) { > + zv >>= 1; > + yv |= ((zv & 1) * mask); > + zv >>= 1; > + mask <<=1; > + } > + *y = yv; > +} > @c > @:Zcode(int,oid)@ > > @@ -130,6 +175,20 @@ > return MAL_SUCCEED; > } > > +str > +ZORDdecode_int_oid_x(int *x, oid *z) > +{ > + Zdecode_int_oid_x(x,z); > + return MAL_SUCCEED; > +} > + > +str > +ZORDdecode_int_oid_y(int *y, oid *z) > +{ > + Zdecode_int_oid_y(y,z); > + return MAL_SUCCEED; > +} > + > str > ZORDbatencode_int_oid(int *zbid, int *xbid, int *ybid) > { > @@ -291,6 +350,116 @@ > return MAL_SUCCEED; > } > > +str > +ZORDbatdecode_int_oid_x(int *xbid, int *zbid) > +{ > + BAT *bx,*bz; > + oid *z, *q; > + int *x; > + > + bz = BATdescriptor(*zbid); > + if ( bz == 0 ) > + throw(OPTIMIZER, "zorder.decode", RUNTIME_OBJECT_MISSING); > + > + bx = BATnew(TYPE_void, TYPE_int, BATcount(bz)); > + if ( bx == 0 ){ > + BBPunfix(bz->batCacheid); > + throw(OPTIMIZER, "zorder.decode", RUNTIME_OBJECT_MISSING); > + } > + > + z = (oid *) Tloc(bz, BUNfirst(bz)); > + q = (oid *) Tloc(bz, BUNlast(bz)); > + x = (int *) Tloc(bx, BUNfirst(bx)); > + > + BATaccessBegin(bz, USE_TAIL, MMAP_SEQUENTIAL); > + if ( bz->T->nonil ){ > + for ( ; z<q; z++,x++) > + Zdecode_int_oid_x(x,z); > + } else { > + for ( ; z<q; z++,x++) > + if ( *z == oid_nil) { > + *x = int_nil; > + } else > + Zdecode_int_oid_x(x,z); > + } > + > + BATaccessEnd(bz, USE_TAIL, MMAP_SEQUENTIAL); > + > + if (!(bx->batDirty&2)) > + bx = BATsetaccess(bx, BAT_READ); > + BATsetcount(bx, BATcount(bz)); > + BATseqbase(bx, bz->hseqbase); > + bx->hsorted = 1; > + bx->tsorted = 0; > + bx->H->nonil = 1; > + bx->T->nonil = bz->T->nonil; > + > + if (bx->htype != bz->htype) { > + BAT *r = VIEWcreate(bz,bx); > + BBPreleaseref(bx->batCacheid); > + bx = r; > + } > + > + BBPunfix(bz->batCacheid); > + BBPkeepref(*xbid = bx->batCacheid); > + return MAL_SUCCEED; > +} > + > +str > +ZORDbatdecode_int_oid_y(int *ybid, int *zbid) > +{ > + BAT *by,*bz; > + oid *z, *q; > + int *y; > + > + bz = BATdescriptor(*zbid); > + if ( bz == 0 ) > + throw(OPTIMIZER, "zorder.decode", RUNTIME_OBJECT_MISSING); > + > + by = BATnew(TYPE_void, TYPE_int, BATcount(bz)); > + if ( by == 0 ){ > + BBPunfix(bz->batCacheid); > + throw(OPTIMIZER, "zorder.decode", RUNTIME_OBJECT_MISSING); > + } > + > + z = (oid *) Tloc(bz, BUNfirst(bz)); > + q = (oid *) Tloc(bz, BUNlast(bz)); > + y = (int *) Tloc(by, BUNfirst(by)); > + > + BATaccessBegin(bz, USE_TAIL, MMAP_SEQUENTIAL); > + if ( bz->T->nonil ){ > + for ( ; z<q; z++,y++) > + Zdecode_int_oid_y(y,z); > + } else { > + for ( ; z<q; z++,y++) > + if ( *z == oid_nil) { > + *y = int_nil; > + } else > + Zdecode_int_oid_y(y,z); > + } > + > + BATaccessEnd(bz, USE_TAIL, MMAP_SEQUENTIAL); > + > + if (!(by->batDirty&2)) > + by = BATsetaccess(by, BAT_READ); > + BATsetcount(by, BATcount(bz)); > + BATseqbase(by, bz->hseqbase); > + by->hsorted = 1; > + by->tsorted = 0; > + by->H->nonil = 1; > + by->T->nonil = bz->T->nonil; > + > + if (by->htype != bz->htype) { > + BAT *r = VIEWcreate(bz,by); > + BBPreleaseref(by->batCacheid); > + by = r; > + } > + > + BBPunfix(bz->batCacheid); > + BBPkeepref(*ybid = by->batCacheid); > + return MAL_SUCCEED; > +} > + > zorder_export > str ZORDslice_int(int *r, int *xb, int *yb, int *xt, int *yt) > { > _______________________________________________ > Checkin-list mailing list > Checkin-list@monetdb.org > http://mail.monetdb.org/mailman/listinfo/checkin-list _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list