/* * We start with the large chunk iterator. * The definition of the control statements require the same * control variables, which means that the BATview is accessible * to determine how far to advance when the next chunk is retrieved. * The number of elements in the chunk is limited by the granule * size. */ str ITRnewChunk(lng *res, int *vid, int *bid, lng *granule) { BAT *b, *view; BUN cnt, first; if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "chop.newChunk", INTERNAL_BAT_ACCESS); } cnt = BATcount(b); first = BUNfirst(b); view = VIEWcreate_(b, b, TRUE); /* printf("set bat chunk bound to " LLFMT " " BUNFMT " - " BUNFMT "\n", *granule, first, MIN(cnt,(BUN) *granule)); */ VIEWbounds(b, view, (BUN) first, first + MIN(cnt, (BUN) * granule)); BATseqbase(view, b->hseqbase); *vid = view->batCacheid; BBPkeepref(view->batCacheid); BBPunfix(b->batCacheid); *res = first; return MAL_SUCCEED; }
BAT * VIEWcreate(BAT *h, BAT *t) { return VIEWcreate_(h, t, FALSE); }