📄 chopper.c
字号:
#line 88 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/mal/chopper.mx"#include "mal_config.h"#include "mal.h"#include "mal_interpreter.h"#ifdef WIN32#ifndef LIBCHOPPER#define chopper_export extern __declspec(dllimport)#else#define chopper_export extern __declspec(dllexport)#endif#else#define chopper_export extern#endifchopper_export str CHPnewChunkIterator(lng *res, int *vid, int *bid, lng *granule);chopper_export str CHPhasMoreChunks(lng *res, int *vid, int *bid, lng *granule);chopper_export str CHPbunIterator(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);chopper_export str CHPbunHasMoreElements(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);chopper_export str CHPgetHead(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);chopper_export str CHPgetTail(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);#line 117 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/mal/chopper.mx"strCHPnewChunkIterator(lng *res, int *vid, int *bid, lng *granule){ BAT *b, *view; size_t cnt, first; if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "chop.newChunkIterator", "Cannot access descriptor"); } cnt = BATcount(b); first = BUNindex(b, BUNfirst(b)); view = VIEWcreate_(b, TRUE); /* printf("set bat chunk bound to %d %d - %d\n", *granule, first, MIN(cnt,(size_t) *granule)); */ VIEWbounds(view, (size_t) first, first + MIN(cnt, (size_t) * granule) - 1); BATseqbase(view, first - 1); *vid = view->batCacheid; BBPkeepref(view->batCacheid); BBPunfix(b->batCacheid); *res = first; return MAL_SUCCEED;}#line 146 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/mal/chopper.mx"strCHPhasMoreChunks(lng *res, int *vid, int *bid, lng *granule){ BAT *b, *view; size_t i; if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "chop.newChunkMoreElements", "Cannot access descriptor"); } if ((view = BATdescriptor(*vid)) == NULL) { BBPunfix(b->batCacheid); throw(MAL, "chop.newChunkMoreElements", "Cannot access 'vid' descriptor"); } i = (size_t) (*res + BATcount(view)); if (i >= BUNindex(b, BUNlast(b))) { *res = -1; BBPunfix(b->batCacheid); BBPunfix(view->batCacheid); return MAL_SUCCEED; } /* printf("set bat chunk bound to %d - %d \n", i, i+(size_t) *granule-1); */ VIEWbounds(view, i, i + (size_t) * granule - 1); BATseqbase(view, i - 1); BBPunfix(b->batCacheid); BBPkeepref(view->batCacheid); *res = i; return MAL_SUCCEED;}#line 184 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/mal/chopper.mx"strCHPbunIterator(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){ BAT *b; lng *cursor; int *bid; lng yy; BUN p; ValPtr head, tail; oid o; cursor = (lng *) getArgReference(stk, pci, 0); head = &stk->stk[pci->argv[1]]; tail = &stk->stk[pci->argv[2]]; bid = (int *) getArgReference(stk, pci, 3); if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "chop.newChunkMoreElements", "Cannot access 'bid' descriptor"); } if (BATcount(b) == 0) { *cursor = -1; BBPunfix(b->batCacheid); return MAL_SUCCEED; } *cursor = BUNindex(b, BUNfirst(b)); /* get head = ... tail = ... */ yy = *cursor; p = BUNptr(b, yy); if( b->htype == TYPE_void){ o= b->hseqbase; VALinit(head, TYPE_oid, &o); } else VALinit(head, getArgType(mb, pci, 1), BUNhead(b, p)); VALinit(tail, getArgType(mb, pci, 2), BUNtail(b, p)); BBPunfix(b->batCacheid); return MAL_SUCCEED;}strCHPbunHasMoreElements(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){ BAT *b; lng *cursor; lng yy; bat *bid; BUN p; ValPtr head, tail; oid o; cursor = (lng *) getArgReference(stk, pci, 0); head = &stk->stk[pci->argv[1]]; tail = &stk->stk[pci->argv[2]]; bid = (bat *) getArgReference(stk, pci, 3); if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "chop.newChunkMoreElements", "Cannot access 'bid' descriptor"); } /* get head = ... tail = ... */ yy = *cursor + 1; *cursor = yy; p = BUNptr(b, yy); if (p >= BUNlast(b)) { *cursor = -1; BBPunfix(b->batCacheid); return MAL_SUCCEED; } if( b->htype == TYPE_void){ o= yy - BUNindex(b,BUNfirst(b))+ b->hseqbase; VALinit(head, TYPE_oid, &o); } else { assert(b->htype == getArgType(mb,pci,1)); VALinit(head, getArgType(mb, pci, 1), BUNhead(b, p)); } assert(b->ttype == getArgType(mb,pci,2)); VALinit(tail, getArgType(mb, pci, 2), BUNtail(b, p)); BBPunfix(b->batCacheid); return MAL_SUCCEED;}#line 275 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/mal/chopper.mx"strCHPgetHead(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){ BAT *b; lng *cursor; int *bid; int limit; BUN p; ValPtr head; oid o; cursor = (lng *) getArgReference(stk, pci, 2); bid = (int *) getArgReference(stk, pci, 1); head = &stk->stk[pci->argv[0]]; if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "chop.getHead", "Cannot access 'bid' descriptor"); } limit = BUNindex(b, BUNlast(b)); if (*cursor < 0 || *cursor >= limit) { BBPunfix(b->batCacheid); throw(MAL, "mal.getHead", "range error"); } /* get head = ... */ p = BUNptr(b, *cursor); if( getArgType(mb,pci,3) == TYPE_void){ o= BUNindex(b,p)+ b->hseqbase; VALinit(head, TYPE_oid, &o); } else VALinit(head, getArgType(mb, pci, 3), BUNhead(b, p)); BBPunfix(b->batCacheid); return MAL_SUCCEED;}strCHPgetTail(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){ BAT *b; lng *cursor; int *bid; int limit; BUN p; ValPtr tail; cursor = (lng *) getArgReference(stk, pci, 2); bid = (int *) getArgReference(stk, pci, 1); tail = &stk->stk[pci->argv[0]]; if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "chop.getTail", "Cannot access 'bid' descriptor"); } limit = BUNindex(b, BUNlast(b)); if (*cursor < 0 || *cursor >= limit) { BBPunfix(b->batCacheid); throw(OUTOFBNDS, "mal.getTail", "range error: %d", *cursor); } /* get tail = ... */ p = BUNptr(b, *cursor); VALinit(tail, getArgType(mb, pci, 3), BUNtail(b, p)); BBPunfix(b->batCacheid); return MAL_SUCCEED;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -