📄 gdk_bat.c
字号:
if (b->tseqbase + BATcount(b) != *(oid*)t) { size_t cnt = BATcount(b); b = BATmaterializet(b, BATcount(b)+1); countonly=0; b->T->nodense = cnt; b->tdense = FALSE; if (b->tsorted & 1) { if (b->tseqbase + cnt > *(oid*)t || *(oid*)t == oid_nil) { b->T->nosorted = 1; b->tsorted = FALSE; b->T->nokey[0] = cnt - 1; b->T->nokey[1] = cnt; b->tkey = bm->hkey = b->tdense = FALSE; } } else if (b->tsorted == (bit)GDK_SORTED_REV){ if (b->tseqbase + cnt < *(oid*)t) { b->T->nosorted = 1; b->tsorted = FALSE; b->T->nokey[0] = cnt - 1; b->T->nokey[1] = cnt; b->tkey = bm->hkey = b->tdense = FALSE; } } } } } else { b->hkey = bm->tkey |= TRUE; if (b->htype == TYPE_oid) { /* empty oid column */ h = &id; id = 0; b->hdense = TRUE; b->hseqbase = bm->tseqbase = *(oid *) h; } if (b->ttype == TYPE_oid) { b->tkey = bm->hkey |= b->tdense = TRUE; b->tseqbase = bm->hseqbase = *(oid *) t; } else if (b->ttype == TYPE_void && b->tseqbase != oid_nil) { if (*(oid*)t == oid_nil) { BATmaterializet(b, BATcount(b)+1); countonly=0; } else { b->tseqbase = bm->hseqbase = *(oid*)t; } } else if (b->ttype) { b->tkey = bm->hkey |= TRUE; } } if (!countonly) { bunfastins(b, h, t); } else { b->batBuns->free += 1; BATsetcount(b, b->batCount+1); } /* first adapt the hashes; then the user-defined accelerators. * REASON: some accelerator updates (qsignature) use the hashes! */ if (b->hhash && h) { HASHins(b, (hash_t) i, h); if (hsize && hsize != b->hheap->size) HEAPwarm(b->hheap); } if (b->thash) { HASHins(bm, (hash_t) i, t); if (tsize && tsize != b->theap->size) HEAPwarm(b->theap); } return b; bunins_failed: return NULL;}#line 1274 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"static INLINE BUNBUNdelete_(BAT *b, BUN p, bit force){ BAT *bm = BBP_cache(-b->batCacheid); int bs = BUNsize(b); BUN l, last = BUNlast(b) - bs; size_t idx1, idx2; ALIGNdel(b, "BUNdelete", force); /* zap alignment info */#line 1287 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (p < b->batInserted && !force) { idx1 = BUNindex(b, p); if (p == b->batFirst) { /* first can simply be discarded */ #line 849 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->hhash) { hashdel(b->hhash, idx1, BUNhead(b, p), p < last); }} #line 1291 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" #line 855 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->thash) { hashdel(b->thash, (hash_t)idx1, BUNtail(b, p), p < last); }}#line 1292 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (BAThdense(b)) { bm->tseqbase = ++b->hseqbase; } if (BATtdense(b)) { bm->hseqbase = ++b->tseqbase; } } else { #line 849 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->hhash) { hashdel(b->hhash, idx1, BUNhead(b, p), p < last); }} #line 1301 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" #line 855 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->thash) { hashdel(b->thash, (hash_t)idx1, BUNtail(b, p), p < last); }}#line 1302 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" l = BUNfirst(b); idx2 = BUNindex(b, l); #line 861 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ char *tmp = alloca(bs); if (b->hhash) { HASHmove(b->hhash, (hash_t)idx2, (hash_t)idx1, BUNhead(b, l), l < last); } if (b->thash) { HASHmove(b->thash, (hash_t)idx2, (hash_t)idx1, BUNtail(b, l), l < last); } /* move first to tmp); */ #line 838 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (bs == 8) { *(lng *) tmp = *(lng *) l; } else if (bs == 4) { *(int *) tmp = *(int *) l; } else { str _dst = (str) tmp, _src = (str) l, _end = _src + bs; while (_src < _end) *_dst++ = *_src++; }#line 872 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" /* move delete to first */ #line 838 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (bs == 8) { *(lng *) l = *(lng *) p; } else if (bs == 4) { *(int *) l = *(int *) p; } else { str _dst = (str) l, _src = (str) p, _end = _src + bs; while (_src < _end) *_dst++ = *_src++; }#line 874 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" /* move first to deleted */ #line 838 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (bs == 8) { *(lng *) p = *(lng *) tmp; } else if (bs == 4) { *(int *) p = *(int *) tmp; } else { str _dst = (str) p, _src = (str) tmp, _end = _src + bs; while (_src < _end) *_dst++ = *_src++; }#line 876 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"}#line 1306 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (b->hsorted & 1) { b->hsorted = FALSE; b->H->nosorted = idx1; } else if (b->hsorted == (bit)GDK_SORTED_REV) { b->hsorted = FALSE; b->H->nosorted_rev = idx1; } if (b->tsorted & 1) { b->tsorted = FALSE; b->T->nosorted = idx1; } else if (b->tsorted == (bit)GDK_SORTED_REV) { b->tsorted = FALSE; b->T->nosorted_rev = idx1; } } b->batFirst += bs; } else {#line 1330 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" int (*hunfix) (ptr) = BATatoms[b->htype].atomUnfix; int (*tunfix) (ptr) = BATatoms[b->ttype].atomUnfix; void (*hatmdel) (Heap *, var_t *) = BATatoms[b->htype].atomDel; void (*tatmdel) (Heap *, var_t *) = BATatoms[b->ttype].atomDel; if (hunfix) { (*hunfix) (BUNhead(b, p)); } if (tunfix) { (*tunfix) (BUNtail(b, p)); } if (hatmdel) { (*hatmdel) (b->hheap, (var_t *) BUNhloc(b, p)); } if (tatmdel) { (*tatmdel) (b->theap, (var_t *) BUNtloc(b, p)); } idx1 = BUNindex(b, p); #line 849 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->hhash) { hashdel(b->hhash, idx1, BUNhead(b, p), p < last); }} #line 1348 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" #line 855 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->thash) { hashdel(b->thash, (hash_t)idx1, BUNtail(b, p), p < last); }}#line 1349 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" idx2 = BUNindex(b, last); if (p != last) { #line 861 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ char *tmp = alloca(bs); if (b->hhash) { HASHmove(b->hhash, (hash_t)idx2, (hash_t)idx1, BUNhead(b, last), last < last); } if (b->thash) { HASHmove(b->thash, (hash_t)idx2, (hash_t)idx1, BUNtail(b, last), last < last); } /* move first to tmp); */ #line 838 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (bs == 8) { *(lng *) tmp = *(lng *) last; } else if (bs == 4) { *(int *) tmp = *(int *) last; } else { str _dst = (str) tmp, _src = (str) last, _end = _src + bs; while (_src < _end) *_dst++ = *_src++; }#line 872 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" /* move delete to first */ #line 838 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (bs == 8) { *(lng *) last = *(lng *) p; } else if (bs == 4) { *(int *) last = *(int *) p; } else { str _dst = (str) last, _src = (str) p, _end = _src + bs; while (_src < _end) *_dst++ = *_src++; }#line 874 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" /* move first to deleted */ #line 838 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (bs == 8) { *(lng *) p = *(lng *) tmp; } else if (bs == 4) { *(int *) p = *(int *) tmp; } else { str _dst = (str) p, _src = (str) tmp, _end = _src + bs; while (_src < _end) *_dst++ = *_src++; }#line 876 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"}#line 1352 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (b->hsorted & 1) { b->hsorted = FALSE; b->H->nosorted = idx1; if (b->hdense) { b->hdense = FALSE; b->H->nodense = idx1; } } else if (b->hsorted == (bit)GDK_SORTED_REV) { b->hsorted = FALSE; b->H->nosorted_rev = idx1; } if (b->tsorted & 1) { b->tsorted = FALSE; b->H->nosorted = idx1; if (b->tdense) { b->tdense = FALSE; b->T->nodense = idx1; } } else if (b->tsorted == (bit)GDK_SORTED_REV) { b->tsorted = FALSE; b->H->nosorted_rev = idx1; } } b->batBuns->free -= bs; p = ((char *) p) - bs; } b->batCount--; b->batDirty = 1; /* bat is dirty */ return p;}BUNBUNdelete(BAT *b, BUN p, bit force){ if (p == NULL) { return p; } if ((b->htype == TYPE_void && b->hseqbase != oid_nil) || (b->ttype == TYPE_void && b->tseqbase != oid_nil)) { int bs = BUNsize(b); BUN last = BUNlast(b) - bs; if ((p < b->batInserted || p != last) && !force) { size_t i = BUNindex(b, p); b = BATmaterialize(b, BATcount(b)); if (b == NULL) return NULL; p = BUNptr(b, i); } } return BUNdelete_(b, p, force);}BAT *BUNdel(BAT *b, ptr x, ptr y, bit force){ BUN p; BATcheck(b, "BUNdel"); BATcheck(x, "BUNdel: head value is nil\n"); if ((p = BUNlocate(b, x, y)) != NULL) { ALIGNdel(b, "BUNdel", force); /* zap alignment info */ BUNdelete(b, p, force); return b; } return 0;}#line 1429 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"BAT *BUNdelHead(BAT *b, ptr x, bit force){ BUN p; BATcheck(b, "BUNdelHead"); if (x == NULL) { x = ATOMnilptr(b->htype); } if ((p = BUNfnd(b, x)) != NULL) { ALIGNdel(b, "BUNdelHead", force); /* zap alignment info */ do { BUNdelete(b, p, force); } while ((p = BUNfnd(b, x)) != NULL); } return b;}#line 1500 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"BAT *BUNinplace(BAT *b, BUN p, ptr h, ptr t, bit force){ if (p >= b->batInserted || force) { /* uncommitted BUN elements */ BUN last = BUNlast(b) - BUNsize(b); BAT *bm = BBP_cache(-b->batCacheid); size_t pit = BUNindex(b, p); ALIGNinp(b, "BUNreplace", force); /* zap alignment info */ if (b->tvarsized) { size_t tsize = b->theap->size; #line 1464 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" #line 855 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->thash) { hashdel(b->thash, (hash_t)pit, BUNtvar(b, p), p < last); }}#line 1464 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" ATOMreplace(b->ttype, b->theap, BUNtloc(b,p), t); #line 855 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx"{ if (b->thash) { hashins(b->thash, (hash_t)pit, BUNtvar(b, p), p < last); }}#line 1466 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_bat.mx" if (BATtordered(b)&1 || BATtordered(b)==(bit)GDK_SORTED_REV) { int bs = BUNsize(b), tt = b->ttype; BUN prv = p - bs; BUN nxt = p + bs; if (prv < b->batFirst) prv = NULL; if (nxt > last) nxt = NULL; if (BATtordered(b)&1) { if ((prv && ATOMcmp(tt, t, BUNtvar(b,prv)) < 0) || (nxt && ATOMcmp(tt, t, BUNtvar(b,nxt)) > 0)) { b->tsorted = FALSE; b->T->nosorted = pit; } else if (b->ttype != TYPE_void && b->tdense) { if (((prv && 1 + *(oid*) BUNtloc(b,prv) != *(oid*) t) || (nxt && *(oid*) BUNtloc(b,nxt) != 1 + *(oid*) t))) { b->tdense = FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -