Changeset: c2556de7d79b for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c2556de7d79b Modified Files: gdk/gdk_imprints.c gdk/gdk_imprints.h gdk/gdk_private.h gdk/gdk_select.c Branch: default Log Message:
Accurate casting when shifting bits and function to print imprints. When shifting bits use uint8_t uint16_t etc. to cast value 1. Maybe this is a solution to the failing tests on 32 bit archs. Also introduced a function that prints imprints to the standard error. The volume of the output of this funciton is huge so should not be used anywhere unless it is needed for specific visualazation reasons. diffs (111 lines): diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c --- a/gdk/gdk_imprints.c +++ b/gdk/gdk_imprints.c @@ -460,7 +460,7 @@ do { mask = 0; \ } \ GETBIN##B(bin,col[i]); \ - mask = IMPSsetBit(mask,bin); \ + mask = IMPSsetBit(B,mask,bin); \ } \ /* one last left */ \ if (prvmask == mask && dcnt > 0 && \ @@ -708,7 +708,6 @@ do { } BBPkeepref(imprints->histogram); b->T->imprints = imprints; - } MT_lock_unset(&GDKimprintsLock(ABS(b->batCacheid)), "BATimprints"); @@ -820,3 +819,44 @@ IMPSdestroy(BAT *b) { return; } + +void +IMPSprint(BAT *b) { + Imprints *imprints; + cchdc_t *d; + str s; + BUN icnt, dcnt, l; + unsigned long long pages; + bte j; + + if (BATprepareImprints(b)) + return; + imprints = b->T->imprints; + d = (cchdc_t *) imprints->dict->base; + s = (char *) malloc(sizeof(char)*(imprints->bits+1)); + +#define IMPSPRNTMASK(T,B) \ +do { \ + uint##B##_t *im = (uint##B##_t *) imprints->imps->base; \ + for (j=0; j<imprints->bits; j++) \ + s[j] = IMPSisSet(B, im[icnt], j)?'x':'.'; \ + s[j] = '\0'; \ +} while (0) + + fprintf(stderr,"bits = %d, impcnt = "BUNFMT", dictcnt = "BUNFMT"\n", + imprints->bits, imprints->impcnt, imprints->dictcnt); + for (dcnt=0, icnt = 0, pages = 1; dcnt < imprints->dictcnt; dcnt++) { + if (d[dcnt].repeat) { + BINSIZE(imprints->bits,IMPSPRNTMASK, " "); + pages += d[dcnt].cnt; + fprintf(stderr,"[ %10llu ]r %s\n", pages, s); + icnt++; + } else { + l = icnt+d[dcnt].cnt; + for (; icnt < l; icnt++) { + BINSIZE(imprints->bits,IMPSPRNTMASK, " "); + fprintf(stderr,"[ %10d ] %s\n", pages++, s); + } + } + } +} diff --git a/gdk/gdk_imprints.h b/gdk/gdk_imprints.h --- a/gdk/gdk_imprints.h +++ b/gdk/gdk_imprints.h @@ -40,9 +40,9 @@ typedef struct { #define IMPSrepeat(X) (((X) & 16777216)?1:0) #define IMPSsetrepeat(X) ((X) |= 16777216) #define IMPSunsetrepeat(X) ((X) &= (~16777216)) -#define IMPSsetBit(X,Y) ((((unsigned long)1)<<(Y))|(X)) -#define IMPSunsetBit(X,Y) ((~(((unsigned long)1)<<(Y)))&(X)) -#define IMPSisSet(X,Y) (((((unsigned long)1)<<Y)&X)?1:0) +#define IMPSsetBit(B,X,Y) ((((uint##B##_t)1)<<(Y))|(X)) +#define IMPSunsetBit(B,X,Y) ((~(((uint##B##_t)1)<<(Y)))&(X)) +#define IMPSisSet(B,X,Y) (((((uint##B##_t)1)<<Y)&X)?1:0) #define IMPSmod2(X,Y) ((X)&((Y)-1)) #endif /* GDK_IMPS_H */ diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -113,6 +113,7 @@ BAT *VIEWreset(BAT *b); void VIEWunlink(BAT *b); int IMPSgetbin(int tpe, bte bits, void *bins, const void *v); void IMPSremove(BAT *b); +void IMPSprint(BAT *b); #define BBP_BATMASK 511 #define BBP_THREADMASK 63 diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -265,12 +265,12 @@ do { \ void *bins = Tloc(histo, 0); \ lbin = IMPSgetbin(ATOMstorage(b->ttype), imprints->bits, bins, tl); \ hbin = IMPSgetbin(ATOMstorage(b->ttype), imprints->bits, bins, th); \ - for (j=lbin; j<=hbin; j++) mask = IMPSsetBit(mask, j); \ + for (j=lbin; j<=hbin; j++) mask = IMPSsetBit(B, mask, j); \ innermask = mask; \ if (!b->T->nonil || vl != minval) \ - innermask = IMPSunsetBit(innermask, lbin); \ + innermask = IMPSunsetBit(B, innermask, lbin); \ if (vh != maxval) \ - innermask = IMPSunsetBit(innermask, hbin); \ + innermask = IMPSunsetBit(B, innermask, hbin); \ if (anti) { \ uint##B##_t tmp = mask; \ mask = ~innermask; \ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list