本文整理汇总了C++中BATdescriptor函数的典型用法代码示例。如果您正苦于以下问题:C++ BATdescriptor函数的具体用法?C++ BATdescriptor怎么用?C++ BATdescriptor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BATdescriptor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CMDbatUNARY1
static str
CMDbatUNARY1(MalStkPtr stk, InstrPtr pci, int abort_on_error,
BAT *(*batfunc)(BAT *, BAT *, int), const char *malfunc)
{
bat *bid;
BAT *bn, *b, *s = NULL;
bid = getArgReference_bat(stk, pci, 1);
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
if (pci->argc == 3) {
bat *sid = getArgReference_bat(stk, pci, 2);
if (*sid && (s = BATdescriptor(*sid)) == NULL) {
BBPunfix(b->batCacheid);
throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
}
}
bn = (*batfunc)(b, s, abort_on_error);
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (bn == NULL) {
return mythrow(MAL, malfunc, OPERATION_FAILED);
}
bid = getArgReference_bat(stk, pci, 0);
BBPkeepref(*bid = bn->batCacheid);
return MAL_SUCCEED;
}
示例2: ITRnextChunk
/*
* The nextChunk version advances the reader,
* which also means that the view descriptor is already available.
* The granule size may differ in each call.
*/
str
ITRnextChunk(lng *res, int *vid, int *bid, lng *granule)
{
BAT *b, *view;
BUN i;
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "iterator.nextChunk", INTERNAL_BAT_ACCESS);
}
if ((view = BATdescriptor(*vid)) == NULL) {
BBPunfix(b->batCacheid);
throw(MAL, "iterator.nextChunk", INTERNAL_BAT_ACCESS);
}
i = (BUN) (*res + BATcount(view));
if (i >= BUNlast(b)) {
*res = lng_nil;
*vid = 0;
BBPunfix(view->batCacheid);
BBPunfix(b->batCacheid);
return MAL_SUCCEED;
}
/* printf("set bat chunk bound to " BUNFMT " - " BUNFMT " \n",
i, i+(BUN) *granule-1); */
VIEWbounds(b, view, i, i + (BUN) * granule);
BATseqbase(view, b->hseqbase == oid_nil ? oid_nil : b->hseqbase + i - BUNfirst(b));
BBPkeepref(*vid = view->batCacheid);
BBPunfix(b->batCacheid);
*res = i;
return MAL_SUCCEED;
}
示例3: BKCbat_inplace_force
str
BKCbat_inplace_force(bat *r, const bat *bid, const bat *rid, const bat *uid, const bit *force)
{
BAT *b, *p, *u;
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "bat.inplace", RUNTIME_OBJECT_MISSING);
if ((p = BATdescriptor(*rid)) == NULL) {
BBPunfix(b->batCacheid);
throw(MAL, "bat.inplace", RUNTIME_OBJECT_MISSING);
}
if ((u = BATdescriptor(*uid)) == NULL) {
BBPunfix(b->batCacheid);
BBPunfix(p->batCacheid);
throw(MAL, "bat.inplace", RUNTIME_OBJECT_MISSING);
}
if (void_replace_bat(b, p, u, *force) == BUN_NONE) {
BBPunfix(b->batCacheid);
BBPunfix(p->batCacheid);
BBPunfix(u->batCacheid);
throw(MAL, "bat.inplace", GDK_EXCEPTION);
}
BBPkeepref(*r = b->batCacheid);
BBPunfix(p->batCacheid);
BBPunfix(u->batCacheid);
return MAL_SUCCEED;
}
示例4: CMDconvertbat
static str
CMDconvertbat(MalStkPtr stk, InstrPtr pci, int tp, int abort_on_error)
{
bat *bid;
BAT *b, *bn, *s = NULL;
bid = getArgReference_bat(stk, pci, 1);
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "batcalc.convert", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
if (pci->argc == 3) {
bat *sid = getArgReference_bat(stk, pci, 2);
if (*sid && (s = BATdescriptor(*sid)) == NULL) {
BBPunfix(b->batCacheid);
throw(MAL, "batcalc.convert", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
}
}
bn = BATconvert(b, s, tp, abort_on_error);
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (bn == NULL) {
char buf[20];
snprintf(buf, sizeof(buf), "batcalc.%s", ATOMname(tp));
return mythrow(MAL, buf, OPERATION_FAILED);
}
bid = getArgReference_bat(stk, pci, 0);
BBPkeepref(*bid = bn->batCacheid);
return MAL_SUCCEED;
}
示例5: AGGRsubmin_val
str
AGGRsubmin_val(bat *retval, bat *bid, bat *gid, bat *eid, bit *skip_nils)
{
BAT *a, *b, *r;
str res;
bat ret;
if ((res = AGGRsubgrouped(&ret, NULL, bid, gid, eid, NULL, *skip_nils,
0, TYPE_oid, BATgroupmin, NULL, "aggr.submin")) != MAL_SUCCEED)
return res;
b = BATdescriptor(*bid);
if( b == NULL)
throw(MAL,"aggr.submax", INTERNAL_BAT_ACCESS);
a = BATdescriptor(ret);
if( a == NULL){
BBPreleaseref(b->batCacheid);
throw(MAL,"aggr.submax", INTERNAL_BAT_ACCESS);
}
r = BATproject(a, b);
BBPreleaseref(b->batCacheid);
BBPreleaseref(a->batCacheid);
BBPdecref(ret, TRUE);
BBPkeepref(*retval = r->batCacheid);
return MAL_SUCCEED;
}
示例6: BKCappend_force_wrap
char *
BKCappend_force_wrap(bat *r, const bat *bid, const bat *uid, const bit *force)
{
BAT *b, *u;
gdk_return ret;
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "bat.append", RUNTIME_OBJECT_MISSING);
if ((u = BATdescriptor(*uid)) == NULL) {
BBPunfix(b->batCacheid);
throw(MAL, "bat.append", RUNTIME_OBJECT_MISSING);
}
if (BATcount(u) == 0) {
ret = GDK_SUCCEED;
} else {
if ((b = setaccess(b, BAT_WRITE)) == NULL)
throw(MAL, "bat.append", OPERATION_FAILED);
ret = BATappend(b, u, *force);
}
BBPunfix(u->batCacheid);
if (ret != GDK_SUCCEED) {
BBPunfix(b->batCacheid);
throw(MAL, "bat.append", GDK_EXCEPTION);
}
if( b->batPersistence == PERSISTENT)
BATmsync(b);
BBPkeepref(*r = b->batCacheid);
return MAL_SUCCEED;
}
示例7: BKCdelete_bat_bun
str
BKCdelete_bat_bun(bat *r, const bat *bid, const bat *sid)
{
BAT *b, *s;
gdk_return ret;
if (*bid == *sid)
return BKCdelete_all(r, bid);
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "bat.delete", RUNTIME_OBJECT_MISSING);
if ((s = BATdescriptor(*sid)) == NULL) {
BBPunfix(b->batCacheid);
throw(MAL, "bat.delete", RUNTIME_OBJECT_MISSING);
}
ret = BATdel(b, s, FALSE);
BBPunfix(s->batCacheid);
if (ret != GDK_SUCCEED) {
BBPunfix(b->batCacheid);
throw(MAL, "bat.delete_bat_bun", GDK_EXCEPTION);
}
if( b->batPersistence == PERSISTENT)
BATmsync(b);
BBPkeepref(*r = b->batCacheid);
return MAL_SUCCEED;
}
示例8: AGGRsubmaxcand_val
str
AGGRsubmaxcand_val(bat *retval, bat *bid, bat *gid, bat *eid, bat *sid, bit *skip_nils)
{
BAT *a, *b, *r;
str res;
bat ret;
if ((res = AGGRsubgrouped(&ret, NULL, bid, gid, eid, sid, *skip_nils,
0, TYPE_oid, BATgroupmax, NULL, "aggr.submax")) != MAL_SUCCEED)
return res;
b = BATdescriptor(*bid);
if ( b == NULL)
throw(MAL,"aggr.max",RUNTIME_OBJECT_MISSING);
a = BATdescriptor(ret);
if ( a == NULL){
BBPreleaseref(b->batCacheid);
throw(MAL,"aggr.max",RUNTIME_OBJECT_MISSING);
}
r = BATproject(a, b);
BBPreleaseref(b->batCacheid);
BBPreleaseref(a->batCacheid);
BBPdecref(ret, TRUE);
BBPkeepref(*retval = r->batCacheid);
return MAL_SUCCEED;
}
示例9: CMDcalcavg
str
CMDcalcavg(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
dbl avg;
BUN vals;
bat *bid;
BAT *b, *s = NULL;
gdk_return ret;
(void) cntxt;
(void) mb;
bid = getArgReference_bat(stk, pci, pci->retc + 0);
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "aggr.avg", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
if (pci->retc == pci->retc + 2) {
bat *sid = getArgReference_bat(stk, pci, pci->retc + 1);
if (*sid && (s = BATdescriptor(*sid)) == NULL) {
BBPunfix(b->batCacheid);
throw(MAL, "aggr.avg", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
}
}
ret = BATcalcavg(b, s, &avg, &vals);
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
if (ret != GDK_SUCCEED)
return mythrow(MAL, "aggr.avg", OPERATION_FAILED);
* getArgReference_dbl(stk, pci, 0) = avg;
if (pci->retc == 2)
* getArgReference_lng(stk, pci, 1) = vals;
return MAL_SUCCEED;
}
示例10: DCselectInsert
str DCselectInsert(int *ret, int *res, int *bid, lng *low, lng *hgh)
{
BAT *b, *r;
lng *readerH, *writerH;
lng *readerT, *writerT;
BUN size, i;
(void) ret;
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "dc.selectInsert", "Cannot access input BAT");
if ((r = BATdescriptor(*res)) == NULL)
throw(MAL, "dc.selectInsert", "Cannot access result BAT");
size = BATcount(b);
if (size > BATcapacity(r) - BATcount(r)) {
BUN ncap;
BUN grows;
BUN needed = size - (BATcapacity(r) - BATcount(r));
ncap = BATcapacity(r) + needed;
grows = BATgrows(r);
if (ncap > grows)
grows = ncap;
if (BATextend(r, grows) == NULL)
throw(MAL, "dc.selectInsert", "Failed to make room for the new values");
}
/*printf("in dc.selectInsert size is "OIDFMT,size);*/
writerH = (lng *) Hloc(r, BUNfirst(r));
writerT = (lng *) Tloc(r, BUNfirst(r));
readerH = (lng *) Hloc(b, BUNfirst(b));
readerT = (lng *) Tloc(b, BUNfirst(b));
for (i = 0; i < size; i++) {
if (*readerT >= *low && *readerT <= *hgh) {
*writerH = *readerH;
*writerT = *readerT;
writerH++;
writerT++;
}
readerH++;
readerT++;
}
BATsetcount(r, (BUN) (writerT - (lng *) Tloc(r, BUNfirst(r))));
BBPunfix(*bid);
BBPunfix(*res);
return MAL_SUCCEED;
}
示例11: MATpackIncrement
/*
* Enable incremental packing. The SQL front-end requires
* fixed oid sequences.
*/
str
MATpackIncrement(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
bat *ret = getArgReference_bat(stk,p,0);
int pieces;
BAT *b, *bb, *bn;
size_t newsize;
(void) cntxt;
b = BATdescriptor( stk->stk[getArg(p,1)].val.ival);
if ( b == NULL)
throw(MAL, "mat.pack", RUNTIME_OBJECT_MISSING);
if ( getArgType(mb,p,2) == TYPE_int){
/* first step, estimate with some slack */
pieces = stk->stk[getArg(p,2)].val.ival;
bn = BATnew(TYPE_void, b->ttype?b->ttype:TYPE_oid, (BUN)(1.2 * BATcount(b) * pieces), TRANSIENT);
if (bn == NULL)
throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
/* allocate enough space for the vheap, but not for strings,
* since BATappend does clever things for strings */
if ( b->T->vheap && bn->T->vheap && ATOMstorage(b->ttype) != TYPE_str){
newsize = b->T->vheap->size * pieces;
if (HEAPextend(bn->T->vheap, newsize, TRUE) != GDK_SUCCEED)
throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
}
BATseqbase(bn, b->H->seq);
BATseqbase(BATmirror(bn), b->T->seq);
BATappend(bn,b,FALSE);
assert(!bn->H->nil || !bn->H->nonil);
assert(!bn->T->nil || !bn->T->nonil);
bn->H->align = (pieces-1);
BBPkeepref(*ret = bn->batCacheid);
BBPunfix(b->batCacheid);
} else {
/* remaining steps */
bb = BATdescriptor(stk->stk[getArg(p,2)].val.ival);
if ( bb ){
if (BATcount(b) == 0)
BATseqbase(b, bb->H->seq);
if (BATcount(b) == 0)
BATseqbase(BATmirror(b), bb->T->seq);
BATappend(b,bb,FALSE);
}
b->H->align--;
if(b->H->align == 0)
BATsetaccess(b, BAT_READ);
assert(!b->H->nil || !b->H->nonil);
assert(!b->T->nil || !b->T->nonil);
BBPkeepref(*ret = b->batCacheid);
if( bb)
BBPunfix(bb->batCacheid);
}
return MAL_SUCCEED;
}
示例12: DCreplaceTailBasedOnHead
/*
* @-
* The operator below is only working for a very limited cases.
*/
str DCreplaceTailBasedOnHead(int *ret, int *res, int *bid)
{
BAT *b, *r;
oid *readerH_b;
int *writerT_r, *readerT_b;
BUN size_b, size_r, i;
(void) ret;
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "dc.replaceTailBasedOnHead", "Cannot access input BAT");
/* check for a failure */
assert(b != NULL);
if ((r = BATdescriptor(*res)) == NULL)
throw(MAL, "dc.replaceTailBasedOnHead", "Cannot access result BAT");
/* check for a failure */
assert(r != NULL);
/* remove Hashes etc */
if (r->H->hash)
HASHremove(r);
if (r->T->hash)
HASHremove(BATmirror(r));
size_r = BATcount(r);
size_b = BATcount(b);
if ((b->htype == TYPE_void) && (size_b == size_r)) {
writerT_r = (int *) Tloc(r, BUNfirst(r));
readerT_b = (int *) Tloc(b, BUNfirst(b));
for (i = 0; i < size_r; i++) {
*writerT_r = *readerT_b;
writerT_r++;
readerT_b++;
}
} else if ((b->htype != TYPE_void) && (size_b < size_r)) {
readerH_b = (oid *) Hloc(b, BUNfirst(b));
readerT_b = (int *) Tloc(b, BUNfirst(b));
for (i = 0; i < size_b; i++) {
writerT_r = (int *) Tloc(r, BUNfirst(r)) + *readerH_b;
*writerT_r = *readerT_b;
readerH_b++;
readerT_b++;
}
}
BBPunfix(*bid);
BBPunfix(*res);
r->batDirty = TRUE;
return MAL_SUCCEED;
}
示例13: AGGRquantile3
str
AGGRquantile3(bat *retval, bat *bid, bat *gid, bat *eid, bat *quantile)
{
// this is inlined from AGGRgrouped3 to avoid changing all the other functions for now
BAT *b, *g, *e, *q;
b = BATdescriptor(*bid); /* [head,value] */
g = BATdescriptor(*gid); /* [head,gid] */
e = BATdescriptor(*eid); /* [gid,any] */
q = BATdescriptor(*quantile);
return AGGRgrouped(retval, NULL, b, g, e, TYPE_any, NULL, NULL, BATgroupquantile, q, 0, "aggr.quantile");
}
示例14: AGGRgrouped3
static str
AGGRgrouped3(bat *retval, bat *bid, bat *gid, bat *eid, int tp,
BAT *(*grpfunc)(BAT *, BAT *, BAT *, BAT *, int, int, int),
int skip_nils,
const char *malfunc)
{
BAT *b, *g, *e;
b = BATdescriptor(*bid); /* [head,value] */
g = BATdescriptor(*gid); /* [head,gid] */
e = BATdescriptor(*eid); /* [gid,any] */
return AGGRgrouped(retval, b, g, e, tp, grpfunc, skip_nils, malfunc);
}
示例15: BKCgetSize
str
BKCgetSize(lng *tot, const bat *bid){
BAT *b;
lng size = 0;
lng blksize = (lng) MT_pagesize();
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "bat.getDiskSize", RUNTIME_OBJECT_MISSING);
}
size = sizeof (bat);
if ( !isVIEW(b)) {
BUN cnt = BATcapacity(b);
size += ROUND_UP(b->H->heap.free, blksize);
size += ROUND_UP(b->T->heap.free, blksize);
if (b->H->vheap)
size += ROUND_UP(b->H->vheap->free, blksize);
if (b->T->vheap)
size += ROUND_UP(b->T->vheap->free, blksize);
if (b->H->hash)
size += ROUND_UP(sizeof(BUN) * cnt, blksize);
if (b->T->hash)
size += ROUND_UP(sizeof(BUN) * cnt, blksize);
size += IMPSimprintsize(b);
}
*tot = size;
BBPunfix(*bid);
return MAL_SUCCEED;
}