📄 gdk_desc.c
字号:
#line 49 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx"#include "monetdb_config.h"#include "gdk.h"#line 106 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx"intBATsavedesc(BAT *b, str nme){ BATstore *bs = (BATstore *) b; int ret = 0, fd = -1; DELTAsave(b); if (b->GDKversion == GDKLIBRARY) { char *hatm = (b->htype>=0)?ATOMname(b->htype): ATOMunknown_name(b->htype); char *tatm = (b->ttype>=0)?ATOMname(b->ttype): ATOMunknown_name(b->ttype); int hlen = (int) strlen(hatm) + 1; int tlen = (int) strlen(tatm) + 1; int hvar = b->hvarsized && (b->htype != TYPE_void); int tvar = b->tvarsized && (b->ttype != TYPE_void); if ((fd = GDKfdlocate(nme, "wb", "desc")) < 0 || write(fd, bs, sizeof(BATstore)) != sizeof(BATstore) || (hvar && write(fd, b->hheap, sizeof(Heap)) != sizeof(Heap)) || (tvar && write(fd, b->theap, sizeof(Heap)) != sizeof(Heap)) || (write(fd, &hlen, sizeof(int)) != sizeof(int)) || (write(fd, hatm, hlen ) != hlen) || (write(fd, &tlen, sizeof(int)) != sizeof(int)) || (write(fd, tatm, tlen ) != tlen)) { ret = -1; } if (fd >= 0) close(fd); } /* a saved bat could still be used so reset the delta status */ DELTAload(b); return (ret < 0) ? ret : 0;}#line 142 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx"BAT *BATloaddesc(str nme){ long_str hatm; long_str tatm; BATstore *dst; BAT *b = NULL; int ver, fd = -1, hvar, tvar; ssize_t n; if ((fd = GDKfdlocate(nme, "rb+", "desc")) < 0) { GDKerror("BATloaddesc: cannot open desc file=%s\n", nme); return NULL; } dst = (BATstore *) GDKzalloc(sizeof(BATstore)); if (!dst) return NULL; if ((n = read(fd, dst, sizeof(BATstore)) != sizeof(BATstore)) ) { GDKerror("BATloaddesc: read error: name=%s, n=%d\n", nme, n); GDKfree(dst); close(fd); return NULL; } ver = dst->B.GDKversion; if (!GDKversionOK(ver)) { GDKerror("GDKload: incompatible version %d.\n", dst->B.GDKversion); GDKfree(dst); close(fd); return NULL; } b = (BAT *) dst; b->H = &dst->H; b->T = &dst->T; b->P = &dst->P; b->U = &dst->U; b->hident = b->tident = NULL; BATroles(b, NULL, NULL); b->batBuns = &b->U->buns; b->batBuns->base = NULL; b->batBuns->filename = NULL; b->hheap = b->theap = NULL; hvar = b->hvarsized && (b->htype != TYPE_void); tvar = b->tvarsized && (b->ttype != TYPE_void); if (hvar && ((b->hheap = (Heap*)GDKzalloc(sizeof(Heap))) == NULL || (n = read(fd, b->hheap, sizeof(Heap))) != sizeof(Heap) )) { GDKerror("BATloaddesc: read error: name=%s, n=%d\n", nme, n); if (b->hheap) GDKfree(b->hheap); GDKfree(dst); close(fd); return NULL; } if (tvar && ((b->theap = (Heap*)GDKzalloc(sizeof(Heap))) == NULL || (n = read(fd, b->theap, sizeof(Heap))) != sizeof(Heap) )) { GDKerror("BATloaddesc: read error: name=%s, n=%d\n", nme, n); if (b->hheap) GDKfree(b->hheap); if (b->theap) GDKfree(b->theap); GDKfree(dst); close(fd); return NULL; } if ( (read(fd, &ver, sizeof(int)) != sizeof(int)) || ver > BUFSIZ || (read(fd, hatm, ver) != ver) || (read(fd, &ver, sizeof(int)) != sizeof(int)) || ver > BUFSIZ || (read(fd, tatm, ver) != ver) ) { if (b->hheap) GDKfree(b->hheap); if (b->theap) GDKfree(b->theap); GDKfree(dst); close(fd); return NULL; } close(fd); /* mark atom as unknown if its not loaded jet */ if (!ATOMname(b->htype) || strcmp(ATOMname(b->htype), hatm) != 0) { int ht = ATOMindex(hatm); if (ht < 0 || BATatoms[ht].deleting) { ht = ATOMunknown_find(hatm); } b->htype = ht; } if (!ATOMname(b->ttype) || strcmp(ATOMname(b->ttype), tatm) != 0) { int tt = ATOMindex(tatm); if (tt < 0 || BATatoms[tt].deleting) { tt = ATOMunknown_find(tatm); } b->ttype = tt; } if (b->hheap) { b->hheap->base = NULL; b->hheap->filename = NULL; } if (b->theap) { b->theap->base = NULL; b->theap->filename = NULL; } /* probably need to allocate heaps here */ b->batCopiedtodisk = 1; b->batElmshift = BATelmshift(b); b->H->props = NULL; b->T->props = NULL; b->hhash = b->thash = NULL; return b;}#line 256 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx"#line 266 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx"static intbatswap(BAT *b, int direction){ void (*fcn) (ptr, int) = BATatoms[b->htype].atomConvert; BUN p, q; int xx; switch (ATOMstorage(b->htype)) { case TYPE_void: case TYPE_chr: case TYPE_bte: break; case TYPE_sht: DELloop(b, p, q, xx) #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { sht *_p = (sht*) BUNhloc(b,p), _i=*_p; *_p = short_int_SWAP(_i); }#line 279 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" BATloopFast(b, p, q, xx) #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { sht *_p = (sht*) BUNhloc(b,p), _i=*_p; *_p = short_int_SWAP(_i); }#line 280 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" break; case TYPE_int: case TYPE_flt: DELloop(b, p, q, xx) #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { int *_p = (int*) BUNhloc(b,p), _i=*_p; *_p = normal_int_SWAP(_i); }#line 285 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" BATloopFast(b, p, q, xx) #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { int *_p = (int*) BUNhloc(b,p), _i=*_p; *_p = normal_int_SWAP(_i); }#line 286 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" break; case TYPE_lng: case TYPE_dbl: DELloop(b, p, q, xx) #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { lng *_p = (lng*) BUNhloc(b,p), _i=*_p; *_p = long_long_SWAP(_i); }#line 291 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" BATloopFast(b, p, q, xx) #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { lng *_p = (lng*) BUNhloc(b,p), _i=*_p; *_p = long_long_SWAP(_i); }#line 292 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" break; default: ATOMheapConvert(b->htype, b->hheap, direction); DELloop(b, p, q, xx) { #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { int *_p = (int*) BUNhloc(b,p), _i=*_p; *_p = normal_int_SWAP(_i); }#line 298 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" if (fcn != NULL) (*fcn) (BUNhead(b, p), direction); } BATloopFast(b, p, q, xx) { #line 261 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" { int *_p = (int*) BUNhloc(b,p), _i=*_p; *_p = normal_int_SWAP(_i); }#line 304 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx" if (fcn != NULL) (*fcn) (BUNhead(b, p), direction); } } return TRUE;}BAT *BATconvert(BAT *b, int direction){ if (batswap(b, direction)) { if (!batswap(BATmirror(b), direction)) { batswap(b, direction == CONV_HTON ? CONV_NTOH : CONV_HTON); } } b->batDirty = 1; return b;}#line 326 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_desc.mx"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -